Repository navigation
Treat empty environment variables as unset - #160
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
get_optional_envreturnsSome("")for an environment variable set to an empty string, soconfigure()treats it as a real value. The OpenTelemetry specification requires an empty value to be interpreted as unset, and the Logfire Python SDK already does this.Empty variables are common in container setups (for example
LOGFIRE_TOKEN=${LOGFIRE_TOKEN}in a Compose file when the host variable is undefined). Before this change:LOGFIRE_TOKEN=""counts as a token:SendToLogfire::IfTokenPresentexports with an empty bearer token, and the default mode skips theTokenRequirederror.LOGFIRE_SEND_TO_LOGFIRE=""makesconfigure()fail with an invalid configuration value error.LOGFIRE_BASE_URL=""replaces the region URL derived from the token.LOGFIRE_SERVICE_NAME=""setsservice.nameto an empty string instead of falling back toOTEL_SERVICE_NAME.Changes
get_optional_envreturnsNonefor empty values, both from the process environment and from the explicitenvmap used in tests. AllLOGFIRE_*/OTEL_*lookups inconfigure()and the OTLP protocol lookup go through this helper.test_send_to_logfireand totest_service_resource_attributes_from_otel_env.Testing
cargo test -p logfire --lib test_send_to_logfireandcargo test -p logfire --test test_resource_attributesfail without the change and pass with it.Fixes #159