Skip to content

Commit 6d2cd3a

Browse files
committed
[receiver/statsd] add obsreport metrics for accepted/refused count
gci write --skip-generated -s standard -s default .
1 parent 80ebb76 commit 6d2cd3a

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: statsdreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Added accepted/refused metrics using obsreport
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [24278]
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+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

receiver/statsdreceiver/receiver.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ import (
1616
"go.opentelemetry.io/collector/consumer"
1717
"go.opentelemetry.io/collector/pdata/pmetric"
1818
"go.opentelemetry.io/collector/receiver"
19+
"go.opentelemetry.io/collector/receiver/receiverhelper"
1920
"go.uber.org/zap"
2021

22+
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/internal/metadata"
2123
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/internal/protocol"
2224
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/internal/transport"
2325
)
@@ -31,6 +33,7 @@ type statsdReceiver struct {
3133

3234
server transport.Server
3335
reporter transport.Reporter
36+
obsrecv *receiverhelper.ObsReport
3437
parser protocol.Parser
3538
nextConsumer consumer.Metrics
3639
cancel context.CancelFunc
@@ -52,10 +55,19 @@ func newReceiver(
5255
return nil, err
5356
}
5457

58+
obsrecv, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{
59+
ReceiverID: set.ID,
60+
ReceiverCreateSettings: set,
61+
})
62+
if err != nil {
63+
return nil, err
64+
}
65+
5566
r := &statsdReceiver{
5667
settings: set,
5768
config: &config,
5869
nextConsumer: nextConsumer,
70+
obsrecv: obsrecv,
5971
reporter: rep,
6072
parser: &protocol.StatsDParser{
6173
BuildInfo: set.BuildInfo,
@@ -110,10 +122,13 @@ func (r *statsdReceiver) Start(ctx context.Context, _ component.Host) error {
110122
batchMetrics := r.parser.GetMetrics()
111123
for _, batch := range batchMetrics {
112124
batchCtx := client.NewContext(ctx, batch.Info)
113-
114-
if err := r.Flush(batchCtx, batch.Metrics, r.nextConsumer); err != nil {
125+
numPoints := batch.Metrics.DataPointCount()
126+
flushCtx := r.obsrecv.StartMetricsOp(batchCtx)
127+
err := r.Flush(flushCtx, batch.Metrics, r.nextConsumer)
128+
if err != nil {
115129
r.reporter.OnDebugf("Error flushing metrics", zap.Error(err))
116130
}
131+
r.obsrecv.EndMetricsOp(flushCtx, metadata.Type.String(), numPoints, err)
117132
}
118133
case metric := <-transferChan:
119134
if err := r.parser.Aggregate(metric.Raw, metric.Addr); err != nil {

0 commit comments

Comments
 (0)