Skip to content

Commit 5c13c75

Browse files
rogercollcodeboten
andauthored
[connector/forward]: Add support for Profiles to Profiles (#14092)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Adds support for Profiles to Profies in the forward connector. <!--Describe what testing was performed and which tests were added.--> #### Testing Produce -> consume unit test <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Alex Boten <[email protected]>
1 parent a9691ee commit 5c13c75

File tree

7 files changed

+65
-11
lines changed

7 files changed

+65
-11
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. otlpreceiver)
7+
component: connector/forward
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 Profiles to Profiles
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [14092]
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: []

connector/forwardconnector/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| Distributions | [core], [contrib], [k8s] |
77
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector?query=is%3Aissue%20is%3Aopen%20label%3Aconnector%2Fforward%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aopen+is%3Aissue+label%3Aconnector%2Fforward) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector?query=is%3Aissue%20is%3Aclosed%20label%3Aconnector%2Fforward%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aclosed+is%3Aissue+label%3Aconnector%2Fforward) |
88

9+
[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development
910
[beta]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#beta
1011
[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol
1112
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
@@ -15,6 +16,7 @@
1516

1617
| [Exporter Pipeline Type] | [Receiver Pipeline Type] | [Stability Level] |
1718
| ------------------------ | ------------------------ | ----------------- |
19+
| profiles | profiles | [development] |
1820
| traces | traces | [beta] |
1921
| metrics | metrics | [beta] |
2022
| logs | logs | [beta] |

connector/forwardconnector/forward.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ import (
99
"go.opentelemetry.io/collector/component"
1010
"go.opentelemetry.io/collector/connector"
1111
"go.opentelemetry.io/collector/connector/forwardconnector/internal/metadata"
12+
"go.opentelemetry.io/collector/connector/xconnector"
1213
"go.opentelemetry.io/collector/consumer"
14+
"go.opentelemetry.io/collector/consumer/xconsumer"
1315
)
1416

1517
// NewFactory returns a connector.Factory.
16-
func NewFactory() connector.Factory {
17-
return connector.NewFactory(
18+
func NewFactory() xconnector.Factory {
19+
return xconnector.NewFactory(
1820
metadata.Type,
1921
createDefaultConfig,
20-
connector.WithTracesToTraces(createTracesToTraces, metadata.TracesToTracesStability),
21-
connector.WithMetricsToMetrics(createMetricsToMetrics, metadata.MetricsToMetricsStability),
22-
connector.WithLogsToLogs(createLogsToLogs, metadata.LogsToLogsStability),
22+
xconnector.WithTracesToTraces(createTracesToTraces, metadata.TracesToTracesStability),
23+
xconnector.WithMetricsToMetrics(createMetricsToMetrics, metadata.MetricsToMetricsStability),
24+
xconnector.WithLogsToLogs(createLogsToLogs, metadata.LogsToLogsStability),
25+
xconnector.WithProfilesToProfiles(createProfilesToProfiles, metadata.ProfilesToProfilesStability),
2326
)
2427
}
2528

@@ -60,13 +63,24 @@ func createLogsToLogs(
6063
return &forward{Logs: nextConsumer}, nil
6164
}
6265

66+
// createProfilesToProfiles creates a profile receiver based on provided config.
67+
func createProfilesToProfiles(
68+
_ context.Context,
69+
_ connector.Settings,
70+
_ component.Config,
71+
nextConsumer xconsumer.Profiles,
72+
) (xconnector.Profiles, error) {
73+
return &forward{Profiles: nextConsumer}, nil
74+
}
75+
6376
// forward is used to pass signals directly from one pipeline to another.
6477
// This is useful when there is a need to replicate data and process it in more
6578
// than one way. It can also be used to join pipelines together.
6679
type forward struct {
6780
consumer.Traces
6881
consumer.Metrics
6982
consumer.Logs
83+
xconsumer.Profiles
7084
component.StartFunc
7185
component.ShutdownFunc
7286
}

connector/forwardconnector/forward_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"go.opentelemetry.io/collector/consumer/consumertest"
1515
"go.opentelemetry.io/collector/pdata/plog"
1616
"go.opentelemetry.io/collector/pdata/pmetric"
17+
"go.opentelemetry.io/collector/pdata/pprofile"
1718
"go.opentelemetry.io/collector/pdata/ptrace"
1819
)
1920

@@ -41,9 +42,15 @@ func TestForward(t *testing.T) {
4142
require.NoError(t, err)
4243
assert.NotNil(t, logsToLogs)
4344

45+
profilesSink := new(consumertest.ProfilesSink)
46+
profilesToProfiles, err := f.CreateProfilesToProfiles(ctx, set, cfg, profilesSink)
47+
require.NoError(t, err)
48+
assert.NotNil(t, profilesToProfiles)
49+
4450
assert.NoError(t, tracesToTraces.Start(ctx, host))
4551
assert.NoError(t, metricsToMetrics.Start(ctx, host))
4652
assert.NoError(t, logsToLogs.Start(ctx, host))
53+
assert.NoError(t, profilesToProfiles.Start(ctx, host))
4754

4855
assert.NoError(t, tracesToTraces.ConsumeTraces(ctx, ptrace.NewTraces()))
4956

@@ -54,11 +61,15 @@ func TestForward(t *testing.T) {
5461
assert.NoError(t, logsToLogs.ConsumeLogs(ctx, plog.NewLogs()))
5562
assert.NoError(t, logsToLogs.ConsumeLogs(ctx, plog.NewLogs()))
5663

64+
assert.NoError(t, profilesToProfiles.ConsumeProfiles(ctx, pprofile.NewProfiles()))
65+
5766
assert.NoError(t, tracesToTraces.Shutdown(ctx))
5867
assert.NoError(t, metricsToMetrics.Shutdown(ctx))
5968
assert.NoError(t, logsToLogs.Shutdown(ctx))
69+
assert.NoError(t, profilesToProfiles.Shutdown(ctx))
6070

6171
assert.Len(t, tracesSink.AllTraces(), 1)
6272
assert.Len(t, metricsSink.AllMetrics(), 2)
6373
assert.Len(t, logsSink.AllLogs(), 3)
74+
assert.Len(t, profilesSink.AllProfiles(), 1)
6475
}

connector/forwardconnector/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ require (
99
go.opentelemetry.io/collector/confmap v1.45.0
1010
go.opentelemetry.io/collector/connector v0.139.0
1111
go.opentelemetry.io/collector/connector/connectortest v0.139.0
12+
go.opentelemetry.io/collector/connector/xconnector v0.139.0
1213
go.opentelemetry.io/collector/consumer v1.45.0
1314
go.opentelemetry.io/collector/consumer/consumertest v0.139.0
15+
go.opentelemetry.io/collector/consumer/xconsumer v0.139.0
1416
go.opentelemetry.io/collector/pdata v1.45.0
17+
go.opentelemetry.io/collector/pdata/pprofile v0.139.0
1518
go.opentelemetry.io/collector/pipeline v1.45.0
1619
go.uber.org/goleak v1.3.0
1720
)
@@ -34,11 +37,8 @@ require (
3437
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
3538
github.com/pmezard/go-difflib v1.0.0 // indirect
3639
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
37-
go.opentelemetry.io/collector/connector/xconnector v0.139.0 // indirect
38-
go.opentelemetry.io/collector/consumer/xconsumer v0.139.0 // indirect
3940
go.opentelemetry.io/collector/featuregate v1.45.0 // indirect
4041
go.opentelemetry.io/collector/internal/fanoutconsumer v0.139.0 // indirect
41-
go.opentelemetry.io/collector/pdata/pprofile v0.139.0 // indirect
4242
go.opentelemetry.io/collector/pipeline/xpipeline v0.139.0 // indirect
4343
go.opentelemetry.io/otel v1.38.0 // indirect
4444
go.opentelemetry.io/otel/metric v1.38.0 // indirect

connector/forwardconnector/internal/metadata/generated_status.go

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

connector/forwardconnector/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ status:
55
disable_codecov_badge: true
66
class: connector
77
stability:
8+
development: [profiles_to_profiles]
89
beta: [traces_to_traces, metrics_to_metrics, logs_to_logs]
910
distributions: [core, contrib, k8s]

0 commit comments

Comments
 (0)