Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mdatagen] add support for bucket boundaries #10229

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
25 changes: 25 additions & 0 deletions .chloggen/codeboten_move-batchprocessortest-mdatagentest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: add support for bucket boundaries for histograms

# One or more tracking issues or pull requests related to the change
issues: [10218]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []

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

1 change: 1 addition & 0 deletions cmd/mdatagen/internal/samplereceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ telemetry:
unit: s
histogram:
value_type: double
bucket_boundaries: [1, 10, 100]
process_runtime_total_alloc_bytes:
enabled: true
description: Cumulative bytes allocated for heap objects (see 'go doc runtime.MemStats.TotalAlloc')
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ func TestLoadMetadata(t *testing.T) {
Unit: strPtr("s"),
Histogram: &histogram{
MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeDouble},
Boundaries: []float64{1, 10, 100},
},
},
"process_runtime_total_alloc_bytes": {
Expand Down
2 changes: 2 additions & 0 deletions cmd/mdatagen/metadata-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,7 @@ telemetry:
value_type: <int|double>
# Required for sum metric: whether the metric is monotonic (no negative delta values).
monotonic: bool
# Bucket boundaries are only available to set for histogram metrics.
bucket_boundaries: [double]
# Optional: array of attributes that were defined in the attributes section that are emitted by this metric.
attributes: [string]
3 changes: 2 additions & 1 deletion cmd/mdatagen/metricdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ type histogram struct {
Mono `mapstructure:",squash"`
MetricValueType `mapstructure:"value_type"`
MetricInputType `mapstructure:",squash"`
Async bool `mapstructure:"async,omitempty"`
Async bool `mapstructure:"async,omitempty"`
Boundaries []float64 `mapstructure:"bucket_boundaries"`
}

func (d histogram) Type() string {
Expand Down
3 changes: 3 additions & 0 deletions cmd/mdatagen/templates/telemetry.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func NewTelemetryBuilder(settings component.TelemetrySettings, options ...teleme
"{{ $name }}",
metric.WithDescription("{{ $metric.Description }}"),
metric.WithUnit("{{ $metric.Unit }}"),
{{- if eq $metric.Data.Type "Histogram" -}}
{{ if $metric.Data.Boundaries -}}metric.WithExplicitBucketBoundaries([]float64{ {{- range $metric.Data.Boundaries }} {{.}}, {{- end }} }...),{{- end }}
{{- end }}
{{ if $metric.Data.Async -}}
metric.With{{ casesTitle $metric.Data.BasicType }}Callback(func(_ context.Context, o metric.{{ casesTitle $metric.Data.BasicType }}Observer) error {
o.Observe(builder.observe{{ $name.Render }}())
Expand Down
Loading