Skip to content

Commit

Permalink
fix: remove marshaler
Browse files Browse the repository at this point in the history
  • Loading branch information
Vihas Splunk authored and atoulme committed Dec 23, 2023
1 parent 962d648 commit 67d4811
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .chloggen/add-json-jaeger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ component: encoding/jaegerencodingextension
note: Add support for JSON protocol for jaeger codec

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: []
issues: [6272]

# (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.
Expand Down
13 changes: 1 addition & 12 deletions extension/encoding/jaegerencodingextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package jaegerencodingextension // import "github.com/open-telemetry/opentelemet

import (
"context"
"errors"
"fmt"

"go.opentelemetry.io/collector/component"
Expand All @@ -16,32 +15,22 @@ import (

var _ encoding.TracesUnmarshalerExtension = &jaegerExtension{}
var _ ptrace.Unmarshaler = &jaegerExtension{}
var _ ptrace.Marshaler = &jaegerExtension{}

type jaegerExtension struct {
config *Config
unmarshaler ptrace.Unmarshaler
marshaler ptrace.Marshaler
}

func (e *jaegerExtension) UnmarshalTraces(buf []byte) (ptrace.Traces, error) {
return e.unmarshaler.UnmarshalTraces(buf)
}

func (e *jaegerExtension) MarshalTraces(td ptrace.Traces) ([]byte, error) {
if e.marshaler == nil {
return nil, errors.New("unsupported encoding")
}
return e.marshaler.MarshalTraces(td)
}

func (e *jaegerExtension) Start(_ context.Context, _ component.Host) error {
e.marshaler = nil
switch e.config.Protocol {
case JaegerProtocolProtobuf:
e.unmarshaler = jaegerProtobufTrace{}
case JaegerProtocolJSON:
e.unmarshaler = jaegerJsonTrace{}
e.unmarshaler = jaegerJSONTrace{}
default:
return fmt.Errorf("unsupported protocol: %q", e.config.Protocol)
}
Expand Down
4 changes: 2 additions & 2 deletions extension/encoding/jaegerencodingextension/jaeger.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ func (j jaegerProtobufTrace) UnmarshalTraces(buf []byte) (ptrace.Traces, error)
return jaegerSpanToTraces(span)
}

type jaegerJsonTrace struct {
type jaegerJSONTrace struct {
}

func (j jaegerJsonTrace) UnmarshalTraces(buf []byte) (ptrace.Traces, error) {
func (j jaegerJSONTrace) UnmarshalTraces(buf []byte) (ptrace.Traces, error) {
span := &jaegerproto.Span{}
err := jsonpb.Unmarshal(bytes.NewReader(buf), span)
if err != nil {
Expand Down

0 comments on commit 67d4811

Please sign in to comment.