-
Notifications
You must be signed in to change notification settings - Fork 223
LOGFIRE_IGNORE_NO_CONFIG doesn't always work #1331
Copy link
Copy link
Closed
Labels
good first issueGood for newcomersGood for newcomers
Description
Description
Environment variable LOGFIRE_IGNORE_NO_CONFIG=1 doesn't always work due to how it's checked.
In my case I want to prevent the warning for tests for functions decorates with logfire.
LogfireNotConfiguredWarning: No logs or spans will be created until `logfire.configure()` has been called. Set the environment variable LOGFIRE_IGNORE_NO_CONFIG=1 or add ignore_no_config=true in pyproject.toml to suppress this warning.
with logfire.span(span_message):
So I set:
[tool.pytest.ini_options]
env = [
"LOGFIRE_IGNORE_NO_CONFIG=1",
]This ensures that LOGFIRE_IGNORE_NO_CONFIG is set before the test is run, but it doesn't prevent the warning as the LogFireConfig is created on module load, which is before any test init happens.
This wouldn't be an issue if the LogFireConfig.warn_if_not_initialized checked the environment variable but it doesn't it relies on the value of LogFireConfig.ignore_no_config which was setup on module load so has stale state.
Slack threads:
- https://pydanticlogfire.slack.com/archives/C06EDRBSAH3/p1753266055376899
- https://pydanticlogfire.slack.com/archives/C06EDRBSAH3/p1755611480458009
Python, Logfire & OS Versions, related packages (not required)
logfire="4.3.3"
platform="macOS-15.6-arm64-arm-64bit"
python="3.12.9 (main, Mar 17 2025, 21:36:21) [Clang 20.1.0 ]"
[related_packages]
requests="2.32.4"
pydantic="2.11.7"
fastapi="0.116.1"
openai="1.99.9"
protobuf="5.29.5"
rich="14.1.0"
executing="2.2.0"
opentelemetry-api="1.36.0"
opentelemetry-exporter-otlp-proto-common="1.36.0"
opentelemetry-exporter-otlp-proto-http="1.36.0"
opentelemetry-instrumentation="0.57b0"
opentelemetry-proto="1.36.0"
opentelemetry-sdk="1.36.0"
opentelemetry-semantic-conventions="0.57b0"Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers