Skip to content

fix(collector): support declarative telemetry resource format#5229

Open
ozzywalsh wants to merge 4 commits into
open-telemetry:mainfrom
ozzywalsh:fix/telemetry-resource-declarative-format
Open

fix(collector): support declarative telemetry resource format#5229
ozzywalsh wants to merge 4 commits into
open-telemetry:mainfrom
ozzywalsh:fix/telemetry-resource-declarative-format

Conversation

@ozzywalsh

@ozzywalsh ozzywalsh commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #5207.

  • The Telemetry.Resource field was typed as map[string]*string, which rejected the declarative resource.attributes array format introduced in Collector v0.151.0
  • GetTelemetry failed to unmarshal, returned nil, and ServiceApplyDefaults overwrote the entire telemetry block with defaults — dropping user-provided resource attributes, metrics level, and custom readers
  • Changed Resource to json.RawMessage so both legacy and declarative formats pass through without interpretation

Test plan

  • Added 7 unit tests covering legacy and declarative resource formats through GetTelemetry, ServiceApplyDefaults, and TelemetryToAnyConfig

@ozzywalsh
ozzywalsh force-pushed the fix/telemetry-resource-declarative-format branch from 1ce7efc to 1da7283 Compare June 19, 2026 12:13
@ozzywalsh
ozzywalsh marked this pull request as ready for review June 19, 2026 12:39
@ozzywalsh
ozzywalsh requested a review from a team as a code owner June 19, 2026 12:39
Comment thread internal/otelconfig/config_test.go Outdated

tel := GetTelemetry(&svc, logr.Discard())
require.NotNil(t, tel)
assert.Equal(t, "detailed", tel.Metrics.Level)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if possible it's better to assert on the entire telemetry object, rather than pieces of it.

Comment thread internal/otelconfig/config_test.go Outdated
require.False(t, *reader.Pull.Exporter.Prometheus.WithoutScopeInfo)
}

func TestGetTelemetryWithLegacyResource(t *testing.T) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please dry this test with table driven approach? In in single test we could execute the apply defaults and get telemetry.

@ozzywalsh
ozzywalsh force-pushed the fix/telemetry-resource-declarative-format branch from 1da7283 to a71a4fa Compare July 7, 2026 14:13
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.07%. Comparing base (cfff697) to head (a71a4fa).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5229      +/-   ##
==========================================
+ Coverage   63.05%   63.07%   +0.01%     
==========================================
  Files         215      215              
  Lines       15261    15261              
==========================================
+ Hits         9623     9626       +3     
+ Misses       4959     4956       -3     
  Partials      679      679              
Flag Coverage Δ
integration 68.10% <ø> (ø)
unittests 63.07% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mutating webhook overwrites service.telemetry when using declarative resource.attributes schema

2 participants