forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[extension/encoding] support skywalkingencoding extension (open-telem…
…etry#36968) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description The `kafkareceiver` supports `jaeger` and `zipkin` protocol traces, and can also receive skywalkng traces via `skywalkingreceiver`. From the practical use of skywalking, we often use kafka to host large-scale traces data. However, `kafka receiver` does not support `skywalking encoding` currently. with this PR, we can fectch skywalking traces and parse it into `otlp` traces: ```yaml receivers: otlp: protocols: grpc: endpoint: 0.0.0.0:4317 kafka: encoding: skywalking_encoding topic: skywalking-segments brokers: - "localhost:9092" resolve_canonical_bootstrap_servers_only: true client_id: otel-collector group_id: otel-collector metadata: retry: max: 10 backoff: 5s exporters: debug: processors: batch: extensions: health_check: pprof: endpoint: :1888 zpages: endpoint: :55679 skywalking_encoding: service: extensions: [pprof, zpages, skywalking_encoding, health_check] pipelines: traces: receivers: [kafka] processors: [batch] exporters: [debug] ``` <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#28693 <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> --------- Signed-off-by: Jared Tan <[email protected]> Co-authored-by: Tyler Helmuth <[email protected]>
- Loading branch information
1 parent
93c4303
commit a357b6e
Showing
21 changed files
with
695 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: new_component | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: extension/skywalkingencodingextension | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Support skywalking_encoding extension for skywalking traces. | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [28693] | ||
|
||
# (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: | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# 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: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../../Makefile.Common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Skywalking encoding extension | ||
|
||
<!-- status autogenerated section --> | ||
| Status | | | ||
| ------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| Stability | [alpha] | | ||
| Distributions | [] | | ||
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aextension%2Fskywalkingencodingextension%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aextension%2Fskywalkingencodingextension) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aextension%2Fskywalkingencodingextension%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aextension%2Fskywalkingencodingextension) | | ||
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@JaredTan95](https://www.github.com/JaredTan95) | | ||
|
||
[alpha]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#alpha | ||
<!-- end autogenerated section --> | ||
|
||
The `Skywalking` encoding extension is used to unmarshal Apache Skywalking segment traces. Marshalling is not supported. | ||
|
||
## Example configuration | ||
|
||
```yaml | ||
extensions: | ||
skywalking_encoding: | ||
|
||
receivers: | ||
kafka: | ||
encoding: skywalking_encoding | ||
``` | ||
The detailed sample configurations [here](./testdata). |
27 changes: 27 additions & 0 deletions
27
extension/encoding/skywalkingencodingextension/extension.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package skywalkingencodingextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/skywalkingencodingextension" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
) | ||
|
||
type skywalkingExtension struct { | ||
unmarshaler ptrace.Unmarshaler | ||
} | ||
|
||
func (e *skywalkingExtension) UnmarshalTraces(buf []byte) (ptrace.Traces, error) { | ||
return e.unmarshaler.UnmarshalTraces(buf) | ||
} | ||
|
||
func (e *skywalkingExtension) Start(_ context.Context, _ component.Host) error { | ||
return nil | ||
} | ||
|
||
func (e *skywalkingExtension) Shutdown(_ context.Context) error { | ||
return nil | ||
} |
47 changes: 47 additions & 0 deletions
47
extension/encoding/skywalkingencodingextension/extension_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package skywalkingencodingextension | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"go.opentelemetry.io/collector/component/componenttest" | ||
"go.opentelemetry.io/collector/extension" | ||
"go.opentelemetry.io/collector/extension/extensiontest" | ||
) | ||
|
||
func TestExtension_Start(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
getExtension func() (extension.Extension, error) | ||
expectedErr string | ||
}{ | ||
{ | ||
name: "skywalkingProtobuf", | ||
getExtension: func() (extension.Extension, error) { | ||
factory := NewFactory() | ||
cfg := factory.CreateDefaultConfig() | ||
return factory.Create(context.Background(), extensiontest.NewNopSettings(), cfg) | ||
}, | ||
}, | ||
} | ||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
ext, err := test.getExtension() | ||
if test.expectedErr != "" && err != nil { | ||
require.ErrorContains(t, err, test.expectedErr) | ||
} else { | ||
require.NoError(t, err) | ||
} | ||
err = ext.Start(context.Background(), componenttest.NewNopHost()) | ||
if test.expectedErr != "" && err != nil { | ||
require.ErrorContains(t, err, test.expectedErr) | ||
} else { | ||
require.NoError(t, err) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package skywalkingencodingextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/skywalkingencodingextension" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/extension" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/skywalkingencodingextension/internal/metadata" | ||
) | ||
|
||
func NewFactory() extension.Factory { | ||
return extension.NewFactory( | ||
metadata.Type, | ||
createDefaultConfig, | ||
createExtension, | ||
metadata.ExtensionStability, | ||
) | ||
} | ||
|
||
func createExtension(_ context.Context, _ extension.Settings, _ component.Config) (extension.Extension, error) { | ||
return &skywalkingExtension{ | ||
unmarshaler: skywalkingProtobufTrace{}, | ||
}, nil | ||
} | ||
|
||
func createDefaultConfig() component.Config { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/skywalkingencodingextension | ||
|
||
go 1.22.0 | ||
|
||
require ( | ||
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/skywalking v0.117.0 | ||
github.com/stretchr/testify v1.10.0 | ||
go.opentelemetry.io/collector/component v0.117.1-0.20250114172347-71aae791d7f8 | ||
go.opentelemetry.io/collector/component/componenttest v0.117.0 | ||
go.opentelemetry.io/collector/extension v0.117.1-0.20250114172347-71aae791d7f8 | ||
go.opentelemetry.io/collector/extension/extensiontest v0.117.0 | ||
go.opentelemetry.io/collector/pdata v1.23.1-0.20250114172347-71aae791d7f8 | ||
google.golang.org/protobuf v1.36.2 | ||
skywalking.apache.org/repo/goapi v0.0.0-20240104145220-ba7202308dd4 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
github.com/go-logr/logr v1.4.2 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/google/uuid v1.6.0 // 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.1-0.20181226105442-5d4384ee4fb2 // indirect | ||
go.opentelemetry.io/collector/config/configtelemetry v0.117.1-0.20250114172347-71aae791d7f8 // indirect | ||
go.opentelemetry.io/collector/semconv v0.117.1-0.20250114172347-71aae791d7f8 // indirect | ||
go.opentelemetry.io/otel v1.32.0 // indirect | ||
go.opentelemetry.io/otel/metric v1.32.0 // indirect | ||
go.opentelemetry.io/otel/sdk v1.32.0 // indirect | ||
go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.32.0 // indirect | ||
go.uber.org/multierr v1.11.0 // indirect | ||
go.uber.org/zap v1.27.0 // indirect | ||
golang.org/x/net v0.33.0 // indirect | ||
golang.org/x/sys v0.28.0 // indirect | ||
golang.org/x/text v0.21.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect | ||
google.golang.org/grpc v1.69.4 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) | ||
|
||
replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/skywalking => ../../../pkg/translator/skywalking |
Oops, something went wrong.