Skip to content

Commit 4157e1b

Browse files
authored
Release v3.16.2 (#1114)
1 parent 7e4648b commit 4157e1b

File tree

15 files changed

+41
-8
lines changed

15 files changed

+41
-8
lines changed

CHANGELOG.md

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

3+
## [v3.16.2] (2025-06-03)
4+
5+
* Fixes for OpenAI Responses API and Agents SDK by @alexmojaki in [#1092](https://github.com/pydantic/logfire/pull/1092), [#1093](https://github.com/pydantic/logfire/pull/1093), [#1094](https://github.com/pydantic/logfire/pull/1094), and [#1095](https://github.com/pydantic/logfire/pull/1095)
6+
* Fix verbose console formatting for enum, dates, and decimals by @sbhrwlr in [#1096](https://github.com/pydantic/logfire/pull/1096)
7+
* Allow setting `logfire.msg` in structlog integration by @alexmojaki in [#1113](https://github.com/pydantic/logfire/pull/1113)
8+
* Add ASGI instrumentation package to `django` extra by @alexmojaki in [#1097](https://github.com/pydantic/logfire/pull/1097)
9+
310
## [v3.16.1] (2025-05-26)
411

512
* Infer base URL from read token in query client by @Viicos in [#1088](https://github.com/pydantic/logfire/pull/1088)
@@ -706,3 +713,4 @@ First release from new repo!
706713
[v3.15.1]: https://github.com/pydantic/logfire/compare/v3.15.0...v3.15.1
707714
[v3.16.0]: https://github.com/pydantic/logfire/compare/v3.15.1...v3.16.0
708715
[v3.16.1]: https://github.com/pydantic/logfire/compare/v3.16.0...v3.16.1
716+
[v3.16.2]: https://github.com/pydantic/logfire/compare/v3.16.1...v3.16.2

logfire-api/logfire_api/_internal/collect_system_info.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from functools import lru_cache
2+
3+
@lru_cache
14
def collect_package_info() -> dict[str, str]:
25
"""Retrieve the package information for all installed packages.
36

logfire-api/logfire_api/_internal/formatter.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ from .scrubbing import BaseScrubber as BaseScrubber, NOOP_SCRUBBER as NOOP_SCRUB
66
from .stack_info import warn_at_user_stacklevel as warn_at_user_stacklevel
77
from .utils import log_internal_error as log_internal_error, truncate_string as truncate_string
88
from _typeshed import Incomplete
9+
from functools import lru_cache
910
from string import Formatter
1011
from types import CodeType as CodeType
1112
from typing import Any, Literal
@@ -27,6 +28,7 @@ chunks_formatter: Incomplete
2728

2829
def logfire_format(format_string: str, kwargs: dict[str, Any], scrubber: BaseScrubber) -> str: ...
2930
def logfire_format_with_magic(format_string: str, kwargs: dict[str, Any], scrubber: BaseScrubber, fstring_frame: types.FrameType | None = None) -> tuple[str, dict[str, Any], str]: ...
31+
@lru_cache
3032
def compile_formatted_value(node: ast.FormattedValue, ex_source: executing.Source) -> tuple[str, CodeType, CodeType]:
3133
"""Returns three things that can be expensive to compute.
3234

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from ..utils import handle_internal_errors as handle_internal_errors, maybe_capt
44
from .asgi import tweak_asgi_spans_tracer_provider as tweak_asgi_spans_tracer_provider
55
from _typeshed import Incomplete
66
from fastapi import FastAPI
7+
from functools import lru_cache
78
from starlette.requests import Request
89
from starlette.websockets import WebSocket
910
from typing import Any, Awaitable, Callable, ContextManager, Iterable
@@ -15,6 +16,7 @@ def instrument_fastapi(logfire_instance: Logfire, app: FastAPI, *, capture_heade
1516
1617
See `Logfire.instrument_fastapi` for more details.
1718
"""
19+
@lru_cache
1820
def patch_fastapi():
1921
"""Globally monkeypatch fastapi functions and return a dictionary for recording instrumentation config per app."""
2022

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import contextlib
12
import httpx
23
from _typeshed import Incomplete
34
from collections.abc import Generator
45
from email.headerregistry import ContentTypeHeader
5-
from functools import cached_property
6+
from functools import cached_property, lru_cache
67
from logfire import Logfire as Logfire, LogfireSpan as LogfireSpan
78
from logfire._internal.main import set_user_attributes_on_raw_span as set_user_attributes_on_raw_span
89
from logfire._internal.stack_info import warn_at_user_stacklevel as warn_at_user_stacklevel
@@ -54,6 +55,7 @@ class LogfireHttpxResponseInfo(ResponseInfo, LogfireHttpxInfoMixin):
5455
def on_response_read(self, hook: Callable[[LogfireSpan], None]): ...
5556
def wrap_response_read(self, hook: Callable[[Callable[[], bytes]], bytes]): ...
5657
def wrap_response_aread(self, hook: Callable[[Callable[[], Awaitable[bytes]]], Awaitable[bytes]]): ...
58+
@contextlib.contextmanager
5759
def attach_original_span_context(self) -> Generator[None]: ...
5860
def capture_text_as_json(self, span: LogfireSpan, *, text: str, attr_name: str): ...
5961

@@ -69,6 +71,8 @@ def capture_request_or_response_headers(span: Span, headers: httpx.Headers, requ
6971

7072
CODES_FOR_METHODS_WITH_DATA_PARAM: Incomplete
7173

74+
@lru_cache
7275
def content_type_header_from_string(content_type: str) -> ContentTypeHeader: ...
7376
def content_type_subtypes(subtype: str) -> set[str]: ...
77+
@lru_cache
7478
def is_json_type(content_type: str) -> bool: ...

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from agents.tracing.spans import SpanError, TSpanData
88
from dataclasses import dataclass
99
from logfire import Logfire as Logfire, LogfireSpan as LogfireSpan
1010
from logfire._internal.formatter import logfire_format as logfire_format
11+
from logfire._internal.integrations.llm_providers.openai import inputs_to_events as inputs_to_events, responses_output_events as responses_output_events
1112
from logfire._internal.scrubbing import NOOP_SCRUBBER as NOOP_SCRUBBER
1213
from logfire._internal.utils import handle_internal_errors as handle_internal_errors, log_internal_error as log_internal_error, truncate_string as truncate_string
1314
from openai.types.responses import Response
@@ -55,6 +56,7 @@ class LogfireWrapperBase(Generic[T]):
5556

5657
@dataclass
5758
class LogfireTraceWrapper(LogfireWrapperBase[Trace], Trace):
59+
@handle_internal_errors
5860
def on_ending(self) -> None: ...
5961
token = ...
6062
def attach(self) -> None: ...
@@ -70,6 +72,7 @@ class LogfireSpanWrapper(LogfireWrapperBase[Span[TSpanData]], Span[TSpanData]):
7072
token = ...
7173
def attach(self) -> None: ...
7274
def detach(self) -> None: ...
75+
@handle_internal_errors
7376
def on_ending(self) -> None: ...
7477
@property
7578
def trace_id(self) -> str: ...
@@ -92,5 +95,3 @@ def attributes_from_span_data(span_data: SpanData, msg_template: str) -> dict[st
9295
def get_basic_response_attributes(response: Response): ...
9396
def get_magic_response_attributes() -> dict[str, Any]: ...
9497
def get_response_span_events(span: ResponseSpanData): ...
95-
def input_to_events(inp: dict[str, Any]): ...
96-
def unknown_event(inp: dict[str, Any]): ...

logfire-api/logfire_api/_internal/json_encoder.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .utils import JsonValue as JsonValue, safe_repr as safe_repr
22
from _typeshed import Incomplete
3+
from functools import lru_cache
34
from typing import Any
45

56
NUMPY_DIMENSION_MAX_SIZE: int
@@ -9,4 +10,5 @@ def encoder_by_type() -> dict[type[Any], EncoderFunction]: ...
910
def to_json_value(o: Any, seen: set[int]) -> JsonValue: ...
1011
def logfire_json_dumps(obj: Any) -> str: ...
1112
def is_sqlalchemy(obj: Any) -> bool: ...
13+
@lru_cache
1214
def is_attrs(cls) -> bool: ...

logfire-api/logfire_api/_internal/json_schema.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .utils import JsonDict
22
from _typeshed import Incomplete
3+
from functools import lru_cache
34
from typing import Any
45

56
__all__ = ['create_json_schema', 'attributes_json_schema_properties', 'attributes_json_schema', 'JsonSchemaProperties']

logfire-api/logfire_api/_internal/main.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,24 +1062,28 @@ class FastLogfireSpan:
10621062
"""A simple version of `LogfireSpan` optimized for auto-tracing."""
10631063
def __init__(self, span: trace_api.Span) -> None: ...
10641064
def __enter__(self) -> FastLogfireSpan: ...
1065+
@handle_internal_errors
10651066
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: Any) -> None: ...
10661067

10671068
class LogfireSpan(ReadableSpan):
10681069
def __init__(self, span_name: str, otlp_attributes: dict[str, otel_types.AttributeValue], tracer: Tracer, json_schema_properties: JsonSchemaProperties, links: Sequence[tuple[SpanContext, otel_types.Attributes]]) -> None: ...
10691070
def __getattr__(self, name: str) -> Any: ...
10701071
def __enter__(self) -> LogfireSpan: ...
1072+
@handle_internal_errors
10711073
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: Any) -> None: ...
10721074
@property
10731075
def message_template(self) -> str | None: ...
10741076
@property
10751077
def tags(self) -> tuple[str, ...]: ...
10761078
@tags.setter
1079+
@handle_internal_errors
10771080
def tags(self, new_tags: Sequence[str]) -> None:
10781081
"""Set or add tags to the span."""
10791082
@property
10801083
def message(self) -> str: ...
10811084
@message.setter
10821085
def message(self, message: str): ...
1086+
@handle_internal_errors
10831087
def set_attribute(self, key: str, value: Any) -> None:
10841088
"""Sets an attribute on the span.
10851089
@@ -1096,6 +1100,7 @@ class LogfireSpan(ReadableSpan):
10961100
Delegates to the OpenTelemetry SDK `Span.record_exception` method.
10971101
"""
10981102
def is_recording(self) -> bool: ...
1103+
@handle_internal_errors
10991104
def set_level(self, level: LevelName | int):
11001105
"""Set the log level of this span."""
11011106

logfire-api/logfire_api/_internal/tracer.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def should_sample(span_context: SpanContext, attributes: Mapping[str, otel_types
9696
This is used to sample spans that are not sampled by the OTEL sampler.
9797
"""
9898
def get_sample_rate_from_attributes(attributes: otel_types.Attributes) -> float | None: ...
99+
@handle_internal_errors
99100
def record_exception(span: trace_api.Span, exception: BaseException, *, attributes: otel_types.Attributes = None, timestamp: int | None = None, escaped: bool = False) -> None:
100101
"""Similar to the OTEL SDK Span.record_exception method, with our own additions."""
101102
def set_exception_status(span: trace_api.Span, exception: BaseException): ...

logfire-api/logfire_api/_internal/utils.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from _typeshed import Incomplete
22
from collections.abc import Generator
3+
from contextlib import contextmanager
34
from dataclasses import dataclass
45
from logfire._internal.stack_info import is_user_code as is_user_code
56
from logfire._internal.ulid import ulid as ulid
@@ -86,6 +87,7 @@ def is_instrumentation_suppressed() -> bool:
8687
8788
This means that any logs/spans generated by logfire or OpenTelemetry will not be logged in any way.
8889
"""
90+
@contextmanager
8991
def suppress_instrumentation() -> Generator[None]:
9092
"""Context manager to suppress all logs/spans generated by logfire or OpenTelemetry."""
9193
def log_internal_error() -> None: ...

logfire-api/logfire_api/propagate.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from contextlib import contextmanager
12
from dataclasses import dataclass
23
from opentelemetry import context as otel_context
34
from opentelemetry.propagators.textmap import TextMapPropagator
@@ -37,6 +38,7 @@ def get_context() -> ContextCarrier:
3738
...
3839
```
3940
"""
41+
@contextmanager
4042
def attach_context(carrier: ContextCarrier, *, third_party: bool = False, propagator: TextMapPropagator | None = None) -> Iterator[None]:
4143
"""Attach a context as generated by [`get_context`][logfire.propagate.get_context] to the current execution context.
4244

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 = "3.16.1"
7+
version = "3.16.2"
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 = "3.16.1"
7+
version = "3.16.2"
88
description = "The best Python observability tool! 🪵🔥"
99
requires-python = ">=3.8"
1010
authors = [

uv.lock

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

0 commit comments

Comments
 (0)