Skip to content

Commit

Permalink
Move internal/otlp to model/otlp
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed Jun 28, 2021
1 parent 75ebb88 commit 7b1a530
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 58 deletions.
8 changes: 4 additions & 4 deletions exporter/fileexporter/file_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/internal/otlp"
otlp2 "go.opentelemetry.io/collector/model/otlp"
"go.opentelemetry.io/collector/model/pdata"
)

// Marshaler configuration used for marhsaling Protobuf to JSON.
var tracesMarshaler = otlp.NewJSONTracesMarshaler()
var metricsMarshaler = otlp.NewJSONMetricsMarshaler()
var logsMarshaler = otlp.NewJSONLogsMarshaler()
var tracesMarshaler = otlp2.NewJSONTracesMarshaler()
var metricsMarshaler = otlp2.NewJSONMetricsMarshaler()
var logsMarshaler = otlp2.NewJSONLogsMarshaler()

// fileExporter is the implementation of file exporter that writes telemetry data to a file
// in Protobuf-JSON format.
Expand Down
8 changes: 4 additions & 4 deletions exporter/fileexporter/file_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/internal/otlp"
"go.opentelemetry.io/collector/internal/testdata"
otlp2 "go.opentelemetry.io/collector/model/otlp"
)

func TestFileTracesExporter(t *testing.T) {
Expand All @@ -37,7 +37,7 @@ func TestFileTracesExporter(t *testing.T) {
assert.NoError(t, fe.ConsumeTraces(context.Background(), td))
assert.NoError(t, fe.Shutdown(context.Background()))

unmarshaler := otlp.NewJSONTracesUnmarshaler()
unmarshaler := otlp2.NewJSONTracesUnmarshaler()
buf, err := ioutil.ReadFile(fe.path)
assert.NoError(t, err)
got, err := unmarshaler.UnmarshalTraces(buf)
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestFileMetricsExporter(t *testing.T) {
assert.NoError(t, fe.ConsumeMetrics(context.Background(), md))
assert.NoError(t, fe.Shutdown(context.Background()))

unmarshaler := otlp.NewJSONMetricsUnmarshaler()
unmarshaler := otlp2.NewJSONMetricsUnmarshaler()
buf, err := ioutil.ReadFile(fe.path)
assert.NoError(t, err)
got, err := unmarshaler.UnmarshalMetrics(buf)
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestFileLogsExporter(t *testing.T) {
assert.NoError(t, fe.ConsumeLogs(context.Background(), ld))
assert.NoError(t, fe.Shutdown(context.Background()))

unmarshaler := otlp.NewJSONLogsUnmarshaler()
unmarshaler := otlp2.NewJSONLogsUnmarshaler()
buf, err := ioutil.ReadFile(fe.path)
assert.NoError(t, err)
got, err := unmarshaler.UnmarshalLogs(buf)
Expand Down
14 changes: 7 additions & 7 deletions exporter/kafkaexporter/kafka_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (

"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/internal/otlp"
"go.opentelemetry.io/collector/internal/testdata"
otlp2 "go.opentelemetry.io/collector/model/otlp"
"go.opentelemetry.io/collector/model/pdata"
)

Expand Down Expand Up @@ -125,7 +125,7 @@ func TestTracesPusher(t *testing.T) {

p := kafkaTracesProducer{
producer: producer,
marshaler: newPdataTracesMarshaler(otlp.NewProtobufTracesMarshaler(), defaultEncoding),
marshaler: newPdataTracesMarshaler(otlp2.NewProtobufTracesMarshaler(), defaultEncoding),
}
t.Cleanup(func() {
require.NoError(t, p.Close(context.Background()))
Expand All @@ -142,7 +142,7 @@ func TestTracesPusher_err(t *testing.T) {

p := kafkaTracesProducer{
producer: producer,
marshaler: newPdataTracesMarshaler(otlp.NewProtobufTracesMarshaler(), defaultEncoding),
marshaler: newPdataTracesMarshaler(otlp2.NewProtobufTracesMarshaler(), defaultEncoding),
logger: zap.NewNop(),
}
t.Cleanup(func() {
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestMetricsDataPusher(t *testing.T) {

p := kafkaMetricsProducer{
producer: producer,
marshaler: newPdataMetricsMarshaler(otlp.NewProtobufMetricsMarshaler(), defaultEncoding),
marshaler: newPdataMetricsMarshaler(otlp2.NewProtobufMetricsMarshaler(), defaultEncoding),
}
t.Cleanup(func() {
require.NoError(t, p.Close(context.Background()))
Expand All @@ -189,7 +189,7 @@ func TestMetricsDataPusher_err(t *testing.T) {

p := kafkaMetricsProducer{
producer: producer,
marshaler: newPdataMetricsMarshaler(otlp.NewProtobufMetricsMarshaler(), defaultEncoding),
marshaler: newPdataMetricsMarshaler(otlp2.NewProtobufMetricsMarshaler(), defaultEncoding),
logger: zap.NewNop(),
}
t.Cleanup(func() {
Expand Down Expand Up @@ -219,7 +219,7 @@ func TestLogsDataPusher(t *testing.T) {

p := kafkaLogsProducer{
producer: producer,
marshaler: newPdataLogsMarshaler(otlp.NewProtobufLogsMarshaler(), defaultEncoding),
marshaler: newPdataLogsMarshaler(otlp2.NewProtobufLogsMarshaler(), defaultEncoding),
}
t.Cleanup(func() {
require.NoError(t, p.Close(context.Background()))
Expand All @@ -236,7 +236,7 @@ func TestLogsDataPusher_err(t *testing.T) {

p := kafkaLogsProducer{
producer: producer,
marshaler: newPdataLogsMarshaler(otlp.NewProtobufLogsMarshaler(), defaultEncoding),
marshaler: newPdataLogsMarshaler(otlp2.NewProtobufLogsMarshaler(), defaultEncoding),
logger: zap.NewNop(),
}
t.Cleanup(func() {
Expand Down
8 changes: 4 additions & 4 deletions exporter/kafkaexporter/marshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package kafkaexporter
import (
"github.com/Shopify/sarama"

"go.opentelemetry.io/collector/internal/otlp"
otlp2 "go.opentelemetry.io/collector/model/otlp"
"go.opentelemetry.io/collector/model/pdata"
)

Expand Down Expand Up @@ -50,7 +50,7 @@ type LogsMarshaler interface {

// tracesMarshalers returns map of supported encodings with TracesMarshaler.
func tracesMarshalers() map[string]TracesMarshaler {
otlpPb := newPdataTracesMarshaler(otlp.NewProtobufTracesMarshaler(), defaultEncoding)
otlpPb := newPdataTracesMarshaler(otlp2.NewProtobufTracesMarshaler(), defaultEncoding)
jaegerProto := jaegerMarshaler{marshaler: jaegerProtoSpanMarshaler{}}
jaegerJSON := jaegerMarshaler{marshaler: newJaegerJSONMarshaler()}
return map[string]TracesMarshaler{
Expand All @@ -62,15 +62,15 @@ func tracesMarshalers() map[string]TracesMarshaler {

// metricsMarshalers returns map of supported encodings and MetricsMarshaler
func metricsMarshalers() map[string]MetricsMarshaler {
otlpPb := newPdataMetricsMarshaler(otlp.NewProtobufMetricsMarshaler(), defaultEncoding)
otlpPb := newPdataMetricsMarshaler(otlp2.NewProtobufMetricsMarshaler(), defaultEncoding)
return map[string]MetricsMarshaler{
otlpPb.Encoding(): otlpPb,
}
}

// logsMarshalers returns map of supported encodings and LogsMarshaler
func logsMarshalers() map[string]LogsMarshaler {
otlpPb := newPdataLogsMarshaler(otlp.NewProtobufLogsMarshaler(), defaultEncoding)
otlpPb := newPdataLogsMarshaler(otlp2.NewProtobufLogsMarshaler(), defaultEncoding)
return map[string]LogsMarshaler{
otlpPb.Encoding(): otlpPb,
}
Expand Down
8 changes: 4 additions & 4 deletions exporter/otlphttpexporter/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/internal/middleware"
"go.opentelemetry.io/collector/internal/otlp"
otlp2 "go.opentelemetry.io/collector/model/otlp"
"go.opentelemetry.io/collector/model/pdata"
)

Expand All @@ -52,9 +52,9 @@ type exporter struct {
}

var (
tracesMarshaler = otlp.NewProtobufTracesMarshaler()
metricsMarshaler = otlp.NewProtobufMetricsMarshaler()
logsMarshaler = otlp.NewProtobufLogsMarshaler()
tracesMarshaler = otlp2.NewProtobufTracesMarshaler()
metricsMarshaler = otlp2.NewProtobufMetricsMarshaler()
logsMarshaler = otlp2.NewProtobufLogsMarshaler()
)

const (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 13 additions & 13 deletions receiver/kafkareceiver/kafka_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/exporter/kafkaexporter"
"go.opentelemetry.io/collector/internal/otlp"
"go.opentelemetry.io/collector/internal/testdata"
otlp2 "go.opentelemetry.io/collector/model/otlp"
"go.opentelemetry.io/collector/model/pdata"
"go.opentelemetry.io/collector/obsreport"
)
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestTracesConsumerGroupHandler(t *testing.T) {
defer view.Unregister(views...)

c := tracesConsumerGroupHandler{
unmarshaler: newPdataTracesUnmarshaler(otlp.NewProtobufTracesUnmarshaler(), defaultEncoding),
unmarshaler: newPdataTracesUnmarshaler(otlp2.NewProtobufTracesUnmarshaler(), defaultEncoding),
logger: zap.NewNop(),
ready: make(chan bool),
nextConsumer: consumertest.NewNop(),
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestTracesConsumerGroupHandler(t *testing.T) {

func TestTracesConsumerGroupHandler_error_unmarshal(t *testing.T) {
c := tracesConsumerGroupHandler{
unmarshaler: newPdataTracesUnmarshaler(otlp.NewProtobufTracesUnmarshaler(), defaultEncoding),
unmarshaler: newPdataTracesUnmarshaler(otlp2.NewProtobufTracesUnmarshaler(), defaultEncoding),
logger: zap.NewNop(),
ready: make(chan bool),
nextConsumer: consumertest.NewNop(),
Expand All @@ -197,7 +197,7 @@ func TestTracesConsumerGroupHandler_error_unmarshal(t *testing.T) {
func TestTracesConsumerGroupHandler_error_nextConsumer(t *testing.T) {
consumerError := errors.New("failed to consume")
c := tracesConsumerGroupHandler{
unmarshaler: newPdataTracesUnmarshaler(otlp.NewProtobufTracesUnmarshaler(), defaultEncoding),
unmarshaler: newPdataTracesUnmarshaler(otlp2.NewProtobufTracesUnmarshaler(), defaultEncoding),
logger: zap.NewNop(),
ready: make(chan bool),
nextConsumer: consumertest.NewErr(consumerError),
Expand All @@ -217,7 +217,7 @@ func TestTracesConsumerGroupHandler_error_nextConsumer(t *testing.T) {

td := pdata.NewTraces()
td.ResourceSpans().AppendEmpty()
bts, err := otlp.NewProtobufTracesMarshaler().MarshalTraces(td)
bts, err := otlp2.NewProtobufTracesMarshaler().MarshalTraces(td)
require.NoError(t, err)
groupClaim.messageChan <- &sarama.ConsumerMessage{Value: bts}
close(groupClaim.messageChan)
Expand Down Expand Up @@ -315,7 +315,7 @@ func TestMetricsConsumerGroupHandler(t *testing.T) {
defer view.Unregister(views...)

c := metricsConsumerGroupHandler{
unmarshaler: newPdataMetricsUnmarshaler(otlp.NewProtobufMetricsUnmarshaler(), defaultEncoding),
unmarshaler: newPdataMetricsUnmarshaler(otlp2.NewProtobufMetricsUnmarshaler(), defaultEncoding),
logger: zap.NewNop(),
ready: make(chan bool),
nextConsumer: consumertest.NewNop(),
Expand Down Expand Up @@ -357,7 +357,7 @@ func TestMetricsConsumerGroupHandler(t *testing.T) {

func TestMetricsConsumerGroupHandler_error_unmarshal(t *testing.T) {
c := metricsConsumerGroupHandler{
unmarshaler: newPdataMetricsUnmarshaler(otlp.NewProtobufMetricsUnmarshaler(), defaultEncoding),
unmarshaler: newPdataMetricsUnmarshaler(otlp2.NewProtobufMetricsUnmarshaler(), defaultEncoding),
logger: zap.NewNop(),
ready: make(chan bool),
nextConsumer: consumertest.NewNop(),
Expand All @@ -382,7 +382,7 @@ func TestMetricsConsumerGroupHandler_error_unmarshal(t *testing.T) {
func TestMetricsConsumerGroupHandler_error_nextConsumer(t *testing.T) {
consumerError := errors.New("failed to consume")
c := metricsConsumerGroupHandler{
unmarshaler: newPdataMetricsUnmarshaler(otlp.NewProtobufMetricsUnmarshaler(), defaultEncoding),
unmarshaler: newPdataMetricsUnmarshaler(otlp2.NewProtobufMetricsUnmarshaler(), defaultEncoding),
logger: zap.NewNop(),
ready: make(chan bool),
nextConsumer: consumertest.NewErr(consumerError),
Expand All @@ -401,7 +401,7 @@ func TestMetricsConsumerGroupHandler_error_nextConsumer(t *testing.T) {
}()

ld := testdata.GenerateMetricsOneMetric()
bts, err := otlp.NewProtobufMetricsMarshaler().MarshalMetrics(ld)
bts, err := otlp2.NewProtobufMetricsMarshaler().MarshalMetrics(ld)
require.NoError(t, err)
groupClaim.messageChan <- &sarama.ConsumerMessage{Value: bts}
close(groupClaim.messageChan)
Expand Down Expand Up @@ -499,7 +499,7 @@ func TestLogsConsumerGroupHandler(t *testing.T) {
defer view.Unregister(views...)

c := logsConsumerGroupHandler{
unmarshaler: newPdataLogsUnmarshaler(otlp.NewProtobufLogsUnmarshaler(), defaultEncoding),
unmarshaler: newPdataLogsUnmarshaler(otlp2.NewProtobufLogsUnmarshaler(), defaultEncoding),
logger: zap.NewNop(),
ready: make(chan bool),
nextConsumer: consumertest.NewNop(),
Expand Down Expand Up @@ -541,7 +541,7 @@ func TestLogsConsumerGroupHandler(t *testing.T) {

func TestLogsConsumerGroupHandler_error_unmarshal(t *testing.T) {
c := logsConsumerGroupHandler{
unmarshaler: newPdataLogsUnmarshaler(otlp.NewProtobufLogsUnmarshaler(), defaultEncoding),
unmarshaler: newPdataLogsUnmarshaler(otlp2.NewProtobufLogsUnmarshaler(), defaultEncoding),
logger: zap.NewNop(),
ready: make(chan bool),
nextConsumer: consumertest.NewNop(),
Expand All @@ -566,7 +566,7 @@ func TestLogsConsumerGroupHandler_error_unmarshal(t *testing.T) {
func TestLogsConsumerGroupHandler_error_nextConsumer(t *testing.T) {
consumerError := errors.New("failed to consume")
c := logsConsumerGroupHandler{
unmarshaler: newPdataLogsUnmarshaler(otlp.NewProtobufLogsUnmarshaler(), defaultEncoding),
unmarshaler: newPdataLogsUnmarshaler(otlp2.NewProtobufLogsUnmarshaler(), defaultEncoding),
logger: zap.NewNop(),
ready: make(chan bool),
nextConsumer: consumertest.NewErr(consumerError),
Expand All @@ -585,7 +585,7 @@ func TestLogsConsumerGroupHandler_error_nextConsumer(t *testing.T) {
}()

ld := testdata.GenerateLogsOneLogRecord()
bts, err := otlp.NewProtobufLogsMarshaler().MarshalLogs(ld)
bts, err := otlp2.NewProtobufLogsMarshaler().MarshalLogs(ld)
require.NoError(t, err)
groupClaim.messageChan <- &sarama.ConsumerMessage{Value: bts}
close(groupClaim.messageChan)
Expand Down
8 changes: 4 additions & 4 deletions receiver/kafkareceiver/pdata_unmarshaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ import (

"github.com/stretchr/testify/assert"

"go.opentelemetry.io/collector/internal/otlp"
otlp2 "go.opentelemetry.io/collector/model/otlp"
)

func TestNewPdataTracesUnmarshaler(t *testing.T) {
um := newPdataTracesUnmarshaler(otlp.NewProtobufTracesUnmarshaler(), "test")
um := newPdataTracesUnmarshaler(otlp2.NewProtobufTracesUnmarshaler(), "test")
assert.Equal(t, "test", um.Encoding())
}

func TestNewPdataMetricsUnmarshaler(t *testing.T) {
um := newPdataMetricsUnmarshaler(otlp.NewProtobufMetricsUnmarshaler(), "test")
um := newPdataMetricsUnmarshaler(otlp2.NewProtobufMetricsUnmarshaler(), "test")
assert.Equal(t, "test", um.Encoding())
}

func TestNewPdataLogsUnmarshaler(t *testing.T) {
um := newPdataLogsUnmarshaler(otlp.NewProtobufLogsUnmarshaler(), "test")
um := newPdataLogsUnmarshaler(otlp2.NewProtobufLogsUnmarshaler(), "test")
assert.Equal(t, "test", um.Encoding())
}
8 changes: 4 additions & 4 deletions receiver/kafkareceiver/unmarshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package kafkareceiver

import (
"go.opentelemetry.io/collector/internal/otlp"
otlp2 "go.opentelemetry.io/collector/model/otlp"
"go.opentelemetry.io/collector/model/pdata"
"go.opentelemetry.io/collector/translator/trace/zipkinv1"
"go.opentelemetry.io/collector/translator/trace/zipkinv2"
Expand Down Expand Up @@ -50,7 +50,7 @@ type LogsUnmarshaler interface {

// defaultTracesUnmarshalers returns map of supported encodings with TracesUnmarshaler.
func defaultTracesUnmarshalers() map[string]TracesUnmarshaler {
otlpPb := newPdataTracesUnmarshaler(otlp.NewProtobufTracesUnmarshaler(), defaultEncoding)
otlpPb := newPdataTracesUnmarshaler(otlp2.NewProtobufTracesUnmarshaler(), defaultEncoding)
jaegerProto := jaegerProtoSpanUnmarshaler{}
jaegerJSON := jaegerJSONSpanUnmarshaler{}
zipkinProto := newPdataTracesUnmarshaler(zipkinv2.NewProtobufTracesUnmarshaler(false, false), "zipkin_proto")
Expand All @@ -67,14 +67,14 @@ func defaultTracesUnmarshalers() map[string]TracesUnmarshaler {
}

func defaultMetricsUnmarshalers() map[string]MetricsUnmarshaler {
otlpPb := newPdataMetricsUnmarshaler(otlp.NewProtobufMetricsUnmarshaler(), defaultEncoding)
otlpPb := newPdataMetricsUnmarshaler(otlp2.NewProtobufMetricsUnmarshaler(), defaultEncoding)
return map[string]MetricsUnmarshaler{
otlpPb.Encoding(): otlpPb,
}
}

func defaultLogsUnmarshalers() map[string]LogsUnmarshaler {
otlpPb := newPdataLogsUnmarshaler(otlp.NewProtobufLogsUnmarshaler(), defaultEncoding)
otlpPb := newPdataLogsUnmarshaler(otlp2.NewProtobufLogsUnmarshaler(), defaultEncoding)
return map[string]LogsUnmarshaler{
otlpPb.Encoding(): otlpPb,
}
Expand Down
14 changes: 7 additions & 7 deletions receiver/otlpreceiver/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/internal/otlp"
otlp2 "go.opentelemetry.io/collector/model/otlp"
"go.opentelemetry.io/collector/model/otlpgrpc"
"go.opentelemetry.io/collector/receiver/otlpreceiver/internal/logs"
"go.opentelemetry.io/collector/receiver/otlpreceiver/internal/metrics"
Expand Down Expand Up @@ -182,8 +182,8 @@ func (r *otlpReceiver) Shutdown(ctx context.Context) error {
return err
}

var tracesPbUnmarshaler = otlp.NewProtobufTracesUnmarshaler()
var tracesJSONUnmarshaler = otlp.NewJSONTracesUnmarshaler()
var tracesPbUnmarshaler = otlp2.NewProtobufTracesUnmarshaler()
var tracesJSONUnmarshaler = otlp2.NewJSONTracesUnmarshaler()

func (r *otlpReceiver) registerTraceConsumer(tc consumer.Traces) error {
if tc == nil {
Expand All @@ -209,8 +209,8 @@ func (r *otlpReceiver) registerTraceConsumer(tc consumer.Traces) error {
return nil
}

var metricsPbUnmarshaler = otlp.NewProtobufMetricsUnmarshaler()
var metricsJSONUnmarshaler = otlp.NewJSONMetricsUnmarshaler()
var metricsPbUnmarshaler = otlp2.NewProtobufMetricsUnmarshaler()
var metricsJSONUnmarshaler = otlp2.NewJSONMetricsUnmarshaler()

func (r *otlpReceiver) registerMetricsConsumer(mc consumer.Metrics) error {
if mc == nil {
Expand All @@ -228,8 +228,8 @@ func (r *otlpReceiver) registerMetricsConsumer(mc consumer.Metrics) error {
return nil
}

var logsPbUnmarshaler = otlp.NewProtobufLogsUnmarshaler()
var logsJSONUnmarshaler = otlp.NewJSONLogsUnmarshaler()
var logsPbUnmarshaler = otlp2.NewProtobufLogsUnmarshaler()
var logsJSONUnmarshaler = otlp2.NewJSONLogsUnmarshaler()

func (r *otlpReceiver) registerLogsConsumer(lc consumer.Logs) error {
if lc == nil {
Expand Down
Loading

0 comments on commit 7b1a530

Please sign in to comment.