-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to intrument a single MySQL conn
- Loading branch information
1 parent
4b365ff
commit 1521bb1
Showing
9 changed files
with
309 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from opentelemetry.instrumentation.mysql import MySQLInstrumentor | ||
|
||
if TYPE_CHECKING: | ||
from mysql.connector.abstracts import MySQLConnectionAbstract | ||
from mysql.connector.pooling import PooledMySQLConnection | ||
from typing_extensions import TypedDict, TypeVar, Unpack | ||
|
||
MySQLConnection = TypeVar('MySQLConnection', PooledMySQLConnection, MySQLConnectionAbstract, None) | ||
|
||
class MySQLInstrumentKwargs(TypedDict, total=False): | ||
skip_dep_check: bool | ||
|
||
|
||
def instrument_mysql( | ||
conn: MySQLConnection = None, | ||
**kwargs: Unpack[MySQLInstrumentKwargs], | ||
) -> MySQLConnection: | ||
"""Instrument the `mysql` module or a specific MySQL connection so that spans are automatically created for each operation. | ||
This function uses the OpenTelemetry MySQL Instrumentation library to instrument either the entire `mysql` module or a specific MySQL connection. | ||
Args: | ||
conn: The MySQL connection to instrument. If None, the entire `mysql` module is instrumented. | ||
**kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` methods. | ||
Returns: | ||
If a connection is provided, returns the instrumented connection. If no connection is provided, returns None. | ||
See the `Logfire.instrument_mysql` method for details. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.