feat(exporter-prometheus): add aggregationSelector option to configure default aggregation - #6910
Conversation
…e default aggregation
|
Welcome, contributor! Thank you for your contribution to opentelemetry-js. Important reminders:
|
|
Having Suggestion: let's implement this feature in a why that there's an new PrometheusExporter({
aggregationPreference: {
gauge: {
// this here is an AggregationOption
type: AggregationType.LAST_VALUE
},
// non-specified ones fall back to default
}
})Internally, the |
Pull request dashboard statusWaiting on reviewers · refreshed 2026-07-28 23:30 UTC Review the latest changes. Status above doesn't look right?
|
…f aggregationSelector function Address review feedback: expose configuration as an aggregationPreference object keyed by instrument kind (converted to an aggregationSelector internally) instead of a selector function, making it clear the config cannot change after the exporter is instantiated. Refs open-telemetry#6605
|
@pichlermarc Thanks for the suggestion! I've updated the PR to use a static |
Which problem is this PR solving?
The
PrometheusExportercurrently hard-codes the default aggregation (AggregationType.DEFAULT) for every instrument kind, so users have no way to override how instruments are aggregated when exporting to Prometheus. This PR adds an optionalaggregationSelectorto the exporter configuration so users can configure the default aggregation as a function of instrument kind, consistent with the SDK'sMetricReaderAPI.Part of #6605
Short description of the changes
aggregationSelector?: AggregationSelectorfield toExporterConfig(src/export/types.ts).aggregationSelectorthrough to the underlyingMetricReaderinPrometheusExporter, falling back to the previous behavior (AggregationType.DEFAULTfor all instruments) when it is not provided.Type of change
How Has This Been Tested?
PrometheusExporter.test.tsverifying that a configuredaggregationSelectoris respected: with aSUMaggregation selector, a histogram instrument is exported as a single summed counter instead of histogram buckets.Checklist: