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

[extension/encoding] support skywalkingencoding extension #36968

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6d856ad
rebase upstream
JaredTan95 Dec 27, 2024
c6b87bf
works
JaredTan95 Dec 26, 2024
1babb63
add UT
JaredTan95 Dec 27, 2024
155d627
rebase upstream
JaredTan95 Dec 27, 2024
b01b7a1
rebase upstream
JaredTan95 Dec 27, 2024
3cf32a7
fix builder-config
JaredTan95 Dec 27, 2024
d8be49c
add changelog
JaredTan95 Dec 27, 2024
5b73339
add docs
JaredTan95 Dec 27, 2024
769d95b
remove unused files.
JaredTan95 Dec 27, 2024
0db3300
update codeonwners
JaredTan95 Dec 27, 2024
7202adf
update codeonwners
JaredTan95 Dec 27, 2024
707249e
fix ci
JaredTan95 Dec 27, 2024
c8d7294
fix govulncheck
JaredTan95 Dec 27, 2024
47b74b2
fix ut
JaredTan95 Dec 27, 2024
0192271
fix lint
JaredTan95 Dec 27, 2024
cd3d12d
fix crosslink
JaredTan95 Dec 27, 2024
31ab139
revert CODEOWNERS update
JaredTan95 Dec 30, 2024
9e71e46
Merge branch 'main' into skywalkingencoding_extension
JaredTan95 Dec 30, 2024
22c14f7
Merge branch 'main' into skywalkingencoding_extension
JaredTan95 Dec 31, 2024
f69ce38
revert CODEOWNER in metadata.yaml update
JaredTan95 Jan 3, 2025
a41251f
Merge branch 'skywalkingencoding_extension' of https://github.com/Jar…
JaredTan95 Jan 3, 2025
4a70980
Merge branch 'main' into skywalkingencoding_extension
JaredTan95 Jan 6, 2025
bc148dd
Merge branch 'main' into skywalkingencoding_extension
JaredTan95 Jan 7, 2025
7f8a860
polish
JaredTan95 Jan 8, 2025
5096705
Merge branch 'main' into skywalkingencoding_extension
JaredTan95 Jan 8, 2025
679934a
add skywalkingencodingextension in builder-config.yaml
JaredTan95 Jan 8, 2025
be3fa00
fix ci
JaredTan95 Jan 8, 2025
f4dd596
fix docs
JaredTan95 Jan 8, 2025
feac52b
fix lint
JaredTan95 Jan 8, 2025
80a2551
update CODEOWNERS
JaredTan95 Jan 9, 2025
4f92871
Merge branch 'main' into skywalkingencoding_extension
JaredTan95 Jan 9, 2025
57821d7
Merge branch 'main' into skywalkingencoding_extension
JaredTan95 Jan 10, 2025
263ad93
Merge branch 'main' into skywalkingencoding_extension
JaredTan95 Jan 10, 2025
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
27 changes: 27 additions & 0 deletions .chloggen/support_skywalking_encoding_extension.yaml
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: []
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ extension/encoding/avrologencodingextension/ @open-telemetry/collector-cont
extension/encoding/jaegerencodingextension/ @open-telemetry/collector-contrib-approvers @MovieStoreGuy @atoulme
extension/encoding/jsonlogencodingextension/ @open-telemetry/collector-contrib-approvers @VihasMakwana @atoulme
extension/encoding/otlpencodingextension/ @open-telemetry/collector-contrib-approvers @dao-jun @VihasMakwana
extension/encoding/skywalkingencodingextension/ @open-telemetry/collector-contrib-approvers @JaredTan95
extension/encoding/textencodingextension/ @open-telemetry/collector-contrib-approvers @MovieStoreGuy @atoulme
extension/encoding/zipkinencodingextension/ @open-telemetry/collector-contrib-approvers @MovieStoreGuy @dao-jun
extension/googleclientauthextension/ @open-telemetry/collector-contrib-approvers @dashpole @aabmass @jsuereth @punya @psx95
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ body:
- extension/encoding/jaegerencoding
- extension/encoding/jsonlogencoding
- extension/encoding/otlpencoding
- extension/encoding/skywalkingencoding
- extension/encoding/textencoding
- extension/encoding/zipkinencoding
- extension/googleclientauth
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ body:
- extension/encoding/jaegerencoding
- extension/encoding/jsonlogencoding
- extension/encoding/otlpencoding
- extension/encoding/skywalkingencoding
- extension/encoding/textencoding
- extension/encoding/zipkinencoding
- extension/googleclientauth
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ body:
- extension/encoding/jaegerencoding
- extension/encoding/jsonlogencoding
- extension/encoding/otlpencoding
- extension/encoding/skywalkingencoding
- extension/encoding/textencoding
- extension/encoding/zipkinencoding
- extension/googleclientauth
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/unmaintained.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ body:
- extension/encoding/jaegerencoding
- extension/encoding/jsonlogencoding
- extension/encoding/otlpencoding
- extension/encoding/skywalkingencoding
- extension/encoding/textencoding
- extension/encoding/zipkinencoding
- extension/googleclientauth
Expand Down
2 changes: 2 additions & 0 deletions cmd/otelcontribcol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ extensions:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/jsonlogencodingextension v0.117.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/textencodingextension v0.117.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/zipkinencodingextension v0.117.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/skywalkingencodingextension v0.117.0

exporters:
- gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.117.0
Expand Down Expand Up @@ -483,6 +484,7 @@ replaces:
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/avrologencodingextension => ../../extension/encoding/avrologencodingextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/jsonlogencodingextension => ../../extension/encoding/jsonlogencodingextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/textencodingextension => ../../extension/encoding/textencodingextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/skywalkingencodingextension => ../../extension/encoding/skywalkingencodingextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/jaegerencodingextension => ../../extension/encoding/jaegerencodingextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/remotetapextension => ../../extension/remotetapextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/opampextension => ../../extension/opampextension
Expand Down
1 change: 1 addition & 0 deletions extension/encoding/skywalkingencodingextension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../../Makefile.Common
27 changes: 27 additions & 0 deletions extension/encoding/skywalkingencodingextension/README.md
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).
28 changes: 28 additions & 0 deletions extension/encoding/skywalkingencodingextension/extension.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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 {
e.unmarshaler = skywalkingProtobufTrace{}
return nil
}

func (e *skywalkingExtension) Shutdown(_ context.Context) error {
return nil
}
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)
}
})
}
}
30 changes: 30 additions & 0 deletions extension/encoding/skywalkingencodingextension/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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{}, nil
}

func createDefaultConfig() component.Config {
return nil
}
44 changes: 44 additions & 0 deletions extension/encoding/skywalkingencodingextension/go.mod
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.0
go.opentelemetry.io/collector/component/componenttest v0.117.0
go.opentelemetry.io/collector/extension v0.117.0
go.opentelemetry.io/collector/extension/extensiontest v0.117.0
go.opentelemetry.io/collector/pdata v1.23.0
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.0 // indirect
go.opentelemetry.io/collector/semconv v0.117.0 // 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.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/skywalking => ../../../pkg/translator/skywalking
Loading
Loading