feat(exporter-prometheus): add config option for default aggregation - #6761
feat(exporter-prometheus): add config option for default aggregation#6761ArthurSens wants to merge 2 commits into
Conversation
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6761 +/- ##
=======================================
Coverage 94.95% 94.95%
=======================================
Files 377 377
Lines 12743 12744 +1
Branches 2896 2897 +1
=======================================
+ Hits 12100 12101 +1
Misses 643 643
🚀 New features to boost your workflow:
|
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Pull request dashboard statusStatus last refreshed: 2026-07-28 01:10:38 UTC.
This automated status or its linked feedback items may be incorrect. If something looks wrong, please report it with the result you expected. If you believe this pull request is incorrectly routed as waiting on the author, comment |
pichlermarc
left a comment
There was a problem hiding this comment.
Sorry for the late review on this PR. I think having AggreagationSelector be a function was a mistake we made, since it implies that changing the returned values after configuring the MetricReader (in this case PrometheusExporter) would re-configure already-created instruments, which is not the case.
Suggestion: let's implement this feature in a why that there's an aggregationPreference option that people can configure like so:
new PrometheusExporter({
aggregationPreference: {
gauge: {
// this here is an AggregationOption
type: AggregationType.LAST_VALUE
},
// non-specified ones fall back to default
}
})Internally, the aggregationPreference is converted to an aggregationSelector and published this way. This way it's clearer that nothing can be changed once the exporter has been instantiated. :)
Which problem is this PR solving?
Adds support for configuring the Prometheus exporter's MetricReader default aggregation as a function of instrument kind.
This implements the behavior described in the Prometheus exporter spec section being stabilized in open-telemetry/opentelemetry-specification#5113
Fixes # (issue)
Short description of the changes
defaultAggregationoption toPrometheusExporterconfig.MetricReader.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
npm run compile --workspace=@opentelemetry/exporter-prometheusnpm run lint --workspace=@opentelemetry/exporter-prometheus -- --quietnpm test -- --grep "defaultAggregation|default aggregation|configured defaultAggregation"Checklist:
Disclaimer: This PR was assisted by LLMs