Skip to content

Commit 8ba3ae3

Browse files
dmathieurogercollmx-psi
authored
Add accepted/refused/failed profile sample metrics to the receivers (#14226)
This adds obs metrics to the profiles receivers. --------- Co-authored-by: Roger Coll <[email protected]> Co-authored-by: Pablo Baeyens <[email protected]>
1 parent b3125ce commit 8ba3ae3

File tree

16 files changed

+431
-19
lines changed

16 files changed

+431
-19
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: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
7+
component: receiver/otlp
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add metrics tracking the number of receiver, refused and failed profile samples
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [14226]
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: [api]
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: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
7+
component: pkg/receiverhelper
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add support for profile samples metrics
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [14226]
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: [api]

receiver/otlpreceiver/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ require (
7676
go.opentelemetry.io/collector/featuregate v1.49.0 // indirect
7777
go.opentelemetry.io/collector/internal/componentalias v0.0.0-00010101000000-000000000000 // indirect
7878
go.opentelemetry.io/collector/pipeline v1.49.0 // indirect
79+
go.opentelemetry.io/collector/pipeline/xpipeline v0.0.0-00010101000000-000000000000 // indirect
7980
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 // indirect
8081
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
8182
go.opentelemetry.io/otel/metric v1.39.0 // indirect
@@ -169,4 +170,6 @@ replace go.opentelemetry.io/collector/extension/extensionmiddleware/extensionmid
169170

170171
replace go.opentelemetry.io/collector/internal/testutil => ../../internal/testutil
171172

173+
replace go.opentelemetry.io/collector/pipeline/xpipeline => ../../pipeline/xpipeline
174+
172175
replace go.opentelemetry.io/collector/internal/componentalias => ../../internal/componentalias

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
go.opentelemetry.io/collector/consumer/consumererror v0.143.0
1010
go.opentelemetry.io/collector/featuregate v1.49.0
1111
go.opentelemetry.io/collector/pipeline v1.49.0
12+
go.opentelemetry.io/collector/pipeline/xpipeline v0.0.0-00010101000000-000000000000
1213
go.opentelemetry.io/collector/receiver v1.49.0
1314
go.opentelemetry.io/otel v1.39.0
1415
go.opentelemetry.io/otel/metric v1.39.0
@@ -69,4 +70,6 @@ replace go.opentelemetry.io/collector/consumer/consumererror => ../../consumer/c
6970

7071
replace go.opentelemetry.io/collector/internal/testutil => ../../internal/testutil
7172

73+
replace go.opentelemetry.io/collector/pipeline/xpipeline => ../../pipeline/xpipeline
74+
7275
replace go.opentelemetry.io/collector/internal/componentalias => ../../internal/componentalias

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)