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 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 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
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: []
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ extension/awsproxy/ @open-telemetry/collector-cont
extension/basicauthextension/ @open-telemetry/collector-contrib-approvers @jpkrohling @frzifus
extension/bearertokenauthextension/ @open-telemetry/collector-contrib-approvers @jpkrohling @frzifus
extension/cgroupruntimeextension/ @open-telemetry/collector-contrib-approvers @mx-psi @rogercoll
extension/encoding/ @open-telemetry/collector-contrib-approvers @atoulme @dao-jun @dmitryax @MovieStoreGuy @VihasMakwana
extension/encoding/ @open-telemetry/collector-contrib-approvers @atoulme @dao-jun @dmitryax @MovieStoreGuy @VihasMakwana @JaredTan95
JaredTan95 marked this conversation as resolved.
Show resolved Hide resolved
extension/encoding/avrologencodingextension/ @open-telemetry/collector-contrib-approvers @thmshmm
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 @@ -47,6 +47,7 @@ extensions:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/jsonlogencodingextension v0.116.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/textencodingextension v0.116.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/zipkinencodingextension v0.116.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/skywalkingencodingextension v0.116.0

exporters:
- gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.116.1-0.20241220212031-7c2639723f67
Expand Down Expand Up @@ -481,6 +482,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
2 changes: 1 addition & 1 deletion extension/encoding/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
status:
codeowners:
active: [atoulme, dao-jun, dmitryax, MovieStoreGuy, VihasMakwana]
active: [atoulme, dao-jun, dmitryax, MovieStoreGuy, VihasMakwana, JaredTan95]
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
28 changes: 28 additions & 0 deletions extension/encoding/skywalkingencodingextension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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:
protocol: skywalking_proto

receivers:
kafka:
encoding: skywalking_encoding
```

The full list of settings exposed for this receiver are documented [here](./config.go) with detailed sample configurations [here](./testdata).
18 changes: 18 additions & 0 deletions extension/encoding/skywalkingencodingextension/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package skywalkingencodingextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/skywalkingencodingextension"
import (
"fmt"
)

type Config struct {
Protocol string `mapstructure:"protocol"`
}

func (c *Config) Validate() error {
if c.Protocol != skywalkingProto {
return fmt.Errorf("unsupported protocol: %q", c.Protocol)
}
return nil
}
17 changes: 17 additions & 0 deletions extension/encoding/skywalkingencodingextension/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package skywalkingencodingextension

import (
"testing"

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

func TestValidate(t *testing.T) {
c := &Config{}
assert.Error(t, c.Validate(), "ex")
c.Protocol = skywalkingProto
assert.NoError(t, c.Validate())
}
33 changes: 33 additions & 0 deletions extension/encoding/skywalkingencodingextension/extension.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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"
)

const (
skywalkingProto = "skywalking_proto"
)

type skywalkingExtension struct {
config *Config
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,48 @@
// 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()
cfg.(*Config).Protocol = "skywalking_protocol"
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)
}
})
}
}
32 changes: 32 additions & 0 deletions extension/encoding/skywalkingencodingextension/factory.go
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, config component.Config) (extension.Extension, error) {
return &skywalkingExtension{
config: config.(*Config),
}, nil
}

func createDefaultConfig() component.Config {
return &Config{Protocol: skywalkingProto}
}
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.116.0
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/collector/component v0.116.1-0.20241220212031-7c2639723f67
go.opentelemetry.io/collector/component/componenttest v0.116.0
go.opentelemetry.io/collector/extension v0.116.1-0.20241220212031-7c2639723f67
go.opentelemetry.io/collector/extension/extensiontest v0.116.0
go.opentelemetry.io/collector/pdata v1.22.1-0.20241220212031-7c2639723f67
google.golang.org/protobuf v1.36.0
skywalking.apache.org/repo/goapi v0.0.0-20241129131257-944118bb91b8
)

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.116.1-0.20241220212031-7c2639723f67 // indirect
go.opentelemetry.io/collector/semconv v0.116.1-0.20241220212031-7c2639723f67 // 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.0 // 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