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

Refactor Prometheus exporter #3239

Merged
merged 13 commits into from Oct 14, 2022
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Added

- Added an example of using metric views to customize instruments. (#3177)
- Prometheus exporter will register with a prometheus registerer on creation, there are options to control this (#3239)
MadVikingGod marked this conversation as resolved.
Show resolved Hide resolved

### Changed
MadVikingGod marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
13 changes: 12 additions & 1 deletion exporters/prometheus/exporter_test.go
Expand Up @@ -141,7 +141,18 @@ func TestPrometheusExporter(t *testing.T) {

exporter, err := New(WithGatherer(registry), WithRegisterer(registry))
require.NoError(t, err)
provider := metric.NewMeterProvider(metric.WithReader(exporter))

customBucketsView, err := view.New(
view.MatchInstrumentName("histogram_*"),
view.WithSetAggregation(aggregation.ExplicitBucketHistogram{
Boundaries: []float64{0, 5, 10, 25, 50, 75, 100, 250, 500, 1000},
}),
)
require.NoError(t, err)
defaultView, err := view.New(view.MatchInstrumentName("*"))
require.NoError(t, err)

provider := metric.NewMeterProvider(metric.WithReader(exporter, customBucketsView, defaultView))
meter := provider.Meter("testmeter")

tc.recordMetrics(ctx, meter)
Expand Down