Skip to content

Commit bae6db6

Browse files
authored
Update generated stubs (#354)
1 parent cdc8eb5 commit bae6db6

File tree

3 files changed

+22
-31
lines changed

3 files changed

+22
-31
lines changed

logfire-api/logfire_api/_internal/integrations/mysql.pyi

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
1-
from __future__ import annotations
1+
from mysql.connector.abstracts import MySQLConnectionAbstract
2+
from mysql.connector.pooling import PooledMySQLConnection
3+
from typing_extensions import TypeVar, TypedDict, Unpack
24

3-
from typing import TYPE_CHECKING
5+
MySQLConnection = TypeVar('MySQLConnection', bound=PooledMySQLConnection | MySQLConnectionAbstract | None)
46

5-
from opentelemetry.instrumentation.mysql import MySQLInstrumentor
7+
class MySQLInstrumentKwargs(TypedDict, total=False):
8+
skip_dep_check: bool
69

7-
if TYPE_CHECKING:
8-
from mysql.connector.abstracts import MySQLConnectionAbstract
9-
from mysql.connector.pooling import PooledMySQLConnection
10-
from typing_extensions import TypedDict, TypeVar, Unpack
11-
12-
MySQLConnection = TypeVar('MySQLConnection', PooledMySQLConnection, MySQLConnectionAbstract, None)
13-
14-
class MySQLInstrumentKwargs(TypedDict, total=False):
15-
skip_dep_check: bool
16-
17-
18-
def instrument_mysql(
19-
conn: MySQLConnection = None,
20-
**kwargs: Unpack[MySQLInstrumentKwargs],
21-
) -> MySQLConnection:
10+
def instrument_mysql(conn: MySQLConnection = None, **kwargs: Unpack[MySQLInstrumentKwargs]) -> MySQLConnection:
2211
"""Instrument the `mysql` module or a specific MySQL connection so that spans are automatically created for each operation.
2312
2413
This function uses the OpenTelemetry MySQL Instrumentation library to instrument either the entire `mysql` module or a specific MySQL connection.

logfire-api/logfire_api/_internal/main.pyi

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ from . import async_ as async_
66
from ..version import VERSION as VERSION
77
from .auto_trace import AutoTraceModule as AutoTraceModule, install_auto_tracing as install_auto_tracing
88
from .config import GLOBAL_CONFIG as GLOBAL_CONFIG, LogfireConfig as LogfireConfig
9-
from .constants import ATTRIBUTES_JSON_SCHEMA_KEY as ATTRIBUTES_JSON_SCHEMA_KEY, ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_SAMPLE_RATE_KEY as ATTRIBUTES_SAMPLE_RATE_KEY, ATTRIBUTES_SPAN_TYPE_KEY as ATTRIBUTES_SPAN_TYPE_KEY, ATTRIBUTES_TAGS_KEY as ATTRIBUTES_TAGS_KEY, ATTRIBUTES_VALIDATION_ERROR_KEY as ATTRIBUTES_VALIDATION_ERROR_KEY, DISABLE_CONSOLE_KEY as DISABLE_CONSOLE_KEY, LevelName as LevelName, NULL_ARGS_KEY as NULL_ARGS_KEY, OTLP_MAX_INT_SIZE as OTLP_MAX_INT_SIZE, log_level_attributes as log_level_attributes
9+
from .constants import ATTRIBUTES_JSON_SCHEMA_KEY as ATTRIBUTES_JSON_SCHEMA_KEY, ATTRIBUTES_LOG_LEVEL_NUM_KEY as ATTRIBUTES_LOG_LEVEL_NUM_KEY, ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_SAMPLE_RATE_KEY as ATTRIBUTES_SAMPLE_RATE_KEY, ATTRIBUTES_SPAN_TYPE_KEY as ATTRIBUTES_SPAN_TYPE_KEY, ATTRIBUTES_TAGS_KEY as ATTRIBUTES_TAGS_KEY, ATTRIBUTES_VALIDATION_ERROR_KEY as ATTRIBUTES_VALIDATION_ERROR_KEY, DISABLE_CONSOLE_KEY as DISABLE_CONSOLE_KEY, LEVEL_NUMBERS as LEVEL_NUMBERS, LevelName as LevelName, NULL_ARGS_KEY as NULL_ARGS_KEY, OTLP_MAX_INT_SIZE as OTLP_MAX_INT_SIZE, log_level_attributes as log_level_attributes
1010
from .formatter import logfire_format as logfire_format, logfire_format_with_magic as logfire_format_with_magic
1111
from .instrument import LogfireArgs as LogfireArgs, instrument as instrument
1212
from .integrations.asyncpg import AsyncPGInstrumentKwargs as AsyncPGInstrumentKwargs
1313
from .integrations.celery import CeleryInstrumentKwargs as CeleryInstrumentKwargs
1414
from .integrations.flask import FlaskInstrumentKwargs as FlaskInstrumentKwargs
1515
from .integrations.httpx import HTTPXInstrumentKwargs as HTTPXInstrumentKwargs
16+
from .integrations.mysql import MySQLConnection as MySQLConnection, MySQLInstrumentKwargs as MySQLInstrumentKwargs
1617
from .integrations.psycopg import PsycopgInstrumentKwargs as PsycopgInstrumentKwargs
1718
from .integrations.pymongo import PymongoInstrumentKwargs as PymongoInstrumentKwargs
1819
from .integrations.redis import RedisInstrumentKwargs as RedisInstrumentKwargs
1920
from .integrations.sqlalchemy import SQLAlchemyInstrumentKwargs as SQLAlchemyInstrumentKwargs
2021
from .integrations.starlette import StarletteInstrumentKwargs as StarletteInstrumentKwargs
21-
from .integrations.mysql import MySQLConnection as MySQLConnection, MySQLInstrumentKwargs as MySQLInstrumentKwargs
2222
from .json_encoder import logfire_json_dumps as logfire_json_dumps
2323
from .json_schema import JsonSchemaProperties as JsonSchemaProperties, attributes_json_schema as attributes_json_schema, attributes_json_schema_properties as attributes_json_schema_properties, create_json_schema as create_json_schema
2424
from .metrics import ProxyMeterProvider as ProxyMeterProvider
2525
from .stack_info import get_user_stack_info as get_user_stack_info
2626
from .tracer import ProxyTracerProvider as ProxyTracerProvider
27-
from .utils import handle_internal_errors as handle_internal_errors, log_internal_error as log_internal_error, uniquify_sequence as uniquify_sequence
27+
from .utils import SysExcInfo as SysExcInfo, handle_internal_errors as handle_internal_errors, log_internal_error as log_internal_error, uniquify_sequence as uniquify_sequence
2828
from django.http import HttpRequest as HttpRequest, HttpResponse as HttpResponse
2929
from fastapi import FastAPI
3030
from flask.app import Flask
@@ -35,7 +35,6 @@ from opentelemetry.util import types as otel_types
3535
from starlette.applications import Starlette
3636
from starlette.requests import Request as Request
3737
from starlette.websockets import WebSocket as WebSocket
38-
from types import TracebackType as TracebackType
3938
from typing import Any, Callable, ContextManager, Iterable, Literal, Sequence, TypeVar
4039
from typing_extensions import LiteralString, Unpack
4140

@@ -619,8 +618,14 @@ class Logfire:
619618
[OpenTelemetry pymongo Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/pymongo/pymongo.html)
620619
library, specifically `PymongoInstrumentor().instrument()`, to which it passes `**kwargs`.
621620
"""
622-
def instrument_mysql(self, conn: MySQLConnection, **kwargs: Unpack[MySQLInstrumentKwargs],
623-
) -> MySQLConnection:
621+
def instrument_redis(self, **kwargs: Unpack[RedisInstrumentKwargs]) -> None:
622+
"""Instrument the `redis` module so that spans are automatically created for each operation.
623+
624+
Uses the
625+
[OpenTelemetry Redis Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/redis/redis.html)
626+
library, specifically `RedisInstrumentor().instrument()`, to which it passes `**kwargs`.
627+
"""
628+
def instrument_mysql(self, conn: MySQLConnection = None, **kwargs: Unpack[MySQLInstrumentKwargs]) -> MySQLConnection:
624629
"""Instrument the `mysql` module or a specific MySQL connection so that spans are automatically created for each operation.
625630
626631
Uses the
@@ -634,13 +639,6 @@ class Logfire:
634639
Returns:
635640
If a connection is provided, returns the instrumented connection. If no connection is provided, returns None.
636641
637-
"""
638-
def instrument_redis(self, **kwargs: Unpack[RedisInstrumentKwargs]) -> None:
639-
"""Instrument the `redis` module so that spans are automatically created for each operation.
640-
641-
Uses the
642-
[OpenTelemetry Redis Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/redis/redis.html)
643-
library, specifically `RedisInstrumentor().instrument()`, to which it passes `**kwargs`.
644642
"""
645643
def metric_counter(self, name: str, *, unit: str = '', description: str = '') -> Counter:
646644
"""Create a counter metric.

logfire-api/logfire_api/_internal/utils.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import typing
12
from _typeshed import Incomplete
23
from collections.abc import Generator
34
from logfire._internal.stack_info import is_user_code as is_user_code
@@ -83,5 +84,8 @@ def is_instrumentation_suppressed() -> bool:
8384
def suppress_instrumentation() -> Generator[None, None, None]:
8485
"""Context manager to suppress all logs/spans generated by logfire or OpenTelemetry."""
8586
def log_internal_error() -> None: ...
87+
88+
SysExcInfo: typing.TypeAlias
89+
8690
def handle_internal_errors() -> Generator[None, None, None]: ...
8791
def maybe_capture_server_headers(capture: bool): ...

0 commit comments

Comments
 (0)