Skip to content
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
feat/otel-env-attributes
Feb 24, 2026
Merged

feat: propagate OTEL env var attributes as default log fields#157
vik-nullify merged 2 commits intomainfrom
feat/otel-env-attributes

Conversation

@dnjg
Copy link
Member

@dnjg dnjg commented Feb 24, 2026

Claude

Summary

  • Reads OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES at logger init and injects them as default zap fields, so logs carry the same resource context as traces and metrics.
  • Fixes stale ldflags path in Makefile and updates README with corrected examples and span/meter usage docs.

Test plan

  • Unit tests for otelEnvFields() covering all cases (no vars, one set, both, malformed, values with =)
  • Integration test verifying fields appear in JSON log output
  • All existing tests pass (go test ./pkg/logger/...)
  • Linter passes (make lint)

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.
@dnjg dnjg added the minor label Feb 24, 2026
@dnjg dnjg requested a review from vik-nullify February 24, 2026 06:29
@dnjg
Copy link
Member Author

dnjg commented Feb 24, 2026

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

@dnjg dnjg marked this pull request as ready for review February 24, 2026 06:33
@Nullify-Platform Nullify-Platform deleted a comment from blacksmith-sh bot Feb 24, 2026
@dnjg
Copy link
Member Author

dnjg commented Feb 24, 2026

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
Copy link
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

@vik-nullify vik-nullify added this pull request to the merge queue Feb 24, 2026
Merged via the queue into main with commit 6f654e0 Feb 24, 2026
3 checks passed
@vik-nullify vik-nullify deleted the feat/otel-env-attributes branch February 24, 2026 06:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants