Skip to content

Commit

Permalink
Remove usages of deprecated pdata module that were added recently (#9689
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dmitryax authored May 2, 2022
1 parent 8b948ed commit 5308e2b
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 103 deletions.
10 changes: 6 additions & 4 deletions processor/schemaprocessor/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/model/pdata"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/ptrace"
"go.uber.org/zap"
)

Expand All @@ -44,15 +46,15 @@ func newTransformer(
}, nil
}

func (t transformer) processLogs(ctx context.Context, ld pdata.Logs) (pdata.Logs, error) {
func (t transformer) processLogs(ctx context.Context, ld plog.Logs) (plog.Logs, error) {
return ld, nil
}

func (t transformer) processMetrics(ctx context.Context, md pdata.Metrics) (pdata.Metrics, error) {
func (t transformer) processMetrics(ctx context.Context, md pmetric.Metrics) (pmetric.Metrics, error) {
return md, nil
}

func (t transformer) processTraces(ctx context.Context, td pdata.Traces) (pdata.Traces, error) {
func (t transformer) processTraces(ctx context.Context, td ptrace.Traces) (ptrace.Traces, error) {
return td, nil
}

Expand Down
14 changes: 8 additions & 6 deletions processor/schemaprocessor/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/model/pdata"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/ptrace"
"go.uber.org/zap/zaptest"
)
Expand Down Expand Up @@ -61,7 +63,7 @@ func TestTransformerProcessing(t *testing.T) {

trans := newTestTransformer(t)
t.Run("metrics", func(t *testing.T) {
in := pdata.NewMetrics()
in := pmetric.NewMetrics()
in.ResourceMetrics().AppendEmpty()
in.ResourceMetrics().At(0).SetSchemaUrl("http://opentelemetry.io/schemas/1.9.0")
in.ResourceMetrics().At(0).ScopeMetrics().AppendEmpty()
Expand All @@ -77,15 +79,15 @@ func TestTransformerProcessing(t *testing.T) {
})

t.Run("traces", func(t *testing.T) {
in := pdata.NewTraces()
in := ptrace.NewTraces()
in.ResourceSpans().AppendEmpty()
in.ResourceSpans().At(0).SetSchemaUrl("http://opentelemetry.io/schemas/1.9.0")
in.ResourceSpans().At(0).ScopeSpans().AppendEmpty()
s := in.ResourceSpans().At(0).ScopeSpans().At(0).Spans().AppendEmpty()
s.SetName("http.request")
s.SetKind(ptrace.SpanKindConsumer)
s.SetSpanID(pdata.NewSpanID([8]byte{0, 1, 2, 3, 4, 5, 6, 7}))
s.SetTraceState(pdata.TraceStateEmpty)
s.SetSpanID(pcommon.NewSpanID([8]byte{0, 1, 2, 3, 4, 5, 6, 7}))
s.SetTraceState(ptrace.TraceStateEmpty)
s.CopyTo(in.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0))

out, err := trans.processTraces(context.Background(), in)
Expand All @@ -94,7 +96,7 @@ func TestTransformerProcessing(t *testing.T) {
})

t.Run("logs", func(t *testing.T) {
in := pdata.NewLogs()
in := plog.NewLogs()
in.ResourceLogs().AppendEmpty()
in.ResourceLogs().At(0).SetSchemaUrl("http://opentelemetry.io/schemas/1.9.0")
in.ResourceLogs().At(0).ScopeLogs().AppendEmpty()
Expand Down
14 changes: 9 additions & 5 deletions receiver/saphanareceiver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/model/pdata"
"go.opentelemetry.io/collector/pdata/pcommon"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/saphanareceiver/internal/metadata"
)
Expand Down Expand Up @@ -147,13 +147,15 @@ func TestSimpleQueryOutput(t *testing.T) {
orderedStats: []queryStat{
{
key: "value",
addMetricFunction: func(mb *metadata.MetricsBuilder, t pdata.Timestamp, val string, m map[string]string) {
addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string,
m map[string]string) {
// Function is a no-op as it's not required for this test
},
},
{
key: "rate",
addMetricFunction: func(mb *metadata.MetricsBuilder, t pdata.Timestamp, val string, m map[string]string) {
addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string,
m map[string]string) {
// Function is a no-op as it's not required for this test
},
},
Expand Down Expand Up @@ -199,13 +201,15 @@ func TestNullOutput(t *testing.T) {
orderedStats: []queryStat{
{
key: "value",
addMetricFunction: func(mb *metadata.MetricsBuilder, t pdata.Timestamp, val string, m map[string]string) {
addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string,
m map[string]string) {
// Function is a no-op as it's not required for this test
},
},
{
key: "rate",
addMetricFunction: func(mb *metadata.MetricsBuilder, t pdata.Timestamp, val string, m map[string]string) {
addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string,
m map[string]string) {
// Function is a no-op as it's not required for this test
},
},
Expand Down
Loading

0 comments on commit 5308e2b

Please sign in to comment.