@@ -25,7 +25,7 @@ from logfire.exceptions import LogfireConfigError as LogfireConfigError
2525from logfire .sampling import SamplingOptions as SamplingOptions
2626from logfire .sampling ._tail_sampling import TailSamplingProcessor as TailSamplingProcessor
2727from logfire .version import VERSION as VERSION
28- from opentelemetry import metrics
28+ from opentelemetry . metrics import Meter
2929from opentelemetry .sdk .metrics .export import MetricReader as MetricReader
3030from opentelemetry .sdk .trace import SpanProcessor
3131from opentelemetry .sdk .trace .id_generator import IdGenerator
@@ -64,9 +64,17 @@ class PydanticPlugin:
6464 include : set [str ] = ...
6565 exclude : set [str ] = ...
6666
67+ @dataclass
68+ class MetricsOptions :
69+ """Configuration of metrics.
70+
71+ This only has one option for now, but it's a place to add more related options in the future.
72+ """
73+ additional_readers : Sequence [MetricReader ] = ...
74+
6775class DeprecatedKwargs (TypedDict ): ...
6876
69- def configure (* , send_to_logfire : bool | Literal ['if-token-present' ] | None = None , token : str | None = None , service_name : str | None = None , service_version : 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 , additional_metric_readers : Sequence [ MetricReader ] | None = None , pydantic_plugin : PydanticPlugin | None = None , scrubbing : ScrubbingOptions | Literal [False ] | None = None , inspect_arguments : bool | None = None , sampling : SamplingOptions | None = None , advanced : AdvancedOptions | None = None , ** deprecated_kwargs : Unpack [DeprecatedKwargs ]) -> None :
77+ def configure (* , send_to_logfire : bool | Literal ['if-token-present' ] | None = None , token : str | None = None , service_name : str | None = None , service_version : 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 , pydantic_plugin : PydanticPlugin | None = None , scrubbing : ScrubbingOptions | Literal [False ] | None = None , inspect_arguments : bool | None = None , sampling : SamplingOptions | None = None , advanced : AdvancedOptions | None = None , ** deprecated_kwargs : Unpack [DeprecatedKwargs ]) -> None :
7078 """Configure the logfire SDK.
7179
7280 Args:
@@ -84,8 +92,8 @@ def configure(*, send_to_logfire: bool | Literal['if-token-present'] | None = No
8492 `LOGFIRE_CONFIG_DIR` environment variable, otherwise defaults to the current working directory.
8593 data_dir: Directory to store credentials, and logs. If `None` uses the `LOGFIRE_CREDENTIALS_DIR` environment variable, otherwise defaults to `'.logfire'`.
8694 additional_span_processors: Span processors to use in addition to the default processor which exports spans to Logfire's API.
87- additional_metric_readers: Sequence of metric readers to be used in addition to the default reader
88- which exports metrics to Logfire's API .
95+ metrics: Set to `False` to disable sending all metrics,
96+ or provide a `MetricsOptions` object to configure metrics, e.g. additional metric readers .
8997 pydantic_plugin: Configuration for the Pydantic plugin. If `None` uses the `LOGFIRE_PYDANTIC_PLUGIN_*` environment
9098 variables, otherwise defaults to `PydanticPlugin(record='off')`.
9199 scrubbing: Options for scrubbing sensitive data. Set to `False` to disable.
@@ -122,14 +130,14 @@ class _LogfireConfigData:
122130 advanced : AdvancedOptions
123131
124132class LogfireConfig (_LogfireConfigData ):
125- def __init__ (self , send_to_logfire : bool | None = None , token : str | None = None , service_name : str | None = None , service_version : 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 , additional_metric_readers : Sequence [ MetricReader ] | None = None , pydantic_plugin : PydanticPlugin | None = None , scrubbing : ScrubbingOptions | Literal [False ] | None = None , inspect_arguments : bool | None = None , sampling : SamplingOptions | None = None , advanced : AdvancedOptions | None = None ) -> None :
133+ def __init__ (self , send_to_logfire : bool | None = None , token : str | None = None , service_name : str | None = None , service_version : 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 , pydantic_plugin : PydanticPlugin | None = None , scrubbing : ScrubbingOptions | Literal [False ] | None = None , inspect_arguments : bool | None = None , sampling : SamplingOptions | None = None , advanced : AdvancedOptions | None = None ) -> None :
126134 """Create a new LogfireConfig.
127135
128136 Users should never need to call this directly, instead use `logfire.configure`.
129137
130138 See `_LogfireConfigData` for parameter documentation.
131139 """
132- def configure (self , send_to_logfire : bool | Literal ['if-token-present' ] | None , token : str | None , service_name : str | None , service_version : str | None , console : ConsoleOptions | Literal [False ] | None , config_dir : Path | None , data_dir : Path | None , additional_span_processors : Sequence [SpanProcessor ] | None , additional_metric_readers : Sequence [ MetricReader ] | None , pydantic_plugin : PydanticPlugin | None , scrubbing : ScrubbingOptions | Literal [False ] | None , inspect_arguments : bool | None , sampling : SamplingOptions | None , advanced : AdvancedOptions | None ) -> None : ...
140+ def configure (self , send_to_logfire : bool | Literal ['if-token-present' ] | None , token : str | None , service_name : str | None , service_version : 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 , pydantic_plugin : PydanticPlugin | None , scrubbing : ScrubbingOptions | Literal [False ] | None , inspect_arguments : bool | None , sampling : SamplingOptions | None , advanced : AdvancedOptions | None ) -> None : ...
133141 def initialize (self ) -> ProxyTracerProvider :
134142 """Configure internals to start exporting traces and metrics."""
135143 def force_flush (self , timeout_millis : int = 30000 ) -> bool :
@@ -159,7 +167,7 @@ class LogfireConfig(_LogfireConfigData):
159167 """
160168 def warn_if_not_initialized (self , message : str ): ...
161169 @cached_property
162- def meter (self ) -> metrics . Meter :
170+ def meter (self ) -> Meter :
163171 """Get a meter from this `LogfireConfig`.
164172
165173 This is used internally and should not be called by users of the SDK.
0 commit comments