Skip to content

fix: populate OTel resource attributes from env var#163

Merged
adamflorence-nullify merged 1 commit intomainfrom
fix/otel-resource-from-env
Mar 6, 2026
Merged

fix: populate OTel resource attributes from env var#163
adamflorence-nullify merged 1 commit intomainfrom
fix/otel-resource-from-env

Conversation

@adamflorence-nullify
Copy link
Member

Description

resource.New() in configureOTel() was missing resource.WithFromEnv(), so resource attributes set via OTEL_RESOURCE_ATTRIBUTES (including nul.deployment_id and deployment.environment) were never attached to the OTel resource.

This meant they appeared on target_info (resource metadata) but not on any application metric (nul_pipeline_event_total, nul_scan_duration_seconds, etc.), making per-customer metric queries impossible.

Impact: Once deployed, all nul_* metrics will gain nul_deployment_id as a label, enabling per-customer alerting (e.g. pipeline volume drop/spike alerts) and dashboarding.

Test Plan

  • go build ./... passes
  • go test ./pkg/logger/... -short passes
  • After deploy to one service, verify nul_deployment_id appears on application metrics in Prometheus (not just target_info)
  • Verify with: group by (nul_deployment_id) (nul_pipeline_event_total{deployment_environment="prod", nul_deployment_id!=""})

Checklist

  • I have performed a self-review of my own code
  • I have checked for redundant or commented out code
  • I have made corresponding changes to the documentation
  • I have added any appropriate tests

…env var

resource.New() was not using resource.WithFromEnv(), so resource
attributes set via OTEL_RESOURCE_ATTRIBUTES (including
nul.deployment_id and deployment.environment) were never attached
to the OTel resource. This meant they appeared on target_info but
not on any application metric (nul_pipeline_event_total,
nul_scan_duration_seconds, etc.), making per-customer metric
queries impossible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adamflorence-nullify adamflorence-nullify added this pull request to the merge queue Mar 6, 2026
Merged via the queue into main with commit 8331132 Mar 6, 2026
4 checks passed
@adamflorence-nullify adamflorence-nullify deleted the fix/otel-resource-from-env branch March 6, 2026 06:38
@dnjg
Copy link
Member

dnjg commented Mar 6, 2026

deployment.environment was already being populated for the metrics from that env var, so i'm not sure this is quite right. is the distinction that we need that setting to enable it for custom attributes as opposed to standard otel ones?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants