@@ -34,7 +34,7 @@ from fastapi import FastAPI
3434from flask .app import Flask
3535from opentelemetry .metrics import CallbackT as CallbackT , Counter , Histogram , UpDownCounter , _Gauge as Gauge
3636from opentelemetry .sdk .trace import ReadableSpan , Span
37- from opentelemetry .trace import Tracer
37+ from opentelemetry .trace import SpanContext , Tracer
3838from opentelemetry .util import types as otel_types
3939from starlette .applications import Starlette
4040from starlette .requests import Request as Request
@@ -202,7 +202,7 @@ class Logfire:
202202 _exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
203203 to record a traceback with the log message.
204204 """
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 :
206206 """Context manager for creating a span.
207207
208208 ```py
@@ -219,10 +219,11 @@ class Logfire:
219219 _span_name: The span name. If not provided, the `msg_template` will be used.
220220 _tags: An optional sequence of tags to include in the span.
221221 _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.
222223 attributes: The arguments to include in the span and format the message template with.
223224 Attributes starting with an underscore are not allowed.
224225 """
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 ]]:
226227 """Decorator for instrumenting a function as a span.
227228
228229 ```py
@@ -239,7 +240,8 @@ class Logfire:
239240 Args:
240241 msg_template: The template for the span message. If not provided, the module and function name will be used.
241242 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.
243245 allow_generator: Set to `True` to prevent a warning when instrumenting a generator function.
244246 Read https://logfire.pydantic.dev/docs/guides/advanced/generators/#using-logfireinstrument first.
245247 """
@@ -973,7 +975,7 @@ class FastLogfireSpan:
973975
974976class LogfireSpan (ReadableSpan ):
975977 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 : ...
977979 def __getattr__ (self , name : str ) -> Any : ...
978980 def __enter__ (self ) -> LogfireSpan : ...
979981 def __exit__ (self , exc_type : type [BaseException ] | None , exc_value : BaseException | None , traceback : Any ) -> None : ...
@@ -1006,6 +1008,7 @@ class LogfireSpan(ReadableSpan):
10061008 """
10071009 def set_attributes (self , attributes : dict [str , Any ]) -> None :
10081010 """Sets the given attributes on the span."""
1011+ def add_link (self , context : SpanContext , attributes : otel_types .Attributes = None ) -> None : ...
10091012 def record_exception (self , exception : BaseException , attributes : otel_types .Attributes = None , timestamp : int | None = None , escaped : bool = False ) -> None :
10101013 """Records an exception as a span event.
10111014
0 commit comments