Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE environment variable #4667

Conversation

utpilla
Copy link
Contributor

@utpilla utpilla commented Jul 18, 2023

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
Copy link

codecov bot commented Jul 18, 2023

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
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
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
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
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. 😄

Copy link
Member

@CodeBlanch CodeBlanch left a comment

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

@@ -2,6 +2,12 @@

## Unreleased

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

@vishweshbankwar vishweshbankwar Jul 18, 2023

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
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
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