Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (r *otelReporter) Counter(conf MetricConf) Counter {
name := r.metricName(conf.Path)
counter, err := r.meter.Float64Counter(name,
metric.WithDescription(conf.Help),
metric.WithUnit(conf.Unit),
)
if err != nil {
panic(err)
Expand All @@ -124,6 +125,7 @@ func (r *otelReporter) Gauge(conf MetricConf) Gauge {

gauge, err := r.meter.Float64Gauge(name,
metric.WithDescription(conf.Help),
metric.WithUnit(conf.Unit),
)
if err != nil {
panic(err)
Expand All @@ -148,6 +150,7 @@ func (r *otelReporter) GaugeFunc(conf MetricConf, f func() float64) GaugeFunc {

_, err := r.meter.Float64ObservableGauge(name,
metric.WithDescription(conf.Help),
metric.WithUnit(conf.Unit),
metric.WithFloat64Callback(func(ctx context.Context, obs metric.Float64Observer) error {
obs.Observe(f(), metric.WithAttributes(constAttrs...))
return nil
Expand All @@ -173,6 +176,7 @@ func (r *otelReporter) Observer(conf MetricConf) Observer {
name := r.metricName(conf.Path)
histogram, err := r.meter.Float64Histogram(name,
metric.WithDescription(conf.Help),
metric.WithUnit(conf.Unit),
)
if err != nil {
panic(err)
Expand Down
3 changes: 3 additions & 0 deletions reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ type MetricConf struct {
Help string
// ConstLabels are static key-value pairs attached to every observation of this metric.
ConstLabels map[string]string
// Unit is the metric unit following UCUM conventions (e.g. "ms", "By", "1").
// Used by the OTEL backend; ignored by Prometheus.
Unit string
}

// ReporterConf configures a Reporter instance.
Expand Down
Loading