Skip to content

Commit 05517d6

Browse files
authored
Remove show_summary and fast_shutdown from logfire.configure() (#431)
1 parent 00dbdd6 commit 05517d6

File tree

3 files changed

+20
-33
lines changed

3 files changed

+20
-33
lines changed

logfire/_internal/config.py

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ class ConsoleOptions:
124124
min_log_level: LevelName = 'info'
125125
"""The minimum log level to show in the console."""
126126

127+
show_project_link: bool = True
128+
"""Whether to print the URL of the Logfire project after initialization."""
129+
127130

128131
@dataclass
129132
class PydanticPlugin:
@@ -157,7 +160,6 @@ def configure( # noqa: D417
157160
service_name: str | None = None,
158161
service_version: str | None = None,
159162
console: ConsoleOptions | Literal[False] | None = None,
160-
show_summary: bool | None = None,
161163
config_dir: Path | str | None = None,
162164
data_dir: Path | str | None = None,
163165
base_url: str | None = None,
@@ -166,7 +168,6 @@ def configure( # noqa: D417
166168
additional_span_processors: Sequence[SpanProcessor] | None = None,
167169
additional_metric_readers: Sequence[MetricReader] | None = None,
168170
pydantic_plugin: PydanticPlugin | None = None,
169-
fast_shutdown: bool = False,
170171
scrubbing: ScrubbingOptions | Literal[False] | None = None,
171172
inspect_arguments: bool | None = None,
172173
sampling: SamplingOptions | None = None,
@@ -185,8 +186,6 @@ def configure( # noqa: D417
185186
console: Whether to control terminal output. If `None` uses the `LOGFIRE_CONSOLE_*` environment variables,
186187
otherwise defaults to `ConsoleOption(colors='auto', indent_spans=True, include_timestamps=True, verbose=False)`.
187188
If `False` disables console output. It can also be disabled by setting `LOGFIRE_CONSOLE` environment variable to `false`.
188-
show_summary: When to print a summary of the Logfire setup including a link to the dashboard. If `None` uses the `LOGFIRE_SHOW_SUMMARY` environment variable, otherwise
189-
defaults to `True`.
190189
config_dir: Directory that contains the `pyproject.toml` file for this project. If `None` uses the
191190
`LOGFIRE_CONFIG_DIR` environment variable, otherwise defaults to the current working directory.
192191
data_dir: Directory to store credentials, and logs. If `None` uses the `LOGFIRE_CREDENTIALS_DIR` environment variable, otherwise defaults to `'.logfire'`.
@@ -199,7 +198,6 @@ def configure( # noqa: D417
199198
which exports metrics to Logfire's API.
200199
pydantic_plugin: Configuration for the Pydantic plugin. If `None` uses the `LOGFIRE_PYDANTIC_PLUGIN_*` environment
201200
variables, otherwise defaults to `PydanticPlugin(record='off')`.
202-
fast_shutdown: Whether to shut down exporters and providers quickly, mostly used for tests. Defaults to `False`.
203201
scrubbing: Options for scrubbing sensitive data. Set to `False` to disable.
204202
inspect_arguments: Whether to enable
205203
[f-string magic](https://logfire.pydantic.dev/docs/guides/onboarding_checklist/add_manual_tracing/#f-strings).
@@ -270,6 +268,14 @@ def configure( # noqa: D417
270268
'Use `sampling=logfire.SamplingOptions(head=...)` instead.',
271269
)
272270

271+
show_summary = deprecated_kwargs.pop('show_summary', None) # type: ignore
272+
if show_summary is not None: # pragma: no cover
273+
warnings.warn(
274+
'The `show_summary` argument is deprecated. '
275+
'Use `console=False` or `console=logfire.ConsoleOptions(show_project_link=False)` instead.',
276+
DeprecationWarning,
277+
)
278+
273279
if deprecated_kwargs:
274280
raise TypeError(f'configure() got unexpected keyword arguments: {", ".join(deprecated_kwargs)}')
275281

@@ -280,15 +286,13 @@ def configure( # noqa: D417
280286
service_name=service_name,
281287
service_version=service_version,
282288
console=console,
283-
show_summary=show_summary,
284289
config_dir=Path(config_dir) if config_dir else None,
285290
data_dir=Path(data_dir) if data_dir else None,
286291
id_generator=id_generator,
287292
ns_timestamp_generator=ns_timestamp_generator,
288293
additional_span_processors=additional_span_processors,
289294
additional_metric_readers=additional_metric_readers,
290295
pydantic_plugin=pydantic_plugin,
291-
fast_shutdown=fast_shutdown,
292296
scrubbing=scrubbing,
293297
inspect_arguments=inspect_arguments,
294298
sampling=sampling,
@@ -332,9 +336,6 @@ class _LogfireConfigData:
332336
console: ConsoleOptions | Literal[False] | None
333337
"""Options for controlling console output"""
334338

335-
show_summary: bool
336-
"""Whether to show the summary when starting a new project"""
337-
338339
data_dir: Path
339340
"""The directory to store Logfire data in"""
340341

@@ -350,9 +351,6 @@ class _LogfireConfigData:
350351
pydantic_plugin: PydanticPlugin
351352
"""Options for the Pydantic plugin"""
352353

353-
fast_shutdown: bool
354-
"""Whether to shut down exporters and providers quickly, mostly used for tests"""
355-
356354
scrubbing: ScrubbingOptions | Literal[False]
357355
"""Options for redacting sensitive data, or False to disable."""
358356

@@ -373,15 +371,13 @@ def _load_configuration(
373371
service_name: str | None,
374372
service_version: str | None,
375373
console: ConsoleOptions | Literal[False] | None,
376-
show_summary: bool | None,
377374
config_dir: Path | None,
378375
data_dir: Path | None,
379376
id_generator: IdGenerator | None,
380377
ns_timestamp_generator: Callable[[], int] | None,
381378
additional_span_processors: Sequence[SpanProcessor] | None,
382379
additional_metric_readers: Sequence[MetricReader] | None,
383380
pydantic_plugin: PydanticPlugin | None,
384-
fast_shutdown: bool,
385381
scrubbing: ScrubbingOptions | Literal[False] | None,
386382
inspect_arguments: bool | None,
387383
sampling: SamplingOptions | None,
@@ -394,7 +390,6 @@ def _load_configuration(
394390
self.token = param_manager.load_param('token', token)
395391
self.service_name = param_manager.load_param('service_name', service_name)
396392
self.service_version = param_manager.load_param('service_version', service_version)
397-
self.show_summary = param_manager.load_param('show_summary', show_summary)
398393
self.data_dir = param_manager.load_param('data_dir', data_dir)
399394
self.inspect_arguments = param_manager.load_param('inspect_arguments', inspect_arguments)
400395
self.ignore_no_config = param_manager.load_param('ignore_no_config')
@@ -428,6 +423,7 @@ def _load_configuration(
428423
include_timestamps=param_manager.load_param('console_include_timestamp'),
429424
verbose=param_manager.load_param('console_verbose'),
430425
min_log_level=param_manager.load_param('console_min_log_level'),
426+
show_project_link=param_manager.load_param('console_show_project_link'),
431427
)
432428

433429
if isinstance(pydantic_plugin, dict):
@@ -449,8 +445,6 @@ def _load_configuration(
449445
)
450446
self.sampling = sampling
451447

452-
self.fast_shutdown = fast_shutdown
453-
454448
self.id_generator = id_generator or RandomIdGenerator()
455449
self.ns_timestamp_generator = ns_timestamp_generator or time.time_ns
456450
self.additional_span_processors = additional_span_processors
@@ -473,15 +467,13 @@ def __init__(
473467
service_name: str | None = None,
474468
service_version: str | None = None,
475469
console: ConsoleOptions | Literal[False] | None = None,
476-
show_summary: bool | None = None,
477470
config_dir: Path | None = None,
478471
data_dir: Path | None = None,
479472
id_generator: IdGenerator | None = None,
480473
ns_timestamp_generator: Callable[[], int] | None = None,
481474
additional_span_processors: Sequence[SpanProcessor] | None = None,
482475
additional_metric_readers: Sequence[MetricReader] | None = None,
483476
pydantic_plugin: PydanticPlugin | None = None,
484-
fast_shutdown: bool = False,
485477
scrubbing: ScrubbingOptions | Literal[False] | None = None,
486478
inspect_arguments: bool | None = None,
487479
sampling: SamplingOptions | None = None,
@@ -501,15 +493,13 @@ def __init__(
501493
service_name=service_name,
502494
service_version=service_version,
503495
console=console,
504-
show_summary=show_summary,
505496
config_dir=config_dir,
506497
data_dir=data_dir,
507498
id_generator=id_generator,
508499
ns_timestamp_generator=ns_timestamp_generator,
509500
additional_span_processors=additional_span_processors,
510501
additional_metric_readers=additional_metric_readers,
511502
pydantic_plugin=pydantic_plugin,
512-
fast_shutdown=fast_shutdown,
513503
scrubbing=scrubbing,
514504
inspect_arguments=inspect_arguments,
515505
sampling=sampling,
@@ -533,15 +523,13 @@ def configure(
533523
service_name: str | None,
534524
service_version: str | None,
535525
console: ConsoleOptions | Literal[False] | None,
536-
show_summary: bool | None,
537526
config_dir: Path | None,
538527
data_dir: Path | None,
539528
id_generator: IdGenerator | None,
540529
ns_timestamp_generator: Callable[[], int] | None,
541530
additional_span_processors: Sequence[SpanProcessor] | None,
542531
additional_metric_readers: Sequence[MetricReader] | None,
543532
pydantic_plugin: PydanticPlugin | None,
544-
fast_shutdown: bool,
545533
scrubbing: ScrubbingOptions | Literal[False] | None,
546534
inspect_arguments: bool | None,
547535
sampling: SamplingOptions | None,
@@ -555,15 +543,13 @@ def configure(
555543
service_name,
556544
service_version,
557545
console,
558-
show_summary,
559546
config_dir,
560547
data_dir,
561548
id_generator,
562549
ns_timestamp_generator,
563550
additional_span_processors,
564551
additional_metric_readers,
565552
pydantic_plugin,
566-
fast_shutdown,
567553
scrubbing,
568554
inspect_arguments,
569555
sampling,
@@ -667,6 +653,8 @@ def add_span_processor(span_processor: SpanProcessor) -> None:
667653
metric_readers = list(self.additional_metric_readers or [])
668654

669655
if (self.send_to_logfire == 'if-token-present' and self.token is not None) or self.send_to_logfire is True:
656+
show_project_link = self.console and self.console.show_project_link
657+
670658
if self.token is None:
671659
if (credentials := LogfireCredentials.load_creds_file(self.data_dir)) is None: # pragma: no branch
672660
credentials = LogfireCredentials.initialize_project(
@@ -676,14 +664,14 @@ def add_span_processor(span_processor: SpanProcessor) -> None:
676664
credentials.write_creds_file(self.data_dir)
677665
self.token = credentials.token
678666
self.base_url = self.base_url or credentials.logfire_api_url
679-
if self.show_summary: # pragma: no branch
667+
if show_project_link: # pragma: no branch
680668
credentials.print_token_summary()
681669
else:
682670

683671
def check_token():
684672
assert self.token is not None
685673
creds = self._initialize_credentials_from_token(self.token)
686-
if self.show_summary and creds is not None: # pragma: no branch
674+
if show_project_link and creds is not None: # pragma: no branch
687675
creds.print_token_summary()
688676

689677
thread = Thread(target=check_token, name='check_logfire_token')

logfire/_internal/config_params.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ class _DefaultCallback:
6363
"""Name of the service emitting spans. For further details, please refer to the [Service section](https://opentelemetry.io/docs/specs/semconv/resource/#service)."""
6464
SERVICE_VERSION = ConfigParam(env_vars=['LOGFIRE_SERVICE_VERSION', 'OTEL_SERVICE_VERSION'], allow_file_config=True)
6565
"""Version number of the service emitting spans. For further details, please refer to the [Service section](https://opentelemetry.io/docs/specs/semconv/resource/#service)."""
66-
SHOW_SUMMARY = ConfigParam(env_vars=['LOGFIRE_SHOW_SUMMARY'], allow_file_config=True, default=True, tp=bool)
67-
"""Whether to show the summary when a new project is created."""
6866
CREDENTIALS_DIR = ConfigParam(env_vars=['LOGFIRE_CREDENTIALS_DIR'], allow_file_config=True, default='.logfire', tp=Path)
6967
"""The directory where to store the configuration file."""
7068
CONSOLE = ConfigParam(env_vars=['LOGFIRE_CONSOLE'], allow_file_config=True, default=True, tp=bool)
@@ -84,6 +82,8 @@ class _DefaultCallback:
8482
"""Whether to log in verbose mode in the console."""
8583
CONSOLE_MIN_LOG_LEVEL = ConfigParam(env_vars=['LOGFIRE_CONSOLE_MIN_LOG_LEVEL'], allow_file_config=True, default='info', tp=LevelName)
8684
"""Minimum log level to show in the console."""
85+
CONSOLE_SHOW_PROJECT_LINK = ConfigParam(env_vars=['LOGFIRE_CONSOLE_SHOW_PROJECT_LINK', 'LOGFIRE_SHOW_SUMMARY'], allow_file_config=True, default=True, tp=bool)
86+
"""Whether to enable/disable the console exporter."""
8787
PYDANTIC_PLUGIN_RECORD = ConfigParam(env_vars=['LOGFIRE_PYDANTIC_PLUGIN_RECORD'], allow_file_config=True, default='off', tp=PydanticPluginRecordValues)
8888
"""Whether instrument Pydantic validation.."""
8989
PYDANTIC_PLUGIN_INCLUDE = ConfigParam(env_vars=['LOGFIRE_PYDANTIC_PLUGIN_INCLUDE'], allow_file_config=True, default=set(), tp=Set[str])
@@ -105,14 +105,14 @@ class _DefaultCallback:
105105
'service_name': SERVICE_NAME,
106106
'service_version': SERVICE_VERSION,
107107
'trace_sample_rate': TRACE_SAMPLE_RATE,
108-
'show_summary': SHOW_SUMMARY,
109108
'data_dir': CREDENTIALS_DIR,
110109
'console': CONSOLE,
111110
'console_colors': CONSOLE_COLORS,
112111
'console_span_style': CONSOLE_SPAN_STYLE,
113112
'console_include_timestamp': CONSOLE_INCLUDE_TIMESTAMP,
114113
'console_verbose': CONSOLE_VERBOSE,
115114
'console_min_log_level': CONSOLE_MIN_LOG_LEVEL,
115+
'console_show_project_link': CONSOLE_SHOW_PROJECT_LINK,
116116
'pydantic_plugin_record': PYDANTIC_PLUGIN_RECORD,
117117
'pydantic_plugin_include': PYDANTIC_PLUGIN_INCLUDE,
118118
'pydantic_plugin_exclude': PYDANTIC_PLUGIN_EXCLUDE,

tests/test_configure.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ def configure_tracking_exporter():
595595
send_to_logfire=True,
596596
token='abc1',
597597
console=False,
598-
fast_shutdown=True,
599598
)
600599
wait_for_check_token_thread()
601600

@@ -1294,7 +1293,7 @@ def test_send_to_logfire_if_token_present_not_empty(capsys: pytest.CaptureFixtur
12941293
'https://logfire-api.pydantic.dev/v1/info',
12951294
json={'project_name': 'myproject', 'project_url': 'fake_project_url'},
12961295
)
1297-
configure(send_to_logfire='if-token-present', console=False)
1296+
configure(send_to_logfire='if-token-present')
12981297
wait_for_check_token_thread()
12991298
assert len(request_mocker.request_history) == 1
13001299
assert capsys.readouterr().err == 'Logfire project URL: fake_project_url\n'

0 commit comments

Comments
 (0)