Skip to content

Commit 2387605

Browse files
committed
add accepted/refused/failed profile sample metrics to the receivers
1 parent 73f090c commit 2387605

File tree

15 files changed

+378
-19
lines changed

15 files changed

+378
-19
lines changed

receiver/otlpreceiver/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ require (
7474
go.opentelemetry.io/collector/extension/extensionmiddleware v0.140.0 // indirect
7575
go.opentelemetry.io/collector/featuregate v1.46.0 // indirect
7676
go.opentelemetry.io/collector/pipeline v1.46.0 // indirect
77+
go.opentelemetry.io/collector/pipeline/xpipeline v0.140.0 // indirect
7778
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 // indirect
7879
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
7980
go.opentelemetry.io/otel/metric v1.38.0 // indirect

receiver/otlpreceiver/go.sum

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/otlpreceiver/internal/profiles/otlp.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,39 @@ import (
99
"go.opentelemetry.io/collector/consumer/xconsumer"
1010
"go.opentelemetry.io/collector/pdata/pprofile/pprofileotlp"
1111
"go.opentelemetry.io/collector/receiver/otlpreceiver/internal/errors"
12+
"go.opentelemetry.io/collector/receiver/receiverhelper"
1213
)
1314

15+
const dataFormatProtobuf = "protobuf"
16+
1417
// Receiver is the type used to handle spans from OpenTelemetry exporters.
1518
type Receiver struct {
1619
pprofileotlp.UnimplementedGRPCServer
1720
nextConsumer xconsumer.Profiles
21+
obsreport *receiverhelper.ObsReport
1822
}
1923

2024
// New creates a new Receiver reference.
21-
func New(nextConsumer xconsumer.Profiles) *Receiver {
25+
func New(nextConsumer xconsumer.Profiles, obsreport *receiverhelper.ObsReport) *Receiver {
2226
return &Receiver{
2327
nextConsumer: nextConsumer,
28+
obsreport: obsreport,
2429
}
2530
}
2631

2732
// Export implements the service Export profiles func.
2833
func (r *Receiver) Export(ctx context.Context, req pprofileotlp.ExportRequest) (pprofileotlp.ExportResponse, error) {
2934
td := req.Profiles()
3035
// We need to ensure that it propagates the receiver name as a tag
31-
numProfiles := td.SampleCount()
32-
if numProfiles == 0 {
36+
numSamples := td.SampleCount()
37+
if numSamples == 0 {
3338
return pprofileotlp.NewExportResponse(), nil
3439
}
3540

41+
ctx = r.obsreport.StartTracesOp(ctx)
3642
err := r.nextConsumer.ConsumeProfiles(ctx, td)
43+
r.obsreport.EndTracesOp(ctx, dataFormatProtobuf, numSamples, err)
44+
3745
// Use appropriate status codes for permanent/non-permanent errors
3846
// If we return the error straightaway, then the grpc implementation will set status code to Unknown
3947
// Refer: https://github.com/grpc/grpc-go/blob/v1.59.0/server.go#L1345

receiver/otlpreceiver/internal/profiles/otlp_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ import (
1616
"google.golang.org/grpc/credentials/insecure"
1717
"google.golang.org/grpc/status"
1818

19+
"go.opentelemetry.io/collector/component"
1920
"go.opentelemetry.io/collector/consumer/consumererror"
2021
"go.opentelemetry.io/collector/consumer/consumertest"
2122
"go.opentelemetry.io/collector/consumer/xconsumer"
2223
"go.opentelemetry.io/collector/pdata/pprofile/pprofileotlp"
2324
"go.opentelemetry.io/collector/pdata/testdata"
25+
"go.opentelemetry.io/collector/receiver/otlpreceiver/internal/metadata"
26+
"go.opentelemetry.io/collector/receiver/receiverhelper"
27+
"go.opentelemetry.io/collector/receiver/receivertest"
2428
)
2529

2630
func TestExport(t *testing.T) {
@@ -86,7 +90,16 @@ func otlpReceiverOnGRPCServer(t *testing.T, tc xconsumer.Profiles) net.Addr {
8690
require.NoError(t, ln.Close())
8791
})
8892

89-
r := New(tc)
93+
set := receivertest.NewNopSettings(metadata.Type)
94+
set.ID = component.MustNewIDWithName("otlp", "profiles")
95+
obsreport, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{
96+
ReceiverID: set.ID,
97+
Transport: "grpc",
98+
ReceiverCreateSettings: set,
99+
})
100+
require.NoError(t, err)
101+
102+
r := New(tc, obsreport)
90103
// Now run it as a gRPC server
91104
srv := grpc.NewServer()
92105
pprofileotlp.RegisterGRPCServer(srv, r)

receiver/otlpreceiver/otlp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (r *otlpReceiver) startGRPCServer(ctx context.Context, host component.Host)
110110
}
111111

112112
if r.nextProfiles != nil {
113-
pprofileotlp.RegisterGRPCServer(r.serverGRPC, profiles.New(r.nextProfiles))
113+
pprofileotlp.RegisterGRPCServer(r.serverGRPC, profiles.New(r.nextProfiles, r.obsrepGRPC))
114114
}
115115

116116
var gln net.Listener
@@ -160,7 +160,7 @@ func (r *otlpReceiver) startHTTPServer(ctx context.Context, host component.Host)
160160
}
161161

162162
if r.nextProfiles != nil {
163-
httpProfilesReceiver := profiles.New(r.nextProfiles)
163+
httpProfilesReceiver := profiles.New(r.nextProfiles, r.obsrepHTTP)
164164
httpMux.HandleFunc(defaultProfilesURLPath, func(resp http.ResponseWriter, req *http.Request) {
165165
handleProfiles(resp, req, httpProfilesReceiver)
166166
})

receiver/receiverhelper/documentation.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ Number of metric points successfully pushed into the pipeline. [Alpha]
2222
| ---- | ----------- | ---------- | --------- | --------- |
2323
| {datapoints} | Sum | Int | true | Alpha |
2424

25+
### otelcol_receiver_accepted_profile_samples
26+
27+
Number of profile samples successfully pushed into the pipeline. [Alpha]
28+
29+
| Unit | Metric Type | Value Type | Monotonic | Stability |
30+
| ---- | ----------- | ---------- | --------- | --------- |
31+
| {samples} | Sum | Int | true | Alpha |
32+
2533
### otelcol_receiver_accepted_spans
2634

2735
Number of spans successfully pushed into the pipeline. [Alpha]
@@ -46,6 +54,14 @@ The number of metric points that failed to be processed by the receiver due to i
4654
| ---- | ----------- | ---------- | --------- | --------- |
4755
| {datapoints} | Sum | Int | true | Alpha |
4856

57+
### otelcol_receiver_failed_profile_samples
58+
59+
The number of profile samples that failed to be processed by the receiver due to internal errors. [Alpha]
60+
61+
| Unit | Metric Type | Value Type | Monotonic | Stability |
62+
| ---- | ----------- | ---------- | --------- | --------- |
63+
| {samples} | Sum | Int | true | Alpha |
64+
4965
### otelcol_receiver_failed_spans
5066

5167
The number of spans that failed to be processed by the receiver due to internal errors. [Alpha]
@@ -70,6 +86,14 @@ Number of metric points that could not be pushed into the pipeline. [Alpha]
7086
| ---- | ----------- | ---------- | --------- | --------- |
7187
| {datapoints} | Sum | Int | true | Alpha |
7288

89+
### otelcol_receiver_refused_profile_samples
90+
91+
Number of profile samples that could not be pushed into the pipeline. [Alpha]
92+
93+
| Unit | Metric Type | Value Type | Monotonic | Stability |
94+
| ---- | ----------- | ---------- | --------- | --------- |
95+
| {samples} | Sum | Int | true | Alpha |
96+
7397
### otelcol_receiver_refused_spans
7498

7599
Number of spans that could not be pushed into the pipeline. [Alpha]

receiver/receiverhelper/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
go.opentelemetry.io/collector/consumer/consumererror v0.140.0
1010
go.opentelemetry.io/collector/featuregate v1.46.0
1111
go.opentelemetry.io/collector/pipeline v1.46.0
12+
go.opentelemetry.io/collector/pipeline/xpipeline v0.140.0
1213
go.opentelemetry.io/collector/receiver v1.46.0
1314
go.opentelemetry.io/otel v1.38.0
1415
go.opentelemetry.io/otel/metric v1.38.0

receiver/receiverhelper/go.sum

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/receiverhelper/internal/metadata/generated_telemetry.go

Lines changed: 34 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/receiverhelper/internal/metadatatest/generated_telemetrytest.go

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)