Skip to content

Commit 67c20af

Browse files
authored
Release v2.5.0 (#629)
1 parent e8dfd4b commit 67c20af

File tree

9 files changed

+30
-17
lines changed

9 files changed

+30
-17
lines changed

CHANGELOG.md

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

3+
## [v2.5.0] (2024-11-27)
4+
5+
* Add `logfire.suppress_scopes` method by @alexmojaki in [#628](https://github.com/pydantic/logfire/pull/628)
6+
* Replace `ModuleNotFoundError` by `ImportError` by @Kludex in [#622](https://github.com/pydantic/logfire/pull/622)
7+
38
## [v2.4.1] (2024-11-21)
49

510
* Allow new context argument of metric instrument methods to be passed positionally by @alexmojaki in [#616](https://github.com/pydantic/logfire/pull/616)
@@ -439,3 +444,4 @@ First release from new repo!
439444
[v2.3.0]: https://github.com/pydantic/logfire/compare/v2.2.1...v2.3.0
440445
[v2.4.0]: https://github.com/pydantic/logfire/compare/v2.3.0...v2.4.0
441446
[v2.4.1]: https://github.com/pydantic/logfire/compare/v2.4.0...v2.4.1
447+
[v2.5.0]: https://github.com/pydantic/logfire/compare/v2.4.1...v2.5.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', '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_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
@@ -40,6 +40,7 @@ instrument_redis = DEFAULT_LOGFIRE_INSTANCE.instrument_redis
4040
instrument_pymongo = DEFAULT_LOGFIRE_INSTANCE.instrument_pymongo
4141
instrument_mysql = DEFAULT_LOGFIRE_INSTANCE.instrument_mysql
4242
instrument_system_metrics = DEFAULT_LOGFIRE_INSTANCE.instrument_system_metrics
43+
suppress_scopes = DEFAULT_LOGFIRE_INSTANCE.suppress_scopes
4344
shutdown = DEFAULT_LOGFIRE_INSTANCE.shutdown
4445
with_tags = DEFAULT_LOGFIRE_INSTANCE.with_tags
4546
with_settings = DEFAULT_LOGFIRE_INSTANCE.with_settings

logfire-api/logfire_api/_internal/config.pyi

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ from .tracer import PendingSpanProcessor as PendingSpanProcessor, ProxyTracerPro
2020
from .utils import SeededRandomIdGenerator as SeededRandomIdGenerator, UnexpectedResponse as UnexpectedResponse, ensure_data_dir_exists as ensure_data_dir_exists, read_toml_file as read_toml_file, suppress_instrumentation as suppress_instrumentation
2121
from _typeshed import Incomplete
2222
from dataclasses import dataclass
23-
from functools import cached_property
2423
from logfire.exceptions import LogfireConfigError as LogfireConfigError
2524
from logfire.sampling import SamplingOptions as SamplingOptions
2625
from logfire.sampling._tail_sampling import TailSamplingProcessor as TailSamplingProcessor
2726
from logfire.version import VERSION as VERSION
28-
from opentelemetry.metrics import Meter
2927
from opentelemetry.sdk.metrics.export import MetricReader as MetricReader
3028
from opentelemetry.sdk.trace import SpanProcessor
3129
from opentelemetry.sdk.trace.id_generator import IdGenerator
@@ -204,15 +202,7 @@ class LogfireConfig(_LogfireConfigData):
204202
The meter provider.
205203
"""
206204
def warn_if_not_initialized(self, message: str): ...
207-
@cached_property
208-
def meter(self) -> Meter:
209-
"""Get a meter from this `LogfireConfig`.
210-
211-
This is used internally and should not be called by users of the SDK.
212-
213-
Returns:
214-
The meter.
215-
"""
205+
def suppress_scopes(self, *scopes: str) -> None: ...
216206

217207
GLOBAL_CONFIG: Incomplete
218208

logfire-api/logfire_api/_internal/main.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,12 @@ class Logfire:
970970
unit: The unit of the metric.
971971
description: The description of the metric.
972972
"""
973+
def suppress_scopes(self, *scopes: str) -> None:
974+
"""Prevent spans and metrics from being created for the given OpenTelemetry scope names.
975+
976+
To get the scope name of a span/metric,
977+
check the value of the `otel_scope_name` column in the Logfire database.
978+
"""
973979
def shutdown(self, timeout_millis: int = 30000, flush: bool = True) -> bool:
974980
"""Shut down all tracers and meters.
975981

logfire-api/logfire_api/_internal/metrics.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class ProxyMeterProvider(MeterProvider):
1414
provider: MeterProvider
1515
meters: WeakSet[_ProxyMeter] = ...
1616
lock: Lock = ...
17+
suppressed_scopes: set[str] = ...
1718
def get_meter(self, name: str, version: str | None = None, schema_url: str | None = None, *args: Any, **kwargs: Any) -> Meter: ...
19+
def suppress_scopes(self, *scopes: str) -> None: ...
1820
def set_meter_provider(self, meter_provider: MeterProvider) -> None: ...
1921
def shutdown(self, timeout_millis: float = 30000) -> None: ...
2022
def force_flush(self, timeout_millis: float = 30000) -> None: ...

logfire-api/logfire_api/_internal/tracer.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import opentelemetry.trace as trace_api
22
from .config import LogfireConfig as LogfireConfig
33
from .constants import ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_PENDING_SPAN_REAL_PARENT_KEY as ATTRIBUTES_PENDING_SPAN_REAL_PARENT_KEY, ATTRIBUTES_SAMPLE_RATE_KEY as ATTRIBUTES_SAMPLE_RATE_KEY, ATTRIBUTES_SPAN_TYPE_KEY as ATTRIBUTES_SPAN_TYPE_KEY, PENDING_SPAN_NAME_SUFFIX as PENDING_SPAN_NAME_SUFFIX
4+
from _typeshed import Incomplete
45
from dataclasses import dataclass
56
from opentelemetry import context as context_api
67
from opentelemetry.context import Context
@@ -21,8 +22,10 @@ class ProxyTracerProvider(TracerProvider):
2122
config: LogfireConfig
2223
tracers: WeakKeyDictionary[_ProxyTracer, Callable[[], Tracer]] = ...
2324
lock: Lock = ...
25+
suppressed_scopes: set[str] = ...
2426
def set_provider(self, provider: SDKTracerProvider) -> None: ...
25-
def get_tracer(self, *args: Any, is_span_tracer: bool = True, **kwargs: Any) -> _ProxyTracer: ...
27+
def suppress_scopes(self, *scopes: str) -> None: ...
28+
def get_tracer(self, instrumenting_module_name: str, *args: Any, is_span_tracer: bool = True, **kwargs: Any) -> _ProxyTracer: ...
2629
def add_span_processor(self, span_processor: Any) -> None: ...
2730
def shutdown(self) -> None: ...
2831
@property
@@ -49,6 +52,7 @@ class _MaybeDeterministicTimestampSpan(trace_api.Span, ReadableSpan):
4952
@dataclass
5053
class _ProxyTracer(Tracer):
5154
"""A tracer that wraps another internal tracer allowing it to be re-assigned."""
55+
instrumenting_module_name: str
5256
tracer: Tracer
5357
provider: ProxyTracerProvider
5458
is_span_tracer: bool
@@ -58,6 +62,10 @@ class _ProxyTracer(Tracer):
5862
def start_span(self, name: str, context: Context | None = None, kind: SpanKind = ..., attributes: otel_types.Attributes = None, links: Sequence[Link] | None = None, start_time: int | None = None, record_exception: bool = True, set_status_on_exception: bool = True) -> Span: ...
5963
start_as_current_span = ...
6064

65+
class SuppressedTracer(Tracer):
66+
def start_span(self, name: str, context: Context | None = None, *args: Any, **kwargs: Any) -> Span: ...
67+
start_as_current_span: Incomplete
68+
6169
@dataclass
6270
class PendingSpanProcessor(SpanProcessor):
6371
"""Span processor that emits an extra pending span for each span as it starts.

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.4.1"
7+
version = "2.5.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.4.1"
7+
version = "2.5.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)