Skip to content

Commit 6a8b6e6

Browse files
authored
Change verbosity level for otelcol_exporter_queue_batch_send_size metric (#14279)
<!-- Issue number if applicable --> #### Link to tracking issue Fixes #14278 --------- Signed-off-by: Israel Blancas <[email protected]>
1 parent 1e7867f commit 6a8b6e6

File tree

3 files changed

+105
-7
lines changed

3 files changed

+105
-7
lines changed

.chloggen/14278.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
7+
component: pkg/exporterhelper
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Change verbosity level for otelcol_exporter_queue_batch_send_size metric to detailed.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [14278]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

service/internal/metricviews/views.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,15 @@ func DefaultViews(level configtelemetry.Level) []config.View {
9393
// Batch exporter metrics
9494
if level < configtelemetry.LevelDetailed {
9595
scope := ptr("go.opentelemetry.io/collector/exporter/exporterhelper")
96-
views = append(views, dropViewOption(&config.ViewSelector{
97-
MeterName: scope,
98-
InstrumentName: ptr("otelcol_exporter_queue_batch_send_size_bytes"),
99-
}))
96+
views = append(views,
97+
dropViewOption(&config.ViewSelector{
98+
MeterName: scope,
99+
InstrumentName: ptr("otelcol_exporter_queue_batch_send_size_bytes"),
100+
}),
101+
dropViewOption(&config.ViewSelector{
102+
MeterName: scope,
103+
InstrumentName: ptr("otelcol_exporter_queue_batch_send_size"),
104+
}))
100105
}
101106

102107
// Batch processor metrics

service/internal/metricviews/views_test.go

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/stretchr/testify/assert"
10+
"github.com/stretchr/testify/require"
1011

1112
"go.opentelemetry.io/collector/config/configtelemetry"
1213
)
@@ -21,17 +22,17 @@ func TestDefaultViews(t *testing.T) {
2122
{
2223
name: "None",
2324
level: configtelemetry.LevelNone,
24-
wantViewsCount: 16,
25+
wantViewsCount: 17,
2526
},
2627
{
2728
name: "Basic",
2829
level: configtelemetry.LevelBasic,
29-
wantViewsCount: 16,
30+
wantViewsCount: 17,
3031
},
3132
{
3233
name: "Normal",
3334
level: configtelemetry.LevelNormal,
34-
wantViewsCount: 13,
35+
wantViewsCount: 14,
3536
},
3637
{
3738
name: "Detailed",
@@ -45,3 +46,70 @@ func TestDefaultViews(t *testing.T) {
4546
})
4647
}
4748
}
49+
50+
func TestDefaultViews_BatchExporterMetrics(t *testing.T) {
51+
tests := []struct {
52+
name string
53+
level configtelemetry.Level
54+
shouldDropBucket bool
55+
shouldDropBytes bool
56+
}{
57+
{
58+
name: "basic level drops bucket and bytes",
59+
level: configtelemetry.LevelBasic,
60+
shouldDropBucket: true,
61+
shouldDropBytes: true,
62+
},
63+
{
64+
name: "normal level drops bucket and bytes",
65+
level: configtelemetry.LevelNormal,
66+
shouldDropBucket: true,
67+
shouldDropBytes: true,
68+
},
69+
{
70+
name: "detailed level does not drop bucket or bytes",
71+
level: configtelemetry.LevelDetailed,
72+
shouldDropBucket: false,
73+
shouldDropBytes: false,
74+
},
75+
}
76+
77+
for _, tt := range tests {
78+
t.Run(tt.name, func(t *testing.T) {
79+
views := DefaultViews(tt.level)
80+
81+
exporterHelperScope := "go.opentelemetry.io/collector/exporter/exporterhelper"
82+
bucketMetricName := "otelcol_exporter_queue_batch_send_size"
83+
bytesMetricName := "otelcol_exporter_queue_batch_send_size_bytes"
84+
85+
var foundBucketDrop, foundBytesDrop bool
86+
for _, view := range views {
87+
if view.Selector != nil {
88+
if view.Selector.MeterName != nil && *view.Selector.MeterName == exporterHelperScope {
89+
if view.Selector.InstrumentName != nil {
90+
if *view.Selector.InstrumentName == bucketMetricName {
91+
foundBucketDrop = true
92+
// Verify it's a drop view
93+
require.NotNil(t, view.Stream)
94+
require.NotNil(t, view.Stream.Aggregation)
95+
require.NotNil(t, view.Stream.Aggregation.Drop)
96+
}
97+
if *view.Selector.InstrumentName == bytesMetricName {
98+
foundBytesDrop = true
99+
// Verify it's a drop view
100+
require.NotNil(t, view.Stream)
101+
require.NotNil(t, view.Stream.Aggregation)
102+
require.NotNil(t, view.Stream.Aggregation.Drop)
103+
}
104+
}
105+
}
106+
}
107+
}
108+
109+
assert.Equal(t, tt.shouldDropBucket, foundBucketDrop,
110+
"bucket metric drop view should be %v for level %v", tt.shouldDropBucket, tt.level)
111+
assert.Equal(t, tt.shouldDropBytes, foundBytesDrop,
112+
"bytes metric drop view should be %v for level %v", tt.shouldDropBytes, tt.level)
113+
})
114+
}
115+
}

0 commit comments

Comments
 (0)