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

Profiles support in OTLP Exporter #11131

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 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/otlpexporter-profiles.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. otlpreceiver)
component: otlpexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Support profiles in the OTLP exporters
dmathieu marked this conversation as resolved.
Show resolved Hide resolved

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

# (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]
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ check-contrib:
-replace go.opentelemetry.io/collector/connector/forwardconnector=$(CURDIR)/connector/forwardconnector \
-replace go.opentelemetry.io/collector/consumer=$(CURDIR)/consumer \
-replace go.opentelemetry.io/collector/consumer/consumerprofiles=$(CURDIR)/consumer/consumerprofiles \
-replace go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles=$(CURDIR)/consumer/consumererror/consumererrorprofiles \
-replace go.opentelemetry.io/collector/consumer/consumertest=$(CURDIR)/consumer/consumertest \
-replace go.opentelemetry.io/collector/exporter=$(CURDIR)/exporter \
-replace go.opentelemetry.io/collector/exporter/debugexporter=$(CURDIR)/exporter/debugexporter \
Expand Down Expand Up @@ -356,6 +357,7 @@ restore-contrib:
-dropreplace go.opentelemetry.io/collector/connector/forwardconnector \
-dropreplace go.opentelemetry.io/collector/consumer \
-dropreplace go.opentelemetry.io/collector/consumer/consumerprofiles \
-dropreplace go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles \
-dropreplace go.opentelemetry.io/collector/consumer/consumertest \
-dropreplace go.opentelemetry.io/collector/exporter \
-dropreplace go.opentelemetry.io/collector/exporter/debugexporter \
Expand Down
1 change: 1 addition & 0 deletions cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var (
"/confmap/provider/yamlprovider",
"/consumer",
"/consumer/consumerprofiles",
"/consumer/consumererror/consumererrorprofiles",
"/consumer/consumertest",
"/connector",
"/connector/connectorprofiles",
Expand Down
1 change: 1 addition & 0 deletions cmd/builder/test/core.builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ replaces:
- go.opentelemetry.io/collector/confmap/provider/yamlprovider => ${WORKSPACE_DIR}/confmap/provider/yamlprovider
- go.opentelemetry.io/collector/consumer => ${WORKSPACE_DIR}/consumer
- go.opentelemetry.io/collector/consumer/consumerprofiles => ${WORKSPACE_DIR}/consumer/consumerprofiles
- go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles => ${WORKSPACE_DIR}/consumer/consumererror/consumererrorprofiles
- go.opentelemetry.io/collector/consumer/consumertest => ${WORKSPACE_DIR}/consumer/consumertest
- go.opentelemetry.io/collector/connector => ${WORKSPACE_DIR}/connector
- go.opentelemetry.io/collector/connector/connectorprofiles => ${WORKSPACE_DIR}/connector/connectorprofiles
Expand Down
8 changes: 8 additions & 0 deletions cmd/mdatagen/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,23 @@ func (s *Status) validateStability() error {
if c != "metrics" &&
c != "traces" &&
c != "logs" &&
c != "profiles" &&
c != "traces_to_traces" &&
c != "traces_to_metrics" &&
c != "traces_to_logs" &&
c != "traces_to_profiles" &&
c != "metrics_to_traces" &&
c != "metrics_to_metrics" &&
c != "metrics_to_logs" &&
c != "metrics_to_profiles" &&
c != "logs_to_traces" &&
c != "logs_to_metrics" &&
c != "logs_to_logs" &&
c != "logs_to_profiles" &&
c != "profiles_to_profiles" &&
c != "profiles_to_traces" &&
c != "profiles_to_metrics" &&
c != "profiles_to_logs" &&
c != "extension" {
errs = errors.Join(errs, fmt.Errorf("invalid component: %v", c))
}
Expand Down
1 change: 1 addition & 0 deletions cmd/otelcorecol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ replaces:
- go.opentelemetry.io/collector/confmap/provider/yamlprovider => ../../confmap/provider/yamlprovider
- go.opentelemetry.io/collector/consumer => ../../consumer
- go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles
- go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles => ../../consumer/consumererror/consumererrorprofiles
- go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest
- go.opentelemetry.io/collector/connector => ../../connector
- go.opentelemetry.io/collector/connector/connectorprofiles => ../../connector/connectorprofiles
Expand Down
3 changes: 3 additions & 0 deletions cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ require (
go.opentelemetry.io/collector/config/internal v0.109.0 // indirect
go.opentelemetry.io/collector/connector/connectorprofiles v0.109.0 // indirect
go.opentelemetry.io/collector/consumer v0.109.0 // indirect
go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles v0.0.0-00010101000000-000000000000 // indirect
go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect
go.opentelemetry.io/collector/consumer/consumertest v0.109.0 // indirect
go.opentelemetry.io/collector/exporter/exporterprofiles v0.109.0 // indirect
Expand Down Expand Up @@ -196,6 +197,8 @@ replace go.opentelemetry.io/collector/consumer => ../../consumer

replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles

replace go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles => ../../consumer/consumererror/consumererrorprofiles

replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest

replace go.opentelemetry.io/collector/connector => ../../connector
Expand Down
1 change: 1 addition & 0 deletions consumer/consumererror/consumererrorprofiles/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../../Makefile.Common
36 changes: 36 additions & 0 deletions consumer/consumererror/consumererrorprofiles/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles

go 1.22.0

require (
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/consumer v0.0.0-00010101000000-000000000000
dmathieu marked this conversation as resolved.
Show resolved Hide resolved
go.opentelemetry.io/collector/pdata/pprofile v0.109.0
go.opentelemetry.io/collector/pdata/testdata v0.109.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opentelemetry.io/collector/pdata v1.15.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/grpc v1.66.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace go.opentelemetry.io/collector/consumer => ../..

replace go.opentelemetry.io/collector/pdata => ../../../pdata

replace go.opentelemetry.io/collector/pdata/testdata => ../../../pdata/testdata

replace go.opentelemetry.io/collector/pdata/pprofile => ../../../pdata/pprofile
77 changes: 77 additions & 0 deletions consumer/consumererror/consumererrorprofiles/go.sum

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

25 changes: 25 additions & 0 deletions consumer/consumererror/consumererrorprofiles/signalerrors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package consumererrorprofiles // import "go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles"

import (
"go.opentelemetry.io/collector/consumer/consumererror/internal"
"go.opentelemetry.io/collector/pdata/pprofile"
)

// Profiles is an error that may carry associated Profile data for a subset of received data
// that failed to be processed or sent.
type Profiles struct {
internal.Retryable[pprofile.Profiles]
}

// NewProfiles creates a Profiles that can encapsulate received data that failed to be processed or sent.
func NewProfiles(err error, data pprofile.Profiles) error {
return Profiles{
Retryable: internal.Retryable[pprofile.Profiles]{
Err: err,
Value: data,
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package consumererrorprofiles // import "go.opentelemetry.io/collector/consumer/consumererror/consumererrorprofiles"

import (
"errors"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/pdata/testdata"
)

func TestProfiles(t *testing.T) {
td := testdata.GenerateProfiles(1)
err := errors.New("some error")
profileErr := NewProfiles(err, td)
assert.Equal(t, err.Error(), profileErr.Error())
var target Profiles
assert.False(t, errors.As(nil, &target))
assert.False(t, errors.As(err, &target))
assert.True(t, errors.As(profileErr, &target))
assert.Equal(t, td, target.Data())
}

func TestProfiles_Unwrap(t *testing.T) {
td := testdata.GenerateProfiles(1)
var err error = testErrorType{"some error"}
// Wrapping err with error Profiles.
profileErr := NewProfiles(err, td)
target := testErrorType{}
require.NotEqual(t, err, target)
// Unwrapping profileErr for err and assigning to target.
require.True(t, errors.As(profileErr, &target))
require.Equal(t, err, target)
}

type testErrorType struct {
s string
}

func (t testErrorType) Error() string {
return ""
}
31 changes: 31 additions & 0 deletions consumer/consumererror/internal/retryable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package internal // import "go.opentelemetry.io/collector/consumer/consumererror/internal"

import (
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/pprofile"
"go.opentelemetry.io/collector/pdata/ptrace"
)

type Retryable[V ptrace.Traces | pmetric.Metrics | plog.Logs | pprofile.Profiles] struct {
Err error
Value V
}

// Error provides the error message
func (err Retryable[V]) Error() string {
return err.Err.Error()
}

// Unwrap returns the wrapped error for functions Is and As in standard package errors.
func (err Retryable[V]) Unwrap() error {
return err.Err
}

// Data returns the telemetry data that failed to be processed or sent.
func (err Retryable[V]) Data() V {
return err.Value
}
Loading
Loading