This repository was archived by the owner on Mar 25, 2026. It is now read-only.
feat: propagate OTEL env var attributes as default log fields#157
Merged
vik-nullify merged 2 commits intomainfrom Feb 24, 2026
Merged
feat: propagate OTEL env var attributes as default log fields#157vik-nullify merged 2 commits intomainfrom
vik-nullify merged 2 commits intomainfrom
Conversation
Read OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES at logger init and inject them as default zap fields so logs carry the same resource context as traces and metrics. Also fixes stale ldflags path in Makefile and updates README with corrected examples, span/meter usage docs.
Member
Author
|
The idea here is to have the same attributes available one logs, traces, and metrics. Also this way in grafana alloy we can just read these fields rather than inferring the labels from things like the log group, which doesn't seem to work quite right for ecs |
tim-thacker-nullify
approved these changes
Feb 24, 2026
Member
Author
|
Ill leave this one up till @vik-nullify gets a chance to review it, in case this is a bad idea with alloy. only thing I can think right now is it'll add a bit of size overhead to each log |
vik-nullify
approved these changes
Feb 24, 2026
Member
|
It does, lets see how useful it is and think about pruning the logs with just right labels as a final pass after this release |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
OTEL_SERVICE_NAMEandOTEL_RESOURCE_ATTRIBUTESat logger init and injects them as default zap fields, so logs carry the same resource context as traces and metrics.Test plan
otelEnvFields()covering all cases (no vars, one set, both, malformed, values with=)go test ./pkg/logger/...)make lint)