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

Select histogram aggregation with environment variables #3265

Merged
merged 9 commits into from Apr 28, 2023

Conversation

ocelotl
Copy link
Contributor

@ocelotl ocelotl commented Apr 19, 2023

Fixes #3264

@ocelotl ocelotl requested a review from a team as a code owner April 19, 2023 00:48
@ocelotl ocelotl self-assigned this Apr 19, 2023
@srikanthccv
Copy link
Member

I wouldn't put any OTLP exporter specific implementation in metrics SDK. The default aggregation from SDK should return the default irrespective of this env, and it should only be considered when the used exporter is OTLP. Each metric exporter has the option to configure the preferred aggregation and temporality. And I believe this logic should go in OTLP metrics exporters, similar to OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE

otel_exporter_otlp_metrics_temporality_preference = (
environ.get(
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE,
"CUMULATIVE",
)
.upper()
.strip()
)
if otel_exporter_otlp_metrics_temporality_preference == "DELTA":
instrument_class_temporality = {
Counter: AggregationTemporality.DELTA,
UpDownCounter: AggregationTemporality.CUMULATIVE,
Histogram: AggregationTemporality.DELTA,
ObservableCounter: AggregationTemporality.DELTA,
ObservableUpDownCounter: AggregationTemporality.CUMULATIVE,
ObservableGauge: AggregationTemporality.CUMULATIVE,
}
elif otel_exporter_otlp_metrics_temporality_preference == "LOWMEMORY":
instrument_class_temporality = {
Counter: AggregationTemporality.DELTA,
UpDownCounter: AggregationTemporality.CUMULATIVE,
Histogram: AggregationTemporality.DELTA,
ObservableCounter: AggregationTemporality.CUMULATIVE,
ObservableUpDownCounter: AggregationTemporality.CUMULATIVE,
ObservableGauge: AggregationTemporality.CUMULATIVE,
}
else:
if otel_exporter_otlp_metrics_temporality_preference != (
"CUMULATIVE"
):
_logger.warning(
"Unrecognized OTEL_EXPORTER_METRICS_TEMPORALITY_PREFERENCE"
" value found: "
f"{otel_exporter_otlp_metrics_temporality_preference}, "
"using CUMULATIVE"
)
instrument_class_temporality = {
Counter: AggregationTemporality.CUMULATIVE,
UpDownCounter: AggregationTemporality.CUMULATIVE,
Histogram: AggregationTemporality.CUMULATIVE,
ObservableCounter: AggregationTemporality.CUMULATIVE,
ObservableUpDownCounter: AggregationTemporality.CUMULATIVE,
ObservableGauge: AggregationTemporality.CUMULATIVE,
}
instrument_class_temporality.update(preferred_temporality or {})
.

Copy link
Member

@srikanthccv srikanthccv left a comment

Choose a reason for hiding this comment

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

See above comment

@ocelotl
Copy link
Contributor Author

ocelotl commented Apr 20, 2023

@srikanthccv moved this feature to the exporter, PTAL.

@ocelotl ocelotl added Skip Changelog PRs that do not require a CHANGELOG.md entry Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary and removed Skip Changelog PRs that do not require a CHANGELOG.md entry labels Apr 21, 2023
@ocelotl ocelotl marked this pull request as ready for review April 21, 2023 20:32
@srikanthccv srikanthccv enabled auto-merge (squash) April 28, 2023 15:01
@srikanthccv srikanthccv merged commit 14ca9f4 into open-telemetry:main Apr 28, 2023
111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION
4 participants