@@ -14,7 +14,7 @@ from .exporters.test import TestExporter as TestExporter
1414from .integrations .executors import instrument_executors as instrument_executors
1515from .main import FastLogfireSpan as FastLogfireSpan , LogfireSpan as LogfireSpan
1616from .metrics import ProxyMeterProvider as ProxyMeterProvider
17- from .scrubbing import BaseScrubber as BaseScrubber , NOOP_SCRUBBER as NOOP_SCRUBBER , ScrubCallback as ScrubCallback , Scrubber as Scrubber , ScrubbingOptions as ScrubbingOptions
17+ from .scrubbing import BaseScrubber as BaseScrubber , NOOP_SCRUBBER as NOOP_SCRUBBER , Scrubber as Scrubber , ScrubbingOptions as ScrubbingOptions
1818from .stack_info import warn_at_user_stacklevel as warn_at_user_stacklevel
1919from .tracer import PendingSpanProcessor as PendingSpanProcessor , ProxyTracerProvider as ProxyTracerProvider
2020from .utils import UnexpectedResponse as UnexpectedResponse , ensure_data_dir_exists as ensure_data_dir_exists , get_version as get_version , read_toml_file as read_toml_file , suppress_instrumentation as suppress_instrumentation
@@ -30,8 +30,8 @@ from opentelemetry.sdk.metrics.export import MetricReader as MetricReader
3030from opentelemetry .sdk .trace import SpanProcessor
3131from opentelemetry .sdk .trace .id_generator import IdGenerator
3232from pathlib import Path
33- from typing import Any , Callable , Literal , Sequence
34- from typing_extensions import Self
33+ from typing import Any , Callable , Literal , Sequence , TypedDict
34+ from typing_extensions import Self , Unpack
3535from weakref import WeakSet
3636
3737OPEN_SPANS : WeakSet [LogfireSpan | FastLogfireSpan ]
@@ -56,23 +56,19 @@ class PydanticPlugin:
5656 include : set [str ] = ...
5757 exclude : set [str ] = ...
5858
59- def configure (* , send_to_logfire : bool | Literal ['if-token-present' ] | None = None , token : str | None = None , project_name : str | None = None , service_name : str | None = None , service_version : str | None = None , trace_sample_rate : float | None = None , console : ConsoleOptions | Literal [False ] | None = None , show_summary : bool | None = None , config_dir : Path | str | None = None , data_dir : Path | str | None = None , base_url : str | None = None , collect_system_metrics : None = None , id_generator : IdGenerator | None = None , ns_timestamp_generator : Callable [[], int ] | None = None , processors : None = None , additional_span_processors : Sequence [SpanProcessor ] | None = None , metric_readers : None = None , additional_metric_readers : Sequence [MetricReader ] | None = None , pydantic_plugin : PydanticPlugin | None = None , fast_shutdown : bool = False , scrubbing_patterns : Sequence [str ] | None = None , scrubbing_callback : ScrubCallback | None = None , scrubbing : ScrubbingOptions | Literal [False ] | None = None , inspect_arguments : bool | None = None , sampling : SamplingOptions | None = None ) -> None :
59+ class DeprecatedKwargs (TypedDict ): ...
60+
61+ 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 , show_summary : bool | None = None , config_dir : Path | str | None = None , data_dir : Path | str | None = None , base_url : str | None = None , id_generator : IdGenerator | None = None , ns_timestamp_generator : Callable [[], int ] | None = None , additional_span_processors : Sequence [SpanProcessor ] | None = None , additional_metric_readers : Sequence [MetricReader ] | None = None , pydantic_plugin : PydanticPlugin | None = None , fast_shutdown : bool = False , scrubbing : ScrubbingOptions | Literal [False ] | None = None , inspect_arguments : bool | None = None , sampling : SamplingOptions | None = None , ** deprecated_kwargs : Unpack [DeprecatedKwargs ]) -> None :
6062 """Configure the logfire SDK.
6163
6264 Args:
6365 send_to_logfire: Whether to send logs to logfire.dev. Defaults to the `LOGFIRE_SEND_TO_LOGFIRE` environment
6466 variable if set, otherwise defaults to `True`. If `if-token-present` is provided, logs will only be sent if
6567 a token is present.
6668 token: The project token. Defaults to the `LOGFIRE_TOKEN` environment variable.
67- project_name: Name to request when creating a new project. Defaults to the `LOGFIRE_PROJECT_NAME` environment
68- variable, or the current directory name.
69- Project name accepts a string value containing alphanumeric characters and
70- hyphens (-). The hyphen character must not be located at the beginning or end of the string and should
71- appear in between alphanumeric characters.
7269 service_name: Name of this service. Defaults to the `LOGFIRE_SERVICE_NAME` environment variable.
7370 service_version: Version of this service. Defaults to the `LOGFIRE_SERVICE_VERSION` environment variable, or the
7471 current git commit hash if available.
75- trace_sample_rate: Deprecated, use `sampling` instead.
7672 console: Whether to control terminal output. If `None` uses the `LOGFIRE_CONSOLE_*` environment variables,
7773 otherwise defaults to `ConsoleOption(colors='auto', indent_spans=True, include_timestamps=True, verbose=False)`.
7874 If `False` disables console output. It can also be disabled by setting `LOGFIRE_CONSOLE` environment variable to `false`.
@@ -82,26 +78,21 @@ def configure(*, send_to_logfire: bool | Literal['if-token-present'] | None = No
8278 `LOGFIRE_CONFIG_DIR` environment variable, otherwise defaults to the current working directory.
8379 data_dir: Directory to store credentials, and logs. If `None` uses the `LOGFIRE_CREDENTIALS_DIR` environment variable, otherwise defaults to `'.logfire'`.
8480 base_url: Root URL for the Logfire API. If `None` uses the `LOGFIRE_BASE_URL` environment variable, otherwise defaults to https://logfire-api.pydantic.dev.
85- collect_system_metrics: Legacy argument, use [`logfire.instrument_system_metrics()`](https://docs.pydantic.dev/logfire/integrations/system_metrics/) instead.
8681 id_generator: Generator for span IDs. Defaults to `RandomIdGenerator()` from the OpenTelemetry SDK.
8782 ns_timestamp_generator: Generator for nanosecond timestamps. Defaults to [`time.time_ns`][time.time_ns] from the
8883 Python standard library.
89- processors: Legacy argument, use `additional_span_processors` instead.
9084 additional_span_processors: Span processors to use in addition to the default processor which exports spans to Logfire's API.
91- metric_readers: Legacy argument, use `additional_metric_readers` instead.
9285 additional_metric_readers: Sequence of metric readers to be used in addition to the default reader
9386 which exports metrics to Logfire's API.
9487 pydantic_plugin: Configuration for the Pydantic plugin. If `None` uses the `LOGFIRE_PYDANTIC_PLUGIN_*` environment
9588 variables, otherwise defaults to `PydanticPlugin(record='off')`.
9689 fast_shutdown: Whether to shut down exporters and providers quickly, mostly used for tests. Defaults to `False`.
9790 scrubbing: Options for scrubbing sensitive data. Set to `False` to disable.
98- scrubbing_patterns: Deprecated, use `scrubbing=logfire.ScrubbingOptions(extra_patterns=[...])` instead.
99- scrubbing_callback: Deprecated, use `scrubbing=logfire.ScrubbingOptions(callback=...)` instead.
10091 inspect_arguments: Whether to enable
10192 [f-string magic](https://docs.pydantic.dev/logfire/guides/onboarding_checklist/add_manual_tracing/#f-strings).
10293 If `None` uses the `LOGFIRE_INSPECT_ARGUMENTS` environment variable.
10394 Defaults to `True` if and only if the Python version is at least 3.11.
104- sampling: Sampling options. TODO document this .
95+ sampling: Sampling options. See the [sampling guide](https://docs.pydantic.dev/logfire/guides/advanced/sampling/) .
10596 """
10697
10798@dataclasses .dataclass
@@ -118,7 +109,6 @@ class _LogfireConfigData:
118109 base_url : str
119110 send_to_logfire : bool | Literal ['if-token-present' ]
120111 token : str | None
121- project_name : str | None
122112 service_name : str
123113 service_version : str | None
124114 console : ConsoleOptions | Literal [False ] | None
@@ -134,14 +124,14 @@ class _LogfireConfigData:
134124 sampling : SamplingOptions
135125
136126class LogfireConfig (_LogfireConfigData ):
137- def __init__ (self , base_url : str | None = None , send_to_logfire : bool | None = None , token : str | None = None , project_name : str | None = None , service_name : str | None = None , service_version : str | None = None , console : ConsoleOptions | Literal [False ] | None = None , show_summary : bool | None = None , config_dir : Path | None = None , data_dir : Path | None = None , id_generator : IdGenerator | None = None , ns_timestamp_generator : Callable [[], int ] | None = None , additional_span_processors : Sequence [SpanProcessor ] | None = None , additional_metric_readers : Sequence [MetricReader ] | None = None , pydantic_plugin : PydanticPlugin | None = None , fast_shutdown : bool = False , scrubbing : ScrubbingOptions | Literal [False ] | None = None , inspect_arguments : bool | None = None , sampling : SamplingOptions | None = None ) -> None :
127+ def __init__ (self , base_url : str | None = None , 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 , show_summary : bool | None = None , config_dir : Path | None = None , data_dir : Path | None = None , id_generator : IdGenerator | None = None , ns_timestamp_generator : Callable [[], int ] | None = None , additional_span_processors : Sequence [SpanProcessor ] | None = None , additional_metric_readers : Sequence [MetricReader ] | None = None , pydantic_plugin : PydanticPlugin | None = None , fast_shutdown : bool = False , scrubbing : ScrubbingOptions | Literal [False ] | None = None , inspect_arguments : bool | None = None , sampling : SamplingOptions | None = None ) -> None :
138128 """Create a new LogfireConfig.
139129
140130 Users should never need to call this directly, instead use `logfire.configure`.
141131
142132 See `_LogfireConfigData` for parameter documentation.
143133 """
144- def configure (self , base_url : str | None , send_to_logfire : bool | Literal ['if-token-present' ] | None , token : str | None , project_name : str | None , service_name : str | None , service_version : str | None , console : ConsoleOptions | Literal [False ] | None , show_summary : bool | None , config_dir : Path | None , data_dir : Path | None , id_generator : IdGenerator | None , ns_timestamp_generator : Callable [[], int ] | None , additional_span_processors : Sequence [SpanProcessor ] | None , additional_metric_readers : Sequence [MetricReader ] | None , pydantic_plugin : PydanticPlugin | None , fast_shutdown : bool , scrubbing : ScrubbingOptions | Literal [False ] | None , inspect_arguments : bool | None , sampling : SamplingOptions | None ) -> None : ...
134+ def configure (self , base_url : str | None , 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 , show_summary : bool | None , config_dir : Path | None , data_dir : Path | None , id_generator : IdGenerator | None , ns_timestamp_generator : Callable [[], int ] | None , additional_span_processors : Sequence [SpanProcessor ] | None , additional_metric_readers : Sequence [MetricReader ] | None , pydantic_plugin : PydanticPlugin | None , fast_shutdown : bool , scrubbing : ScrubbingOptions | Literal [False ] | None , inspect_arguments : bool | None , sampling : SamplingOptions | None ) -> None : ...
145135 def initialize (self ) -> ProxyTracerProvider :
146136 """Configure internals to start exporting traces and metrics."""
147137 def force_flush (self , timeout_millis : int = 30000 ) -> bool :
@@ -250,7 +240,7 @@ class LogfireCredentials:
250240 LogfireConfigError: If there was an error configuring the project.
251241 """
252242 @classmethod
253- def create_new_project (cls , * , session : requests .Session , logfire_api_url : str , organization : str | None = None , default_organization : bool = False , project_name : str | None = None , force_project_name_prompt : bool = False ) -> dict [str , Any ]:
243+ def create_new_project (cls , * , session : requests .Session , logfire_api_url : str , organization : str | None = None , default_organization : bool = False , project_name : str | None = None ) -> dict [str , Any ]:
254244 """Create a new project and configure it to be used by Logfire.
255245
256246 It creates the project under the organization if both project and organization are valid.
@@ -262,8 +252,6 @@ class LogfireCredentials:
262252 organization: The organization name of the new project.
263253 default_organization: Whether to create the project under the user default organization.
264254 project_name: The default name of the project.
265- force_project_name_prompt: Whether to force a prompt for the project name.
266- service_name: Name of the service.
267255
268256 Returns:
269257 The created project informations.
@@ -272,13 +260,11 @@ class LogfireCredentials:
272260 LogfireConfigError: If there was an error creating projects.
273261 """
274262 @classmethod
275- def initialize_project (cls , * , logfire_api_url : str , project_name : str | None , session : requests .Session ) -> Self :
263+ def initialize_project (cls , * , logfire_api_url : str , session : requests .Session ) -> Self :
276264 """Create a new project or use an existing project on logfire.dev requesting the given project name.
277265
278266 Args:
279267 logfire_api_url: The Logfire API base URL.
280- project_name: Name for the project.
281- user_token: The user's token to use to create the new project.
282268 session: HTTP client session used to communicate with the Logfire API.
283269
284270 Returns:
0 commit comments