Skip to content

Commit d539334

Browse files
authored
Release v2.6.0 (#639)
1 parent bab7008 commit d539334

File tree

7 files changed

+40
-6
lines changed

7 files changed

+40
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes
22

3+
## [v2.6.0] (2024-12-02)
4+
5+
* Add `instrument_sqlite3` by @Kludex in [#634](https://github.com/pydantic/logfire/pull/634)
6+
37
## [v2.5.0] (2024-11-27)
48

59
* Add `logfire.suppress_scopes` method by @alexmojaki in [#628](https://github.com/pydantic/logfire/pull/628)
@@ -445,3 +449,4 @@ First release from new repo!
445449
[v2.4.0]: https://github.com/pydantic/logfire/compare/v2.3.0...v2.4.0
446450
[v2.4.1]: https://github.com/pydantic/logfire/compare/v2.4.0...v2.4.1
447451
[v2.5.0]: https://github.com/pydantic/logfire/compare/v2.4.1...v2.5.0
452+
[v2.6.0]: https://github.com/pydantic/logfire/compare/v2.5.0...v2.6.0

logfire-api/logfire_api/__init__.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ from .version import VERSION as VERSION
1212
from logfire.sampling import SamplingOptions as SamplingOptions
1313
from typing import Any
1414

15-
__all__ = ['Logfire', 'LogfireSpan', 'LevelName', 'AdvancedOptions', 'ConsoleOptions', 'CodeSource', 'PydanticPlugin', 'configure', 'span', 'instrument', 'log', 'trace', 'debug', 'notice', 'info', 'warn', 'error', 'exception', 'fatal', 'force_flush', 'log_slow_async_callbacks', 'install_auto_tracing', 'instrument_asgi', 'instrument_wsgi', 'instrument_pydantic', 'instrument_fastapi', 'instrument_openai', 'instrument_anthropic', 'instrument_asyncpg', 'instrument_httpx', 'instrument_celery', 'instrument_requests', 'instrument_psycopg', 'instrument_django', 'instrument_flask', 'instrument_starlette', 'instrument_aiohttp_client', 'instrument_sqlalchemy', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'instrument_system_metrics', 'AutoTraceModule', 'with_tags', 'with_settings', 'suppress_scopes', 'shutdown', 'load_spans_from_file', 'no_auto_trace', 'ScrubMatch', 'ScrubbingOptions', 'VERSION', 'suppress_instrumentation', 'StructlogProcessor', 'LogfireLoggingHandler', 'loguru_handler', 'SamplingOptions', 'MetricsOptions']
15+
__all__ = ['Logfire', 'LogfireSpan', 'LevelName', 'AdvancedOptions', 'ConsoleOptions', 'CodeSource', 'PydanticPlugin', 'configure', 'span', 'instrument', 'log', 'trace', 'debug', 'notice', 'info', 'warn', 'error', 'exception', 'fatal', 'force_flush', 'log_slow_async_callbacks', 'install_auto_tracing', 'instrument_asgi', 'instrument_wsgi', 'instrument_pydantic', 'instrument_fastapi', 'instrument_openai', 'instrument_anthropic', 'instrument_asyncpg', 'instrument_httpx', 'instrument_celery', 'instrument_requests', 'instrument_psycopg', 'instrument_django', 'instrument_flask', 'instrument_starlette', 'instrument_aiohttp_client', 'instrument_sqlalchemy', 'instrument_sqlite3', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'instrument_system_metrics', 'AutoTraceModule', 'with_tags', 'with_settings', 'suppress_scopes', 'shutdown', 'load_spans_from_file', 'no_auto_trace', 'ScrubMatch', 'ScrubbingOptions', 'VERSION', 'suppress_instrumentation', 'StructlogProcessor', 'LogfireLoggingHandler', 'loguru_handler', 'SamplingOptions', 'MetricsOptions']
1616

1717
DEFAULT_LOGFIRE_INSTANCE = Logfire()
1818
span = DEFAULT_LOGFIRE_INSTANCE.span
@@ -36,6 +36,7 @@ instrument_flask = DEFAULT_LOGFIRE_INSTANCE.instrument_flask
3636
instrument_starlette = DEFAULT_LOGFIRE_INSTANCE.instrument_starlette
3737
instrument_aiohttp_client = DEFAULT_LOGFIRE_INSTANCE.instrument_aiohttp_client
3838
instrument_sqlalchemy = DEFAULT_LOGFIRE_INSTANCE.instrument_sqlalchemy
39+
instrument_sqlite3 = DEFAULT_LOGFIRE_INSTANCE.instrument_sqlite3
3940
instrument_redis = DEFAULT_LOGFIRE_INSTANCE.instrument_redis
4041
instrument_pymongo = DEFAULT_LOGFIRE_INSTANCE.instrument_pymongo
4142
instrument_mysql = DEFAULT_LOGFIRE_INSTANCE.instrument_mysql
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import sqlite3
2+
from opentelemetry.trace import TracerProvider
3+
from typing import TypeVar, TypedDict, Unpack
4+
5+
SQLite3Connection = TypeVar('SQLite3Connection', bound=sqlite3.Connection | None)
6+
7+
class SQLite3InstrumentKwargs(TypedDict, total=False):
8+
skip_dep_check: bool
9+
10+
def instrument_sqlite3(*, conn: SQLite3Connection, tracer_provider: TracerProvider, **kwargs: Unpack[SQLite3InstrumentKwargs]) -> SQLite3Connection:
11+
"""Instrument the `sqlite3` module so that spans are automatically created for each query.
12+
13+
See the `Logfire.instrument_sqlite3` method for details.
14+
"""

logfire-api/logfire_api/_internal/main.pyi

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ from .integrations.psycopg import PsycopgInstrumentKwargs as PsycopgInstrumentKw
2020
from .integrations.pymongo import PymongoInstrumentKwargs as PymongoInstrumentKwargs
2121
from .integrations.redis import RedisInstrumentKwargs as RedisInstrumentKwargs
2222
from .integrations.sqlalchemy import SQLAlchemyInstrumentKwargs as SQLAlchemyInstrumentKwargs
23+
from .integrations.sqlite3 import SQLite3Connection as SQLite3Connection, SQLite3InstrumentKwargs as SQLite3InstrumentKwargs
2324
from .integrations.starlette import StarletteInstrumentKwargs as StarletteInstrumentKwargs
2425
from .integrations.system_metrics import Base as SystemMetricsBase, Config as SystemMetricsConfig
2526
from .integrations.wsgi import WSGIInstrumentKwargs as WSGIInstrumentKwargs
@@ -704,6 +705,20 @@ class Logfire:
704705
[OpenTelemetry SQLAlchemy Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/sqlalchemy/sqlalchemy.html)
705706
library, specifically `SQLAlchemyInstrumentor().instrument()`, to which it passes `**kwargs`.
706707
"""
708+
def instrument_sqlite3(self, conn: SQLite3Connection = None, **kwargs: Unpack[SQLite3InstrumentKwargs]) -> SQLite3Connection:
709+
"""Instrument the `sqlite3` module or a specific connection so that spans are automatically created for each operation.
710+
711+
Uses the
712+
[OpenTelemetry SQLite3 Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/sqlite3/sqlite3.html)
713+
library.
714+
715+
Args:
716+
conn: The `sqlite3` connection to instrument, or `None` to instrument all connections.
717+
**kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` methods.
718+
719+
Returns:
720+
If a connection is provided, returns the instrumented connection. If no connection is provided, returns `None`.
721+
"""
707722
def instrument_pymongo(self, **kwargs: Unpack[PymongoInstrumentKwargs]) -> None:
708723
"""Instrument the `pymongo` module so that spans are automatically created for each operation.
709724
@@ -735,7 +750,6 @@ class Logfire:
735750
736751
Returns:
737752
If a connection is provided, returns the instrumented connection. If no connection is provided, returns None.
738-
739753
"""
740754
def instrument_system_metrics(self, config: SystemMetricsConfig | None = None, base: SystemMetricsBase = 'basic') -> None:
741755
"""Collect system metrics.

logfire-api/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "logfire-api"
7-
version = "2.5.0"
7+
version = "2.6.0"
88
description = "Shim for the Logfire SDK which does nothing unless Logfire is installed"
99
authors = [
1010
{ name = "Pydantic Team", email = "[email protected]" },

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "logfire"
7-
version = "2.5.0"
7+
version = "2.6.0"
88
description = "The best Python observability tool! 🪵🔥"
99
requires-python = ">=3.8"
1010
authors = [

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)