Skip to content

Commit 9b04e2c

Browse files
authored
Release v4.1.0 (#1291)
1 parent 97077f1 commit 9b04e2c

File tree

8 files changed

+28
-10
lines changed

8 files changed

+28
-10
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+
## [v4.1.0] (2025-08-04)
4+
5+
* Add `min_level` argument to `logfire.configure` by @alexmojaki in [#1265](https://github.com/pydantic/logfire/pull/1265)
6+
37
## [v4.0.1] (2025-07-31)
48

59
* Handle cyclic references in exceptions by @alexmojaki in [#1284](https://github.com/pydantic/logfire/pull/1284)
@@ -815,3 +819,4 @@ First release from new repo!
815819
[v3.25.0]: https://github.com/pydantic/logfire/compare/v3.24.2...v3.25.0
816820
[v4.0.0]: https://github.com/pydantic/logfire/compare/v3.25.0...v4.0.0
817821
[v4.0.1]: https://github.com/pydantic/logfire/compare/v4.0.0...v4.0.1
822+
[v4.1.0]: https://github.com/pydantic/logfire/compare/v4.0.1...v4.1.0

logfire-api/logfire_api/_internal/config.pyi

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import requests
33
from ..propagate import NoExtractTraceContextPropagator as NoExtractTraceContextPropagator, WarnOnExtractTraceContextPropagator as WarnOnExtractTraceContextPropagator
44
from .client import InvalidProjectName as InvalidProjectName, LogfireClient as LogfireClient, ProjectAlreadyExists as ProjectAlreadyExists
55
from .config_params import ParamManager as ParamManager, PydanticPluginRecordValues as PydanticPluginRecordValues
6-
from .constants import LevelName as LevelName, RESOURCE_ATTRIBUTES_CODE_ROOT_PATH as RESOURCE_ATTRIBUTES_CODE_ROOT_PATH, RESOURCE_ATTRIBUTES_CODE_WORK_DIR as RESOURCE_ATTRIBUTES_CODE_WORK_DIR, RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME as RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL
6+
from .constants import LEVEL_NUMBERS as LEVEL_NUMBERS, LevelName as LevelName, RESOURCE_ATTRIBUTES_CODE_ROOT_PATH as RESOURCE_ATTRIBUTES_CODE_ROOT_PATH, RESOURCE_ATTRIBUTES_CODE_WORK_DIR as RESOURCE_ATTRIBUTES_CODE_WORK_DIR, RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME as RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL
77
from .exporters.console import ConsoleColorsValues as ConsoleColorsValues, ConsoleLogExporter as ConsoleLogExporter, IndentedConsoleSpanExporter as IndentedConsoleSpanExporter, ShowParentsConsoleSpanExporter as ShowParentsConsoleSpanExporter, SimpleConsoleSpanExporter as SimpleConsoleSpanExporter
88
from .exporters.dynamic_batch import DynamicBatchSpanProcessor as DynamicBatchSpanProcessor
99
from .exporters.logs import CheckSuppressInstrumentationLogProcessorWrapper as CheckSuppressInstrumentationLogProcessorWrapper, MainLogProcessorWrapper as MainLogProcessorWrapper
@@ -88,7 +88,7 @@ class CodeSource:
8888

8989
class DeprecatedKwargs(TypedDict): ...
9090

91-
def configure(*, local: bool = False, send_to_logfire: bool | Literal['if-token-present'] | None = None, token: str | None = None, service_name: str | None = None, service_version: str | None = None, environment: str | None = None, console: ConsoleOptions | Literal[False] | None = None, config_dir: Path | str | None = None, data_dir: Path | str | None = None, additional_span_processors: Sequence[SpanProcessor] | None = None, metrics: MetricsOptions | Literal[False] | None = None, scrubbing: ScrubbingOptions | Literal[False] | None = None, inspect_arguments: bool | None = None, sampling: SamplingOptions | None = None, add_baggage_to_attributes: bool = True, code_source: CodeSource | None = None, distributed_tracing: bool | None = None, advanced: AdvancedOptions | None = None, **deprecated_kwargs: Unpack[DeprecatedKwargs]) -> Logfire:
91+
def configure(*, local: bool = False, send_to_logfire: bool | Literal['if-token-present'] | None = None, token: str | None = None, service_name: str | None = None, service_version: str | None = None, environment: str | None = None, console: ConsoleOptions | Literal[False] | None = None, config_dir: Path | str | None = None, data_dir: Path | str | None = None, additional_span_processors: Sequence[SpanProcessor] | None = None, metrics: MetricsOptions | Literal[False] | None = None, scrubbing: ScrubbingOptions | Literal[False] | None = None, inspect_arguments: bool | None = None, sampling: SamplingOptions | None = None, min_level: int | LevelName | None = None, add_baggage_to_attributes: bool = True, code_source: CodeSource | None = None, distributed_tracing: bool | None = None, advanced: AdvancedOptions | None = None, **deprecated_kwargs: Unpack[DeprecatedKwargs]) -> Logfire:
9292
"""Configure the logfire SDK.
9393
9494
Args:
@@ -135,6 +135,14 @@ def configure(*, local: bool = False, send_to_logfire: bool | Literal['if-token-
135135
136136
Defaults to `True` if and only if the Python version is at least 3.11.
137137
138+
min_level:
139+
Minimum log level for logs and spans to be created. By default, all logs and spans are created.
140+
For example, set to 'info' to only create logs with level 'info' or higher, thus filtering out debug logs.
141+
For spans, this only applies when `_level` is explicitly specified in `logfire.span`.
142+
Changing the level of a span _after_ it is created will be ignored by this.
143+
If a span is not created, this has no effect on the current active span, or on logs/spans created inside the
144+
filtered `logfire.span` context manager.
145+
If set to `None`, uses the `LOGFIRE_MIN_LEVEL` environment variable; if that is not set, there is no minimum level.
138146
sampling: Sampling options. See the [sampling guide](https://logfire.pydantic.dev/docs/guides/advanced/sampling/).
139147
add_baggage_to_attributes: Set to `False` to prevent OpenTelemetry Baggage from being added to spans as attributes.
140148
See the [Baggage documentation](https://logfire.pydantic.dev/docs/reference/advanced/baggage/) for more details.
@@ -170,20 +178,21 @@ class _LogfireConfigData:
170178
scrubbing: ScrubbingOptions | Literal[False]
171179
inspect_arguments: bool
172180
sampling: SamplingOptions
181+
min_level: int
173182
add_baggage_to_attributes: bool
174183
code_source: CodeSource | None
175184
distributed_tracing: bool | None
176185
advanced: AdvancedOptions
177186

178187
class LogfireConfig(_LogfireConfigData):
179-
def __init__(self, send_to_logfire: bool | Literal['if-token-present'] | None = None, token: str | None = None, service_name: str | None = None, service_version: str | None = None, environment: str | None = None, console: ConsoleOptions | Literal[False] | None = None, config_dir: Path | None = None, data_dir: Path | None = None, additional_span_processors: Sequence[SpanProcessor] | None = None, metrics: MetricsOptions | Literal[False] | None = None, scrubbing: ScrubbingOptions | Literal[False] | None = None, inspect_arguments: bool | None = None, sampling: SamplingOptions | None = None, add_baggage_to_attributes: bool = True, code_source: CodeSource | None = None, distributed_tracing: bool | None = None, advanced: AdvancedOptions | None = None) -> None:
188+
def __init__(self, send_to_logfire: bool | Literal['if-token-present'] | None = None, token: str | None = None, service_name: str | None = None, service_version: str | None = None, environment: str | None = None, console: ConsoleOptions | Literal[False] | None = None, config_dir: Path | None = None, data_dir: Path | None = None, additional_span_processors: Sequence[SpanProcessor] | None = None, metrics: MetricsOptions | Literal[False] | None = None, scrubbing: ScrubbingOptions | Literal[False] | None = None, inspect_arguments: bool | None = None, sampling: SamplingOptions | None = None, min_level: int | LevelName | None = None, add_baggage_to_attributes: bool = True, code_source: CodeSource | None = None, distributed_tracing: bool | None = None, advanced: AdvancedOptions | None = None) -> None:
180189
"""Create a new LogfireConfig.
181190
182191
Users should never need to call this directly, instead use `logfire.configure`.
183192
184193
See `_LogfireConfigData` for parameter documentation.
185194
"""
186-
def configure(self, send_to_logfire: bool | Literal['if-token-present'] | None, token: str | None, service_name: str | None, service_version: str | None, environment: str | None, console: ConsoleOptions | Literal[False] | None, config_dir: Path | None, data_dir: Path | None, additional_span_processors: Sequence[SpanProcessor] | None, metrics: MetricsOptions | Literal[False] | None, scrubbing: ScrubbingOptions | Literal[False] | None, inspect_arguments: bool | None, sampling: SamplingOptions | None, add_baggage_to_attributes: bool, code_source: CodeSource | None, distributed_tracing: bool | None, advanced: AdvancedOptions | None) -> None: ...
195+
def configure(self, send_to_logfire: bool | Literal['if-token-present'] | None, token: str | None, service_name: str | None, service_version: str | None, environment: str | None, console: ConsoleOptions | Literal[False] | None, config_dir: Path | None, data_dir: Path | None, additional_span_processors: Sequence[SpanProcessor] | None, metrics: MetricsOptions | Literal[False] | None, scrubbing: ScrubbingOptions | Literal[False] | None, inspect_arguments: bool | None, sampling: SamplingOptions | None, min_level: int | LevelName | None, add_baggage_to_attributes: bool, code_source: CodeSource | None, distributed_tracing: bool | None, advanced: AdvancedOptions | None) -> None: ...
187196
def initialize(self) -> None:
188197
"""Configure internals to start exporting traces and metrics."""
189198
def force_flush(self, timeout_millis: int = 30000) -> bool:

logfire-api/logfire_api/_internal/config_params.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class _DefaultCallback:
3030
callback: Callable[[], Any]
3131

3232
SEND_TO_LOGFIRE: Incomplete
33+
MIN_LEVEL: Incomplete
3334
TOKEN: Incomplete
3435
SERVICE_NAME: Incomplete
3536
SERVICE_VERSION: Incomplete

logfire-api/logfire_api/_internal/constants.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from _typeshed import Incomplete
2-
from opentelemetry.util import types as otel_types
32

43
LOGFIRE_ATTRIBUTES_NAMESPACE: str
54
LevelName: Incomplete
@@ -9,7 +8,7 @@ LOGGING_TO_OTEL_LEVEL_NUMBERS: dict[int, int]
98
ATTRIBUTES_LOG_LEVEL_NAME_KEY: Incomplete
109
ATTRIBUTES_LOG_LEVEL_NUM_KEY: Incomplete
1110

12-
def log_level_attributes(level: LevelName | int) -> dict[str, otel_types.AttributeValue]: ...
11+
def log_level_attributes(level: LevelName | int) -> dict[str, int]: ...
1312

1413
SpanTypeType: Incomplete
1514
ATTRIBUTES_SPAN_TYPE_KEY: Incomplete

logfire-api/logfire_api/_internal/logs.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import dataclasses
22
from dataclasses import dataclass
3+
from logfire._internal.constants import LEVEL_NUMBERS as LEVEL_NUMBERS
34
from opentelemetry._logs import LogRecord, Logger, LoggerProvider
45
from opentelemetry.util.types import _ExtendedAttributes
56
from threading import Lock
@@ -13,14 +14,17 @@ class ProxyLoggerProvider(LoggerProvider):
1314
loggers: WeakSet[ProxyLogger] = dataclasses.field(default_factory=WeakSet)
1415
lock: Lock = dataclasses.field(default_factory=Lock)
1516
suppressed_scopes: set[str] = dataclasses.field(default_factory=set)
17+
min_level: int = ...
1618
def get_logger(self, name: str, version: str | None = None, schema_url: str | None = None, attributes: _ExtendedAttributes | None = None) -> Logger: ...
19+
def set_min_level(self, min_level: int) -> None: ...
1720
def suppress_scopes(self, *scopes: str) -> None: ...
1821
def set_provider(self, logger_provider: LoggerProvider) -> None: ...
1922
def __getattr__(self, item: str) -> Any: ...
2023

2124
@dataclass(eq=False)
2225
class ProxyLogger(Logger):
2326
logger: Logger
27+
min_level: int
2428
name: str
2529
version: str | None = ...
2630
schema_url: str | None = ...

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 = "4.0.1"
7+
version = "4.1.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 = "4.0.1"
7+
version = "4.1.0"
88
description = "The best Python observability tool! 🪵🔥"
99
requires-python = ">=3.9"
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)