Skip to content

Commit

Permalink
expose a way to control the temporality
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmarnell committed Nov 3, 2023
1 parent 3500b7d commit 66b45f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions go-kit/metrics/provider/otel/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ func WithCollectPeriod(collectPeriod time.Duration) Option {
}
}

func WithTemporalitySelector(temporality metric.TemporalitySelector) Option {
return func(c *config) error {
c.temporalitySelector = temporality

return nil
}
}

func WithExponentialHistograms() Option {
return WithAggregationSelector(ExponentialAggregationSelector)
}
Expand Down Expand Up @@ -80,6 +88,7 @@ func WithHTTPEndpointExporter(endpoint string, options ...otlpmetrichttp.Option)
defaults := []otlpmetrichttp.Option{
otlpmetrichttp.WithEndpoint(u.Host),
otlpmetrichttp.WithAggregationSelector(cfg.aggregationSelector),
otlpmetrichttp.WithTemporalitySelector(cfg.temporalitySelector),
}

if u.Scheme == "https" {
Expand Down Expand Up @@ -107,6 +116,7 @@ func WithGRPCExporter(endpoint string, options ...otlpmetricgrpc.Option) Option
defaults := []otlpmetricgrpc.Option{
otlpmetricgrpc.WithEndpoint(endpoint),
otlpmetricgrpc.WithInsecure(),
otlpmetricgrpc.WithTemporalitySelector(cfg.temporalitySelector),
otlpmetricgrpc.WithAggregationSelector(cfg.aggregationSelector),
}
options = append(defaults, options...)
Expand Down
1 change: 1 addition & 0 deletions go-kit/metrics/provider/otel/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type config struct {
serviceResource *resource.Resource
prefix string
collectPeriod time.Duration
temporalitySelector metric.TemporalitySelector
aggregationSelector metric.AggregationSelector
exporterFactory exporterFactory
}
Expand Down

0 comments on commit 66b45f7

Please sign in to comment.