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

Deprecate CheckReceiverMetrics functions #12120

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
25 changes: 25 additions & 0 deletions .chloggen/deprecate-checkreceivermetrics.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: deprecation

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate CheckReceiverMetrics in componenenttest

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

# (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: Use the `metadatatest.AssertEqualMetric` series of functions instead of `obsreporttest.CheckReceiverMetrics`

# 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: [api]
1 change: 1 addition & 0 deletions component/componenttest/obsreporttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (tts *TestTelemetry) CheckReceiverLogs(protocol string, acceptedLogRecords,
return checkReceiver(tts.Telemetry, tts.id, "log_records", protocol, acceptedLogRecords, droppedLogRecords)
}

// Deprecated: [v0.119.0] use the metadatatest.AssertEqualMetric series of functions instead.
// CheckReceiverMetrics checks that for the current exported values for metrics receiver metrics match given values.
func (tts *TestTelemetry) CheckReceiverMetrics(protocol string, acceptedMetricPoints, droppedMetricPoints int64) error {
return checkReceiver(tts.Telemetry, tts.id, "metric_points", protocol, acceptedMetricPoints, droppedMetricPoints)
Expand Down
41 changes: 36 additions & 5 deletions receiver/receiverhelper/obsreport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,24 @@ func TestReceiveMetricsOp(t *testing.T) {
}
}

require.NoError(t, tt.CheckReceiverMetrics(transport, int64(acceptedMetricPoints), int64(refusedMetricPoints)))
metadatatest.AssertEqualReceiverAcceptedMetricPoints(t, tt.Telemetry,
[]metricdata.DataPoint[int64]{
{
Attributes: attribute.NewSet(
attribute.String(internal.ReceiverKey, receiverID.String()),
attribute.String(internal.TransportKey, transport)),
Value: int64(acceptedMetricPoints),
},
}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreExemplars())
metadatatest.AssertEqualReceiverRefusedMetricPoints(t, tt.Telemetry,
[]metricdata.DataPoint[int64]{
{
Attributes: attribute.NewSet(
attribute.String(internal.ReceiverKey, receiverID.String()),
attribute.String(internal.TransportKey, transport)),
Value: int64(refusedMetricPoints),
},
}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreExemplars())
})
}

Expand Down Expand Up @@ -289,10 +306,24 @@ func TestCheckReceiverMetricsViews(t *testing.T) {
require.NotNil(t, ctx)
rec.EndMetricsOp(ctx, format, 7, nil)

require.NoError(t, tt.CheckReceiverMetrics(transport, 7, 0))
require.Error(t, tt.CheckReceiverMetrics(transport, 7, 7))
require.Error(t, tt.CheckReceiverMetrics(transport, 0, 0))
assert.Error(t, tt.CheckReceiverMetrics(transport, 0, 7))
metadatatest.AssertEqualReceiverAcceptedMetricPoints(t, tt.Telemetry,
[]metricdata.DataPoint[int64]{
{
Attributes: attribute.NewSet(
attribute.String(internal.ReceiverKey, receiverID.String()),
attribute.String(internal.TransportKey, transport)),
Value: int64(7),
},
}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreExemplars())
metadatatest.AssertEqualReceiverRefusedMetricPoints(t, tt.Telemetry,
[]metricdata.DataPoint[int64]{
{
Attributes: attribute.NewSet(
attribute.String(internal.ReceiverKey, receiverID.String()),
attribute.String(internal.TransportKey, transport)),
Value: int64(0),
},
}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreExemplars())
}

func TestCheckReceiverLogsViews(t *testing.T) {
Expand Down
Loading