Skip to content

Commit

Permalink
use generated meter (#9669)
Browse files Browse the repository at this point in the history
This follows #9556 and uses the Meter func instead of managing the scope
in the batch processor manually. Replaces #9581

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
  • Loading branch information
codeboten authored Mar 11, 2024
1 parent aa64df7 commit c7f0172
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions processor/batchprocessor/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ import (
"go.opentelemetry.io/otel/metric"
"go.uber.org/multierr"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/batchprocessor/internal/metadata"
"go.opentelemetry.io/collector/processor/processorhelper"
)

const (
scopeName = "go.opentelemetry.io/collector/processor/batchprocessor"
)

type trigger int

const (
Expand Down Expand Up @@ -50,16 +48,16 @@ func newBatchProcessorTelemetry(set processor.CreateSettings, currentMetadataCar
detailed: set.MetricsLevel == configtelemetry.LevelDetailed,
}

if err := bpt.createOtelMetrics(set.MeterProvider, currentMetadataCardinality); err != nil {
if err := bpt.createOtelMetrics(set.TelemetrySettings, currentMetadataCardinality); err != nil {
return nil, err
}

return bpt, nil
}

func (bpt *batchProcessorTelemetry) createOtelMetrics(mp metric.MeterProvider, currentMetadataCardinality func() int) error {
func (bpt *batchProcessorTelemetry) createOtelMetrics(set component.TelemetrySettings, currentMetadataCardinality func() int) error {
var errors, err error
meter := mp.Meter(scopeName)
meter := metadata.Meter(set)

bpt.batchSizeTriggerSend, err = meter.Int64Counter(
processorhelper.BuildCustomMetricName(typeStr, "batch_size_trigger_send"),
Expand Down

0 comments on commit c7f0172

Please sign in to comment.