Skip to content

Commit 0831231

Browse files
authored
Deprecate CheckReceiverMetrics functions (#12120)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Deprecating CheckReceiverMetrics functions in the untested `obsreporttest` and `otelchecker` go files. cc @bogdandrutu <!--Describe what testing was performed and which tests were added.--> #### Testing n/a <!--Describe the documentation added.--> #### Documentation n/a <!--Please delete paragraphs that you did not use before submitting.-->
1 parent 12d8ab1 commit 0831231

File tree

3 files changed

+62
-5
lines changed

3 files changed

+62
-5
lines changed
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: deprecation
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: component/componenttest
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Deprecate CheckReceiverMetrics in componenenttest
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12185]
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: Use the `metadatatest.AssertEqualMetric` series of functions instead of `obsreporttest.CheckReceiverMetrics`
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: [api]

component/componenttest/obsreporttest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func (tts *TestTelemetry) CheckReceiverTraces(protocol string, acceptedSpans, dr
3535
return checkReceiver(tts.Telemetry, tts.id, "spans", protocol, acceptedSpans, droppedSpans)
3636
}
3737

38+
// Deprecated: [v0.120.0] use the metadatatest.AssertEqualMetric series of functions instead.
3839
// CheckReceiverMetrics checks that for the current exported values for metrics receiver metrics match given values.
3940
func (tts *TestTelemetry) CheckReceiverMetrics(protocol string, acceptedMetricPoints, droppedMetricPoints int64) error {
4041
return checkReceiver(tts.Telemetry, tts.id, "metric_points", protocol, acceptedMetricPoints, droppedMetricPoints)

receiver/receiverhelper/obsreport_test.go

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,24 @@ func TestReceiveMetricsOp(t *testing.T) {
213213
}
214214
}
215215

216-
require.NoError(t, tt.CheckReceiverMetrics(transport, int64(acceptedMetricPoints), int64(refusedMetricPoints)))
216+
metadatatest.AssertEqualReceiverAcceptedMetricPoints(t, tt.Telemetry,
217+
[]metricdata.DataPoint[int64]{
218+
{
219+
Attributes: attribute.NewSet(
220+
attribute.String(internal.ReceiverKey, receiverID.String()),
221+
attribute.String(internal.TransportKey, transport)),
222+
Value: int64(acceptedMetricPoints),
223+
},
224+
}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreExemplars())
225+
metadatatest.AssertEqualReceiverRefusedMetricPoints(t, tt.Telemetry,
226+
[]metricdata.DataPoint[int64]{
227+
{
228+
Attributes: attribute.NewSet(
229+
attribute.String(internal.ReceiverKey, receiverID.String()),
230+
attribute.String(internal.TransportKey, transport)),
231+
Value: int64(refusedMetricPoints),
232+
},
233+
}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreExemplars())
217234
})
218235
}
219236

@@ -321,10 +338,24 @@ func TestCheckReceiverMetricsViews(t *testing.T) {
321338
require.NotNil(t, ctx)
322339
rec.EndMetricsOp(ctx, format, 7, nil)
323340

324-
require.NoError(t, tt.CheckReceiverMetrics(transport, 7, 0))
325-
require.Error(t, tt.CheckReceiverMetrics(transport, 7, 7))
326-
require.Error(t, tt.CheckReceiverMetrics(transport, 0, 0))
327-
assert.Error(t, tt.CheckReceiverMetrics(transport, 0, 7))
341+
metadatatest.AssertEqualReceiverAcceptedMetricPoints(t, tt.Telemetry,
342+
[]metricdata.DataPoint[int64]{
343+
{
344+
Attributes: attribute.NewSet(
345+
attribute.String(internal.ReceiverKey, receiverID.String()),
346+
attribute.String(internal.TransportKey, transport)),
347+
Value: int64(7),
348+
},
349+
}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreExemplars())
350+
metadatatest.AssertEqualReceiverRefusedMetricPoints(t, tt.Telemetry,
351+
[]metricdata.DataPoint[int64]{
352+
{
353+
Attributes: attribute.NewSet(
354+
attribute.String(internal.ReceiverKey, receiverID.String()),
355+
attribute.String(internal.TransportKey, transport)),
356+
Value: int64(0),
357+
},
358+
}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreExemplars())
328359
}
329360

330361
func TestCheckReceiverLogsViews(t *testing.T) {

0 commit comments

Comments
 (0)