Skip to content

Commit

Permalink
[cmd/mdatagen] Remove level field from metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-psi committed Jan 21, 2025
1 parent dcc866c commit 3dbab92
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 150 deletions.
6 changes: 0 additions & 6 deletions cmd/mdatagen/internal/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"golang.org/x/text/language"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/pdata/pmetric"
)
Expand Down Expand Up @@ -60,11 +59,6 @@ type Metric struct {

// Attributes is the list of attributes that the metric emits.
Attributes []AttributeName `mapstructure:"attributes"`

// Level specifies the minimum `configtelemetry.Level` for which
// the metric will be emitted. This only applies to internal telemetry
// configuration.
Level configtelemetry.Level `mapstructure:"level"`
}

type Stability struct {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions cmd/mdatagen/internal/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,3 @@ type Telemetry struct {
Level configtelemetry.Level `mapstructure:"level"`
Metrics map[MetricName]Metric `mapstructure:"metrics"`
}

func (t Telemetry) Levels() map[string]any {
levels := map[string]any{}
for _, m := range t.Metrics {
levels[m.Level.String()] = nil
}
return levels
}
11 changes: 2 additions & 9 deletions cmd/mdatagen/internal/templates/telemetry.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func NewTelemetryBuilder(settings component.TelemetrySettings, options ...Teleme

{{- range $name, $metric := .Telemetry.Metrics }}
{{- if not $metric.Optional }}
builder.{{ $name.Render }}, err = getLeveledMeter(builder.meter, configtelemetry.Level{{ $metric.Level }}, settings.MetricsLevel).{{ $metric.Data.Instrument }}(
builder.{{ $name.Render }}, err = builder.meter.{{ $metric.Data.Instrument }}(
"otelcol_{{ $name }}",
metric.WithDescription("{{ $metric.Description }}{{ $metric.Stability }}"),
metric.WithUnit("{{ $metric.Unit }}"),
Expand All @@ -119,19 +119,12 @@ func NewTelemetryBuilder(settings component.TelemetrySettings, options ...Teleme
)
errs = errors.Join(errs, err)
{{- if $metric.Data.Async }}
_, err = getLeveledMeter(builder.meter, configtelemetry.Level{{ $metric.Level }}, settings.MetricsLevel).RegisterCallback(builder.observe{{ $name.Render }}, builder.{{ $name.Render }})
_, err = builder.meter.RegisterCallback(builder.observe{{ $name.Render }}, builder.{{ $name.Render }})
errs = errors.Join(errs, err)
{{- end }}
{{- end }}
{{- end }}
return &builder, errs
}

func getLeveledMeter(meter metric.Meter, cfgLevel, srvLevel configtelemetry.Level) metric.Meter {
if cfgLevel <= srvLevel {
return meter
}
return noopmetric.Meter{}
}

{{- end }}
27 changes: 9 additions & 18 deletions exporter/exporterhelper/internal/metadata/generated_telemetry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion processor/batchprocessor/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Number of units in the batch

### otelcol_processor_batch_batch_send_size_bytes

Number of bytes in batch that was sent
Number of bytes in batch that was sent. Only available on detailed level.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
Expand Down
23 changes: 7 additions & 16 deletions processor/batchprocessor/internal/metadata/generated_telemetry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions processor/batchprocessor/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ telemetry:
value_type: int
bucket_boundaries: [ 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 20000, 30000, 50000, 100000 ]
processor_batch_batch_send_size_bytes:
level: detailed
enabled: true
description: Number of bytes in batch that was sent
description: Number of bytes in batch that was sent. Only available on detailed level.
unit: By
histogram:
value_type: int
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3dbab92

Please sign in to comment.