Skip to content

Add support for OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE environment variable#4667

Merged
utpilla merged 9 commits into
open-telemetry:mainfrom
utpilla:utpilla/Add-support-for-Temporality-Preference
Jul 19, 2023
Merged

Add support for OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE environment variable#4667
utpilla merged 9 commits into
open-telemetry:mainfrom
utpilla:utpilla/Add-support-for-Temporality-Preference

Conversation

@utpilla

@utpilla utpilla commented Jul 18, 2023

Copy link
Copy Markdown
Contributor

Fixes #3756

Spec: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.14.0/specification/metrics/sdk_exporters/otlp.md#additional-configuration

Changes

  • Add support for OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE environment variable

Please provide a brief description of the changes here.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes

@utpilla
utpilla requested a review from a team July 18, 2023 21:13
@codecov

codecov Bot commented Jul 18, 2023

Copy link
Copy Markdown

Codecov Report

Merging #4667 (9d3f89a) into main (67bd46d) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4667      +/-   ##
==========================================
- Coverage   85.08%   85.07%   -0.02%     
==========================================
  Files         314      314              
  Lines       12725    12747      +22     
==========================================
+ Hits        10827    10844      +17     
- Misses       1898     1903       +5     
Impacted Files Coverage Δ
...nTelemetryProtocol/OtlpMetricExporterExtensions.cs 98.86% <100.00%> (+1.89%) ⬆️

... and 3 files with indirect coverage changes

[InlineData("DELTA", MetricReaderTemporalityPreference.Delta)]
public void TestTemporalityPreferenceConfiguration(string configValue, MetricReaderTemporalityPreference expectedTemporality)
{
var configData = new Dictionary<string, string> { ["OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE"] = configValue };

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.

nit: Use the constant OtlpMetricExporterExtensions.OtlpMetricExporterTemporalityPreferenceEnvVarKey here (I'm assuming the tests can see internals)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was done on purpose. If someone accidentally changes the environment variable key name in the src file, then our tests should complain about it. If I use the const string defined in the src file then our tests would simply pass even when the value of the key is changed.

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.

I don't necessarily disagree with your logic, but it does break with all other envvar tests that I can recall seeing. Ex:

Environment.SetEnvironmentVariable(OtlpExporterOptions.EndpointEnvVarName, "http://test:8888");
Environment.SetEnvironmentVariable(OtlpExporterOptions.HeadersEnvVarName, "A=2,B=3");
Environment.SetEnvironmentVariable(OtlpExporterOptions.TimeoutEnvVarName, "2000");
Environment.SetEnvironmentVariable(OtlpExporterOptions.ProtocolEnvVarName, "http/protobuf");

I would probably go with the constant to be consistent and follow DRY principle. If someone does have a valid reason to change it they should only have to do it in one spot.

But I made this a "nit" comment because I figured you might disagree 🤣 Up to you!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we should think about what do we want to test? If we want to test, that a user a can configure something by providing a value for a particular string in the config, then our tests shouldn't be using the same const as the src file. Our tests would be too dynamic for their own good. 😄

@CodeBlanch CodeBlanch left a comment

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.

LGTM with a CHANGELOG update


## Unreleased

* Added support for configuring the metric exporter's temporality using the

@vishweshbankwar vishweshbankwar Jul 18, 2023

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.

Remove this todo as well. Can be a separate PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call out. I was thinking we should update that README once we have released a version of the package with this feature instead of doing that now.

@utpilla
utpilla merged commit 4edd9b6 into open-telemetry:main Jul 19, 2023
@utpilla
utpilla deleted the utpilla/Add-support-for-Temporality-Preference branch November 23, 2023 03:35
AsherBond pushed a commit to OTEL-California/opentelemetry-specification that referenced this pull request Jun 29, 2026
## Changes

Update the compliance matrix for .NET as of 1.16.0 of the .NET SDK.

I got Copilot to do most of the work of researching what was missing
that had been implementing and finding the relevant PRs that implemented
then. I cross checked the PRs _looked_ correct, but some of it might be
incorrect, particularly things that seem to have been implemented for a
while and predate my contributions to OTel. I then had Claude review the
changes and cross-reference, which fixed some of the entries, but again
there might still be some mistakes.

~~Some of the entries might only be available as experimental features,
so maybe they shouldn't be updated?~~ Experimental entries removed, now
marked as ~~strikethrough~~ below.

Entries updated with relevant PR links where appropriate below.

/cc @open-telemetry/dotnet-maintainers 

### Traces

- Get a Tracer with schema_url:
open-telemetry/opentelemetry-dotnet#6736
- Get a Tracer with scope attributes:
open-telemetry/opentelemetry-dotnet#6137
- Associate Tracer with InstrumentationScope:
open-telemetry/opentelemetry-dotnet#239
- Fetch InstrumentationScope from ReadableSpan:
open-telemetry/opentelemetry-dotnet#679

### Metrics

- Associate Meter with InstrumentationScope:
open-telemetry/opentelemetry-dotnet#6714
- Gauge instrument is supported:
open-telemetry/opentelemetry-dotnet#5867
- Valid instrument created / warning for duplicate name:
open-telemetry/opentelemetry-dotnet#2916
- Duplicate instrument registration resolved by first-seen:
open-telemetry/opentelemetry-dotnet#2916
- Instrument names conform to specified syntax:
open-telemetry/opentelemetry-dotnet#3821
- Instrument supports advisory ExplicitBucketBoundaries:
open-telemetry/opentelemetry-dotnet#5854
- Instrument supports advisory Attributes: Not implemented
- name/version/schema_url create InstrumentationScope:
open-telemetry/opentelemetry-dotnet#6714
- ~~View allows configuring name, description, attributes, aggregation:
open-telemetry/opentelemetry-dotnet#2396
- ~~View allows configuring exemplar reservoir:
open-telemetry/opentelemetry-dotnet#5558
- Metrics Reader supports default aggregation config:
open-telemetry/opentelemetry-dotnet#6778
- Metrics Reader supports default temporality config:
open-telemetry/opentelemetry-dotnet#4667
- ~~ExemplarReservoir interface/extension point:
open-telemetry/opentelemetry-dotnet#5542
- ~~ExemplarReservoir has offer method:
open-telemetry/opentelemetry-dotnet#5542
- SimpleFixedSizeExemplarReservoir:
open-telemetry/opentelemetry-dotnet#4256
- AlignedHistogramBucketExemplarReservoir:
open-telemetry/opentelemetry-dotnet#4119

### Logs

- ~~LoggerProvider.GetLogger:
open-telemetry/opentelemetry-dotnet#4422
- LoggerProvider.GetLogger accepts attributes: Not implemented
- LoggerProvider.Shutdown:
open-telemetry/opentelemetry-dotnet#5648
- LoggerProvider.ForceFlush:
open-telemetry/opentelemetry-dotnet#5648
- Logger.Emit(LogRecord) with Exception parameter: Not implemented
- ~~LogRecord.Set EventName:
open-telemetry/opentelemetry-dotnet#6306
- Logger.Enabled: Not implemented
- Ergonomic API (ILogger bridge):
open-telemetry/opentelemetry-dotnet#3489
- SimpleLogRecordProcessor:
open-telemetry/opentelemetry-dotnet#1622
- BatchLogRecordProcessor:
open-telemetry/opentelemetry-dotnet#1622
- Can plug custom LogRecordProcessor:
open-telemetry/opentelemetry-dotnet#4916
- LogRecordProcessor.Enabled: Not implemented
- Can plug custom LogRecordExporter:
open-telemetry/opentelemetry-dotnet#1622

### Context Propagation

- Jaeger Propagator:
open-telemetry/opentelemetry-dotnet#3309
- TextMapPropagator:
open-telemetry/opentelemetry-dotnet#1427

### Environment Variables

- OTEL_SDK_DISABLED:
open-telemetry/opentelemetry-dotnet#6568
- OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT:
open-telemetry/opentelemetry-dotnet#4887
- OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT:
open-telemetry/opentelemetry-dotnet#4887
- OTEL_TRACES_SAMPLER:
open-telemetry/opentelemetry-dotnet#5448
- OTEL_TRACES_SAMPLER_ARG:
open-telemetry/opentelemetry-dotnet#5448
- OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION:
open-telemetry/opentelemetry-dotnet#6778

### Exporters — OTLP

- OTLP/HTTP gzip Content-Encoding support:
open-telemetry/opentelemetry-dotnet#7055
- ~~Honors retryable responses with backoff:
open-telemetry/opentelemetry-dotnet#5495
- ~~Honors non-retryable responses:
open-telemetry/opentelemetry-dotnet#5495
- ~~Honors throttling response:
open-telemetry/opentelemetry-dotnet#5495
- Metric Exporter configurable temporality preference:
open-telemetry/opentelemetry-dotnet#4667
- Metric Exporter configurable default aggregation:
open-telemetry/opentelemetry-dotnet#6778

### Exporters — Zipkin

- InstrumentationScope mapping:
open-telemetry/opentelemetry-dotnet#5473

### Exporters — Prometheus

- Metadata Deduplication:
open-telemetry/opentelemetry-dotnet#7237
- otel_scope_name and otel_scope_version labels:
open-telemetry/opentelemetry-dotnet#7237
- otel_scope_[attribute] labels:
open-telemetry/opentelemetry-dotnet#7237
- Prometheus Counters have _total suffix by default:
open-telemetry/opentelemetry-dotnet#5305
- Prometheus Counters _total suffixing can be disabled:
open-telemetry/opentelemetry-dotnet#5305
- Colliding sanitized attribute keys are merged:
open-telemetry/opentelemetry-dotnet#7239
- Exemplars for Histograms and Monotonic sums:
open-telemetry/opentelemetry-dotnet#7222
- target_info metric from Resource:
open-telemetry/opentelemetry-dotnet#5407

### OpenTracing Compatibility

- Create OpenTracing Shim:
open-telemetry/opentelemetry-dotnet#197
- Tracer shim:
open-telemetry/opentelemetry-dotnet#197
- Span shim:
open-telemetry/opentelemetry-dotnet#197
- SpanContext shim:
open-telemetry/opentelemetry-dotnet#197
- ScopeManager shim:
open-telemetry/opentelemetry-dotnet#197
- Error mapping for attributes/events:
open-telemetry/opentelemetry-dotnet#197
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.

Add support for OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE env var

3 participants