Skip to content

Commit

Permalink
Update metrics option to require a MeterProvider instead of a Reader
Browse files Browse the repository at this point in the history
  • Loading branch information
kralicky committed Apr 10, 2023
1 parent 4cd02ff commit e5efdae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
21 changes: 1 addition & 20 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,7 @@ type MetricsExporter struct {
staticAttrs []attribute.KeyValue
}

// func (m *MetricsExporter) Inverted() *MetricsExporter {
// if m == nil {
// return nil
// }
// return &MetricsExporter{
// rxBytesCollector: m.txBytesCollector,
// txBytesCollector: m.rxBytesCollector,

// rxRpcCollector: m.txRpcCollector,
// txRpcCollector: m.rxRpcCollector,

// svcRxLatencyCollector: m.svcRxLatencyCollector,
// svcTxLatencyCollector: m.svcTxLatencyCollector,

// staticAttrs: m.staticAttrs,
// }
// }

func NewMetricsExporter(reader metric.Reader, staticAttrs ...attribute.KeyValue) *MetricsExporter {
provider := metric.NewMeterProvider(metric.WithReader(reader))
func NewMetricsExporter(provider *metric.MeterProvider, staticAttrs ...attribute.KeyValue) *MetricsExporter {
meter := provider.Meter("github.com/kralicky/totem/metrics")

rxBytes, err := meter.Int64Counter("stream_receive_bytes",
Expand Down
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ func WithInterceptors(config InterceptorConfig) ServerOption {
}
}

func WithMetrics(reader metric.Reader, staticAttrs ...attribute.KeyValue) ServerOption {
func WithMetrics(provider *metric.MeterProvider, staticAttrs ...attribute.KeyValue) ServerOption {
return func(o *ServerOptions) {
o.metrics = NewMetricsExporter(reader, staticAttrs...)
o.metrics = NewMetricsExporter(provider, staticAttrs...)
}
}

Expand Down

0 comments on commit e5efdae

Please sign in to comment.