Skip to content

Commit

Permalink
Rename internal/otlp files, avoid duplicate initialization (#3317)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored May 26, 2021
1 parent 6fa269a commit 5cdc777
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions internal/otlp/decoder.go → internal/otlp/json_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,23 @@ type decoder struct {
delegate jsonpb.Unmarshaler
}

func newDecoder() *decoder {
return &decoder{delegate: jsonpb.Unmarshaler{}}
}

// NewJSONTracesDecoder returns a serializer.TracesDecoder to decode from OTLP json bytes.
func NewJSONTracesDecoder() model.TracesDecoder {
return &decoder{delegate: jsonpb.Unmarshaler{}}
return newDecoder()
}

// NewJSONMetricsDecoder returns a serializer.MetricsDecoder to decode from OTLP json bytes.
func NewJSONMetricsDecoder() model.MetricsDecoder {
return &decoder{delegate: jsonpb.Unmarshaler{}}
return newDecoder()
}

// NewJSONLogsDecoder returns a serializer.LogsDecoder to decode from OTLP json bytes.
func NewJSONLogsDecoder() model.LogsDecoder {
return &decoder{delegate: jsonpb.Unmarshaler{}}
return newDecoder()
}

func (d *decoder) DecodeLogs(buf []byte) (interface{}, error) {
Expand Down
10 changes: 7 additions & 3 deletions internal/otlp/encoder.go → internal/otlp/json_encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,23 @@ type encoder struct {
delegate jsonpb.Marshaler
}

func newEncoder() *encoder {
return &encoder{delegate: jsonpb.Marshaler{}}
}

// NewJSONTracesEncoder returns a serializer.TracesUnmarshaler to encode to OTLP json bytes.
func NewJSONTracesEncoder() model.TracesEncoder {
return &encoder{delegate: jsonpb.Marshaler{}}
return newEncoder()
}

// NewJSONMetricsEncoder returns a serializer.MetricsEncoder to encode to OTLP json bytes.
func NewJSONMetricsEncoder() model.MetricsEncoder {
return &encoder{delegate: jsonpb.Marshaler{}}
return newEncoder()
}

// NewJSONLogsEncoder returns a serializer.LogsEncoder to encode to OTLP json bytes.
func NewJSONLogsEncoder() model.LogsEncoder {
return &encoder{delegate: jsonpb.Marshaler{}}
return newEncoder()
}

func (e *encoder) EncodeLogs(modelData interface{}) ([]byte, error) {
Expand Down

0 comments on commit 5cdc777

Please sign in to comment.