Skip to content

Conversation

dprotaso
Copy link
Contributor

This PR exposes the default TemporalitySelector funcs that are used by the OTel env var processing.

The reason to expose these funcs is because there is some discrepancy in various vendor documentation on how to enable these settings using go option args WithTemporalitySelector

https://cloud-native.slack.com/archives/C01NPAXACKT/p1757443233624599

Copy link

codecov bot commented Sep 11, 2025

Codecov Report

❌ Patch coverage is 34.42623% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.8%. Comparing base (0d5aa14) to head (49a4a6e).
⚠️ Report is 115 commits behind head on main.

Files with missing lines Patch % Lines
sdk/metric/temporality.go 0.0% 18 Missing ⚠️
sdk/metric/reader.go 20.0% 12 Missing ⚠️
...tlpmetric/otlpmetricgrpc/internal/oconf/options.go 0.0% 5 Missing ⚠️
...tlpmetric/otlpmetrichttp/internal/oconf/options.go 0.0% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #7346     +/-   ##
=======================================
- Coverage   82.9%   82.8%   -0.2%     
=======================================
  Files        267     268      +1     
  Lines      24982   24990      +8     
=======================================
- Hits       20729   20698     -31     
- Misses      3877    3916     +39     
  Partials     376     376             
Files with missing lines Coverage Δ
...pmetric/otlpmetricgrpc/internal/oconf/envconfig.go 96.7% <100.0%> (-0.4%) ⬇️
...pmetric/otlpmetrichttp/internal/oconf/envconfig.go 96.7% <100.0%> (-0.4%) ⬇️
...tlpmetric/otlpmetricgrpc/internal/oconf/options.go 86.5% <0.0%> (-2.6%) ⬇️
...tlpmetric/otlpmetrichttp/internal/oconf/options.go 89.3% <0.0%> (-2.6%) ⬇️
sdk/metric/reader.go 68.4% <20.0%> (-31.6%) ⬇️
sdk/metric/temporality.go 0.0% <0.0%> (ø)

... and 2 files with indirect coverage changes

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

@open-telemetry open-telemetry deleted a comment from evankanderson Sep 11, 2025
@open-telemetry open-telemetry deleted a comment from evankanderson Sep 11, 2025
@MrAlias MrAlias added this to the v1.39.0 milestone Sep 11, 2025
@akats7
Copy link

akats7 commented Sep 11, 2025

@dprotaso question from the SIG, why not just expose the temporality selectors, what does the refactor/temporality preference type achieve

@dprotaso
Copy link
Contributor Author

dprotaso commented Sep 12, 2025

Hey @akats7

what does the refactor/temporality preference type achieve

Knative currently exposes a config map where users can set some OTel properties. Similar to how temporality preference can be configured using env vars we want our end-users to be able to use the same values supported by the otel-go SDK.

Having these functions/values exposed means we don't need to copy stuff from the SDK into our code base. I've highlighted in slack that this has lead to incorrect documentation from different vendors when they're telling users to write their own temporality selectors.

@dashpole
Copy link
Contributor

I think we can expose the functions, but probably can't expose the string values. Those are only part of the OTLP exporter spec, not the SDK spec. See https://github.com/open-telemetry/opentelemetry-specification/blob/1e04e1be0e17cae6d01c862049bbeb298e0ffa06/specification/metrics/sdk_exporters/otlp.md?plain=1#L50

@dprotaso
Copy link
Contributor Author

. Those are only part of the OTLP exporter spec, not the SDK spec

Does that mean the strings should be in a different package?

@dashpole
Copy link
Contributor

Yeah, they probably belong in the otelconf package eventually.

@dprotaso
Copy link
Contributor Author

What action should I take now then on this PR?

@dmathieu
Copy link
Member

I would split this into two PRs. One that exposes the functions, the other that exposes the strings, so both can be discussed/merged separately.

@dprotaso
Copy link
Contributor Author

I pulled the functions out into - #7434

Comment on lines +8 to +23
// TemporalityPreference defines the user's desired temporality for metrics instruments.
type TemporalityPreference string

const (
// TemporalityPreferenceDefault indicates the SDK's default temporality should be used.
TemporalityPreferenceDefault TemporalityPreference = ""

// TemporalityPreferenceCumulative indicates a cumulative temporality should be used.
TemporalityPreferenceCumulative TemporalityPreference = "cumulative"

// TemporalityPreferenceDelta indicates a delta temporality should be used.
TemporalityPreferenceDelta TemporalityPreference = "delta"

// TemporalityPreferenceLowMemory indicates temporality preference that optimizes memory use.
TemporalityPreferenceLowMemory TemporalityPreference = "lowmemory"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

These should not be added to the SDK. They duplicate existing configuration.

@dprotaso
Copy link
Contributor Author

dprotaso commented Oct 1, 2025

With the functions pulled out where should I put the functionality that maps the TemporalityPreference to *TemporalitySelector function?

dmathieu added a commit that referenced this pull request Oct 2, 2025
From: #7346

This PR exposes the default TemporalitySelector funcs that are used by
the OTel env var processing.

The reason to expose these funcs is because there is some discrepancy in
various vendor documentation on how to enable these settings using go
option args WithTemporalitySelector

https://cloud-native.slack.com/archives/C01NPAXACKT/p1757443233624599

---------

Co-authored-by: Damien Mathieu <[email protected]>
Co-authored-by: David Ashpole <[email protected]>
@MrAlias
Copy link
Contributor

MrAlias commented Oct 3, 2025

With the functions pulled out where should I put the functionality that maps the TemporalityPreference to *TemporalitySelector function?

@dprotaso please see https://github.com/open-telemetry/opentelemetry-go/pull/7346/files#r2392819028

I do not plan to accept any additional overlapping configuration for temporarily in the SDK.

If you would like too support resolution of the selector functions, look at adding in otelconf as was mentioned.

@dashpole
Copy link
Contributor

We discussed whether this even makes sense in otelconf, and we decided it probably does not. TemporalityPreference (the string constants) aren't part of the SDK spec. They are part of the declarative config spec for OTLP exporters, which would make the otelconf package a potential place for it to live, but we aren't ready right now to make subsections of the otelconf yaml parsing public right now. To start, we want to limit parsing to parsing the entire otelconf files.

@dprotaso
Copy link
Contributor Author

@dashpole should I close this out and just creating a tracking issue or something?

@dashpole
Copy link
Contributor

yeah. Please create the tracking issue in opentelemetry-go-contrib

@dprotaso
Copy link
Contributor Author

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.

5 participants