Skip to content

Refactor componentattribute and move into service#13948

Merged
mx-psi merged 10 commits into
open-telemetry:mainfrom
jade-guiton-dd:attr-injection-in-service
Oct 24, 2025
Merged

Refactor componentattribute and move into service#13948
mx-psi merged 10 commits into
open-telemetry:mainfrom
jade-guiton-dd:attr-injection-in-service

Conversation

@jade-guiton-dd
Copy link
Copy Markdown
Contributor

@jade-guiton-dd jade-guiton-dd commented Oct 8, 2025

Description

This PR splits the code handling component attribute injection, currently in internal/telemetry and internal/telemetry/componentattribute, into three parts:

  • the part meant to be called by components to drop unwanted injected attributes, which remains in internal/telemetry;
  • the part which handles copying Zap logs to an OTel LoggerProvider (where injected attributes are surfaced as instrumentation scope attributes), which is moved into service/telemetry/otelconftelemetry, since this "copying" behavior is specific to the otelconf-based telemetry provider;
  • the rest is moved into service/internal/componentattribute.

The main goals of this split are:

I also rewrote a lot of the attribute injection code along the way:

  • Instead of adding an unexported field in TelemetrySettings to store the current set of injected attributes, this set is now stored inside the provider wrappers (which was already partly the case). This allowed me to move the TelemetrySettings definition back into component, removing the dependency it had on componentattribute.

  • I completely changed the approach for injection in logs. Instead of a chain of custom core wrappers with a withAttributeSet method, injected attributes are now set through the standard zapcore.Core.With method. By introducing a custom ObjectMarshaler, we can make injected attributes act like regular Zap fields, while also allowing special handling in the otelzap wrapper core, which will set them as instrumentation scope attributes instead of log record attributes.

If I'm not mistaken, this PR should have no externally-visible changes, so no changelog should be necessary. (Except maybe the _ struct{} in TelemetrySettings, but there was no changelog when we added those elsewhere)

Link to tracking issue

Updates #13842

Testing

The large amounts of splitting and refactoring led me to abandon the existing tests, as they would be too hard to adapt. I wrote new tests for the code in service/telemetry/otelconftelemetry and service/internal/componentattribute, which hopefully should fill that gap appropriately.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 86.12717% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.57%. Comparing base (71418b6) to head (bc17235).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
internal/telemetry/telemetry.go 0.00% 11 Missing ⚠️
service/telemetry/otelconftelemetry/logger_tee.go 77.27% 10 Missing ⚠️
service/internal/componentattribute/logger_zap.go 91.89% 2 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (86.12%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13948      +/-   ##
==========================================
- Coverage   91.61%   91.57%   -0.05%     
==========================================
  Files         655      658       +3     
  Lines       42793    42824      +31     
==========================================
+ Hits        39205    39216      +11     
- Misses       2765     2784      +19     
- Partials      823      824       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jade-guiton-dd jade-guiton-dd added area:service collector-telemetry healthchecker and other telemetry collection issues Skip Changelog PRs that do not require a CHANGELOG.md entry labels Oct 9, 2025
@jade-guiton-dd jade-guiton-dd marked this pull request as ready for review October 9, 2025 13:23
@jade-guiton-dd jade-guiton-dd requested a review from atoulme October 9, 2025 13:23
@jade-guiton-dd
Copy link
Copy Markdown
Contributor Author

Regarding code coverage:

  • internal/telemetry/telemetry.go should be covered by service/internal/componentattribute/telemetry_test.go and service/telemetry/otelconftelemetry/logger_test.go
  • internal/telemetry/mock.go is a mock for testing purposes, used in receiver/otlpreceiver/factory_test.go and processor/memorylimiterprocessor/factory_test.go

CodeCov doesn't take these uses into account as they are in different modules.

@jade-guiton-dd
Copy link
Copy Markdown
Contributor Author

@axw I can't tag you as reviewer but I would appreciate a review from you, notably on how well this fits into the "bring your own SDK" initiative.

Copy link
Copy Markdown
Contributor

@atoulme atoulme left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@axw axw left a comment

Choose a reason for hiding this comment

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

Thanks @jade-guiton-dd, only minor concerns from me.

Comment thread internal/telemetry/telemetrytest/mock.go
Comment thread service/telemetry/otelconftelemetry/logger_tee.go Outdated
Copy link
Copy Markdown
Contributor

@jmacd jmacd left a comment

Choose a reason for hiding this comment

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

Appreciate the PR desciption!

@mx-psi
Copy link
Copy Markdown
Member

mx-psi commented Oct 24, 2025

/easycla

@mx-psi mx-psi added this pull request to the merge queue Oct 24, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 24, 2025
@mx-psi mx-psi enabled auto-merge October 24, 2025 09:34
@mx-psi mx-psi added this pull request to the merge queue Oct 24, 2025
Merged via the queue into open-telemetry:main with commit 0f3b0c9 Oct 24, 2025
60 of 62 checks passed
@github-actions github-actions Bot added this to the next release milestone Oct 24, 2025
damemi added a commit to odigos-io/odigos that referenced this pull request Feb 4, 2026
…or/otel to 141 + Remove deprecated components + Bump k8s min version to 1.21 (#4111)

The clickhouse exporter supports TLS settings similar to otlp:
https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/945e5a71ef31793ff3280b28c1425086ea5332b6/exporter/clickhouseexporter/README.md#tls

Some users need this to connect to clickhouse, adding them as options in
the destination here

This adds:

* `insecure_skip_verify`
* `ca_file` (using the k8sconfig interface to mount the secret as a
file, similar to how the GCP exporter supports application default
credentials)

The direct string fields (such as CAPem, CertPem, KeyPem) aren't yet
supported in the clickhouse exporter, so it has to be a mounted file.
See
open-telemetry/opentelemetry-collector-contrib#43911 (comment)

---

To do this, it required bumping the collector/otel deps to 136 when TLS
config support was added to clickhouse. This required the following
changes:

This actually needs collector v0.136.0 for these settings from
open-telemetry/opentelemetry-collector-contrib#42581
(open-telemetry/opentelemetry-collector-contrib@d9769f7)

Also needs to remove loki exporter (removed in 131) for 136 🙃
open-telemetry/opentelemetry-collector-contrib#41413,
see
https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.130.0/exporter/lokiexporter#deprecation-notice
it's replaced with just otlp. The only destination that actually looks
like it's using the loki exporter is OpsVerse

As well as the opencensus exporter, removed in 133 upstream by
open-telemetry/opentelemetry-collector-contrib#42239

Also routing processor
open-telemetry/opentelemetry-collector-contrib#36616

See previous attempt #3669
(reverted in #3734)

---

Then, it turns out that 136 was bugged and did not have full support for
TLS settings like `insecure_skip_verify`. This was fixed in 141, which
required the following extra changes:

Actually needs collector v141 due to this bug in clickhouse not handling
all tls settings:
open-telemetry/opentelemetry-collector-contrib#43911
fixed in
open-telemetry/opentelemetry-collector-contrib#44093

Remove deprecated carbon exporter support (unmaintained upstream)
open-telemetry/opentelemetry-collector-contrib#44532

another upstream breaking change giving go mod trouble
open-telemetry/opentelemetry-collector#13948

configgrpc update:
open-telemetry/opentelemetry-collector#13996

and now metadata.yaml metrics require stablity levels
open-telemetry/opentelemetry-collector#13756

```
Error: failed loading /app/collector/receivers/odigosebpfreceiver/metadata.yaml: decoding failed due to the following error(s):

'telemetry.metrics[ebpf_memory_pressure_wait_time_total]' missing required field: `stability`
'telemetry.metrics[ebpf_total_bytes_read]' missing required field: `stability`
'telemetry.metrics[ebpf_lost_samples]' missing required field: `stability`
Error: failed loading /app/collector/receivers/odigosebpfreceiver/metadata.yaml: decoding failed due to the following error(s):

'telemetry.metrics[ebpf_memory_pressure_wait_time_total]' missing required field: `stability`
'telemetry.metrics[ebpf_total_bytes_read]' missing required field: `stability`
'telemetry.metrics[ebpf_lost_samples]' missing required field: `stability`
Error: metadata.yaml ordering check failed: [telemetry metrics] keys are not sorted: [odigos_log_data_size odigos_metric_data_size odigos_trace_data_size odigos_accepted_spans odigos_accepted_metric_points odigos_accepted_log_records]
Error: metadata.yaml ordering check failed: [telemetry metrics] keys are not sorted: [odigos_log_data_size odigos_metric_data_size odigos_trace_data_size odigos_accepted_spans odigos_accepted_metric_points odigos_accepted_log_records]
```

This bump also required adding the `endpointslices` permission to the
odiglet service account for the data-collection collector

---

Finally, endpointslices was not GA in k8s 1.20. This PR bumps our
minimum supported k8s version to 1.21. Enterprise update in
odigos-io/odigos-enterprise#2117
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:service collector-telemetry healthchecker and other telemetry collection issues Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants