Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .chloggen/otlpreceiver-profile-metrics.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: enhancement

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add metrics tracking the number of receiver, refused and failed profile samples

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

# (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:

# 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]
25 changes: 25 additions & 0 deletions .chloggen/receiverhelper-profile-metrics.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: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
component: pkg/receiverhelper

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add support for profile samples metrics

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

# (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:

# 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]
3 changes: 3 additions & 0 deletions receiver/otlpreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ require (
go.opentelemetry.io/collector/extension/extensionmiddleware v0.140.0 // indirect
go.opentelemetry.io/collector/featuregate v1.46.0 // indirect
go.opentelemetry.io/collector/pipeline v1.46.0 // indirect
go.opentelemetry.io/collector/pipeline/xpipeline v0.140.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
Expand Down Expand Up @@ -166,3 +167,5 @@ replace go.opentelemetry.io/collector/config/configmiddleware => ../../config/co
replace go.opentelemetry.io/collector/extension/extensionmiddleware/extensionmiddlewaretest => ../../extension/extensionmiddleware/extensionmiddlewaretest

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

replace go.opentelemetry.io/collector/pipeline/xpipeline => ../../pipeline/xpipeline
14 changes: 11 additions & 3 deletions receiver/otlpreceiver/internal/profiles/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,39 @@ import (
"go.opentelemetry.io/collector/consumer/xconsumer"
"go.opentelemetry.io/collector/pdata/pprofile/pprofileotlp"
"go.opentelemetry.io/collector/receiver/otlpreceiver/internal/errors"
"go.opentelemetry.io/collector/receiver/receiverhelper"
)

const dataFormatProtobuf = "protobuf"

// Receiver is the type used to handle spans from OpenTelemetry exporters.
type Receiver struct {
pprofileotlp.UnimplementedGRPCServer
nextConsumer xconsumer.Profiles
obsreport *receiverhelper.ObsReport
}

// New creates a new Receiver reference.
func New(nextConsumer xconsumer.Profiles) *Receiver {
func New(nextConsumer xconsumer.Profiles, obsreport *receiverhelper.ObsReport) *Receiver {
return &Receiver{
nextConsumer: nextConsumer,
obsreport: obsreport,
}
}

// Export implements the service Export profiles func.
func (r *Receiver) Export(ctx context.Context, req pprofileotlp.ExportRequest) (pprofileotlp.ExportResponse, error) {
td := req.Profiles()
// We need to ensure that it propagates the receiver name as a tag
numProfiles := td.SampleCount()
if numProfiles == 0 {
numSamples := td.SampleCount()
if numSamples == 0 {
return pprofileotlp.NewExportResponse(), nil
}

ctx = r.obsreport.StartTracesOp(ctx)
err := r.nextConsumer.ConsumeProfiles(ctx, td)
r.obsreport.EndTracesOp(ctx, dataFormatProtobuf, numSamples, err)

// Use appropriate status codes for permanent/non-permanent errors
// If we return the error straightaway, then the grpc implementation will set status code to Unknown
// Refer: https://github.com/grpc/grpc-go/blob/v1.59.0/server.go#L1345
Expand Down
15 changes: 14 additions & 1 deletion receiver/otlpreceiver/internal/profiles/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ import (
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/consumer/xconsumer"
"go.opentelemetry.io/collector/pdata/pprofile/pprofileotlp"
"go.opentelemetry.io/collector/pdata/testdata"
"go.opentelemetry.io/collector/receiver/otlpreceiver/internal/metadata"
"go.opentelemetry.io/collector/receiver/receiverhelper"
"go.opentelemetry.io/collector/receiver/receivertest"
)

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

r := New(tc)
set := receivertest.NewNopSettings(metadata.Type)
set.ID = component.MustNewIDWithName("otlp", "profiles")
obsreport, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{
ReceiverID: set.ID,
Transport: "grpc",
ReceiverCreateSettings: set,
})
require.NoError(t, err)

r := New(tc, obsreport)
// Now run it as a gRPC server
srv := grpc.NewServer()
pprofileotlp.RegisterGRPCServer(srv, r)
Expand Down
4 changes: 2 additions & 2 deletions receiver/otlpreceiver/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (r *otlpReceiver) startGRPCServer(ctx context.Context, host component.Host)
}

if r.nextProfiles != nil {
pprofileotlp.RegisterGRPCServer(r.serverGRPC, profiles.New(r.nextProfiles))
pprofileotlp.RegisterGRPCServer(r.serverGRPC, profiles.New(r.nextProfiles, r.obsrepGRPC))
}

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

if r.nextProfiles != nil {
httpProfilesReceiver := profiles.New(r.nextProfiles)
httpProfilesReceiver := profiles.New(r.nextProfiles, r.obsrepHTTP)
httpMux.HandleFunc(defaultProfilesURLPath, func(resp http.ResponseWriter, req *http.Request) {
handleProfiles(resp, req, httpProfilesReceiver)
})
Expand Down
24 changes: 24 additions & 0 deletions receiver/receiverhelper/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Number of metric points successfully pushed into the pipeline. [Alpha]
| ---- | ----------- | ---------- | --------- | --------- |
| {datapoints} | Sum | Int | true | Alpha |

### otelcol_receiver_accepted_profile_samples

Number of profile samples successfully pushed into the pipeline. [Alpha]

| Unit | Metric Type | Value Type | Monotonic | Stability |
| ---- | ----------- | ---------- | --------- | --------- |
| {samples} | Sum | Int | true | Alpha |

### otelcol_receiver_accepted_spans

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

### otelcol_receiver_failed_profile_samples

The number of profile samples that failed to be processed by the receiver due to internal errors. [Alpha]

| Unit | Metric Type | Value Type | Monotonic | Stability |
| ---- | ----------- | ---------- | --------- | --------- |
| {samples} | Sum | Int | true | Alpha |

### otelcol_receiver_failed_spans

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

### otelcol_receiver_refused_profile_samples

Number of profile samples that could not be pushed into the pipeline. [Alpha]

| Unit | Metric Type | Value Type | Monotonic | Stability |
| ---- | ----------- | ---------- | --------- | --------- |
| {samples} | Sum | Int | true | Alpha |

### otelcol_receiver_refused_spans

Number of spans that could not be pushed into the pipeline. [Alpha]
Expand Down
3 changes: 3 additions & 0 deletions receiver/receiverhelper/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
go.opentelemetry.io/collector/consumer/consumererror v0.140.0
go.opentelemetry.io/collector/featuregate v1.46.0
go.opentelemetry.io/collector/pipeline v1.46.0
go.opentelemetry.io/collector/pipeline/xpipeline v0.140.0
go.opentelemetry.io/collector/receiver v1.46.0
go.opentelemetry.io/otel v1.38.0
go.opentelemetry.io/otel/metric v1.38.0
Expand Down Expand Up @@ -66,3 +67,5 @@ replace go.opentelemetry.io/collector/featuregate => ../../featuregate
replace go.opentelemetry.io/collector/consumer/consumererror => ../../consumer/consumererror

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

replace go.opentelemetry.io/collector/pipeline/xpipeline => ../../pipeline/xpipeline
47 changes: 34 additions & 13 deletions receiver/receiverhelper/internal/metadata/generated_telemetry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading