@@ -34,7 +34,7 @@ from fastapi import FastAPI
34
34
from flask .app import Flask
35
35
from opentelemetry .metrics import CallbackT as CallbackT , Counter , Histogram , UpDownCounter , _Gauge as Gauge
36
36
from opentelemetry .sdk .trace import ReadableSpan , Span
37
- from opentelemetry .trace import Tracer
37
+ from opentelemetry .trace import SpanContext , Tracer
38
38
from opentelemetry .util import types as otel_types
39
39
from starlette .applications import Starlette
40
40
from starlette .requests import Request as Request
@@ -202,7 +202,7 @@ class Logfire:
202
202
_exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
203
203
to record a traceback with the log message.
204
204
"""
205
- def span (self , msg_template : str , / , * , _tags : Sequence [str ] | None = None , _span_name : str | None = None , _level : LevelName | None = None , ** attributes : Any ) -> LogfireSpan :
205
+ def span (self , msg_template : str , / , * , _tags : Sequence [str ] | None = None , _span_name : str | None = None , _level : LevelName | None = None , _links : Sequence [ tuple [ SpanContext , otel_types . Attributes ]] = (), ** attributes : Any ) -> LogfireSpan :
206
206
"""Context manager for creating a span.
207
207
208
208
```py
@@ -219,10 +219,11 @@ class Logfire:
219
219
_span_name: The span name. If not provided, the `msg_template` will be used.
220
220
_tags: An optional sequence of tags to include in the span.
221
221
_level: An optional log level name.
222
+ _links: An optional sequence of links to other spans. Each link is a tuple of a span context and attributes.
222
223
attributes: The arguments to include in the span and format the message template with.
223
224
Attributes starting with an underscore are not allowed.
224
225
"""
225
- def instrument (self , msg_template : LiteralString | None = None , * , span_name : str | None = None , extract_args : bool = True , allow_generator : bool = False ) -> Callable [[Callable [P , R ]], Callable [P , R ]]:
226
+ def instrument (self , msg_template : LiteralString | None = None , * , span_name : str | None = None , extract_args : bool | Iterable [ str ] = True , allow_generator : bool = False ) -> Callable [[Callable [P , R ]], Callable [P , R ]]:
226
227
"""Decorator for instrumenting a function as a span.
227
228
228
229
```py
@@ -239,7 +240,8 @@ class Logfire:
239
240
Args:
240
241
msg_template: The template for the span message. If not provided, the module and function name will be used.
241
242
span_name: The span name. If not provided, the `msg_template` will be used.
242
- extract_args: Whether to extract arguments from the function signature and log them as span attributes.
243
+ extract_args: By default, all function call arguments are logged as span attributes.
244
+ Set to `False` to disable this, or pass an iterable of argument names to include.
243
245
allow_generator: Set to `True` to prevent a warning when instrumenting a generator function.
244
246
Read https://logfire.pydantic.dev/docs/guides/advanced/generators/#using-logfireinstrument first.
245
247
"""
@@ -973,7 +975,7 @@ class FastLogfireSpan:
973
975
974
976
class LogfireSpan (ReadableSpan ):
975
977
end_on_exit : bool
976
- def __init__ (self , span_name : str , otlp_attributes : dict [str , otel_types .AttributeValue ], tracer : Tracer , json_schema_properties : JsonSchemaProperties ) -> None : ...
978
+ 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 : ...
977
979
def __getattr__ (self , name : str ) -> Any : ...
978
980
def __enter__ (self ) -> LogfireSpan : ...
979
981
def __exit__ (self , exc_type : type [BaseException ] | None , exc_value : BaseException | None , traceback : Any ) -> None : ...
@@ -1006,6 +1008,7 @@ class LogfireSpan(ReadableSpan):
1006
1008
"""
1007
1009
def set_attributes (self , attributes : dict [str , Any ]) -> None :
1008
1010
"""Sets the given attributes on the span."""
1011
+ def add_link (self , context : SpanContext , attributes : otel_types .Attributes = None ) -> None : ...
1009
1012
def record_exception (self , exception : BaseException , attributes : otel_types .Attributes = None , timestamp : int | None = None , escaped : bool = False ) -> None :
1010
1013
"""Records an exception as a span event.
1011
1014
0 commit comments