diff --git a/.codecov.yml b/.codecov.yml index fd81640a298..684b3772c07 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -18,4 +18,4 @@ coverage: target: 95% ignore: - - "model/internal/data/protogen/**/*" + - "pdata/internal/data/protogen/**/*" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c2592075f75..362e0907d2f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -26,3 +26,7 @@ updates: directory: "/model" schedule: interval: "weekly" + - package-ecosystem: "gomod" + directory: "/pdata" + schedule: + interval: "weekly" diff --git a/CHANGELOG.md b/CHANGELOG.md index 2912bc207ab..6719d57fe88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ ### 🚩 Deprecations 🚩 +- All pdata related APIs from model (model/pdata, model/otlp and model/otlpgrpc) are deprecated in + favor of packages in the new pdata module separated by telemetry signal type (#5168) + - `model/pdata`, `model/otlp` -> `pdata/pcommon`, `pdata/plog`, `pdata/pmetric`, `pdata/ptrace` + - `model/otlpgrpc` -> `pdata/plog/plogotlp`, `pdata/pmetric/pmetricotlp`, `pdata/ptrace/ptraceotlp` - Deprecate configmapprovider package, replace with mapconverter (#5167) - Deprecate `service.MustNewConfigProvider` and `service.MustNewDefaultConfigProvider`in favor of `service.NewConfigProvider` (#4762) diff --git a/Makefile b/Makefile index 59a540837cd..77ae812bc40 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ include ./Makefile.Common # This is the code that we want to run lint, etc. ALL_SRC := $(shell find . -name '*.go' \ -not -path './internal/tools/*' \ - -not -path './model/internal/data/protogen/*' \ + -not -path './pdata/internal/data/protogen/*' \ -not -path './service/internal/zpages/tmplgen/*' \ -type f | sort) @@ -226,7 +226,7 @@ gendependabot: $(eval SHELL:=/bin/bash) # Definitions for ProtoBuf generation. # The source directory for OTLP ProtoBufs. -OPENTELEMETRY_PROTO_SRC_DIR=model/internal/opentelemetry-proto +OPENTELEMETRY_PROTO_SRC_DIR=pdata/internal/opentelemetry-proto # The SHA matching the current version of the proto to use OPENTELEMETRY_PROTO_VERSION=v0.15.0 @@ -235,13 +235,13 @@ OPENTELEMETRY_PROTO_VERSION=v0.15.0 OPENTELEMETRY_PROTO_FILES := $(subst $(OPENTELEMETRY_PROTO_SRC_DIR)/,,$(wildcard $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/*/v1/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/collector/*/v1/*.proto)) # Target directory to write generated files to. -PROTO_TARGET_GEN_DIR=model/internal/data/protogen +PROTO_TARGET_GEN_DIR=pdata/internal/data/protogen # Go package name to use for generated files. PROTO_PACKAGE=go.opentelemetry.io/collector/$(PROTO_TARGET_GEN_DIR) # Intermediate directory used during generation. -PROTO_INTERMEDIATE_DIR=model/internal/.patched-otlp-proto +PROTO_INTERMEDIATE_DIR=pdata/internal/.patched-otlp-proto DOCKER_PROTOBUF ?= otel/build-protobuf:0.9.0 PROTOC := docker run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD}/$(PROTO_INTERMEDIATE_DIR) ${DOCKER_PROTOBUF} --proto_path=${PWD} @@ -289,7 +289,7 @@ genproto_sub: # Generate structs, functions and tests for pdata package. Must be used after any changes # to proto and after running `make genproto` genpdata: - $(GOCMD) run model/internal/cmd/pdatagen/main.go + $(GOCMD) run pdata/internal/cmd/pdatagen/main.go $(MAKE) fmt # Generate semantic convention constants. Requires a clone of the opentelemetry-specification repo @@ -306,6 +306,7 @@ gensemconv: check-contrib: @echo Setting contrib at $(CONTRIB_PATH) to use this core checkout @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector=$(CURDIR)" + @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/pdata=$(CURDIR)/pdata" @$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector/model=$(CURDIR)/model" @$(MAKE) -C $(CONTRIB_PATH) -j2 gotidy @$(MAKE) -C $(CONTRIB_PATH) test diff --git a/client/doc_test.go b/client/doc_test.go index ee8f0bf97d1..5d818586df6 100644 --- a/client/doc_test.go +++ b/client/doc_test.go @@ -21,7 +21,7 @@ import ( "go.opentelemetry.io/collector/client" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) func Example_receiver() { @@ -29,7 +29,7 @@ func Example_receiver() { var next consumer.Traces // You'll convert the incoming data into pipeline data - td := pdata.NewTraces() + td := ptrace.NewTraces() // You probably have a context with client metadata from your listener or // scraper diff --git a/cmd/otelcorecol/builder-config.yaml b/cmd/otelcorecol/builder-config.yaml index fb8c24a9138..92569abb1f1 100644 --- a/cmd/otelcorecol/builder-config.yaml +++ b/cmd/otelcorecol/builder-config.yaml @@ -29,3 +29,4 @@ processors: replaces: - go.opentelemetry.io/collector => ../../ - go.opentelemetry.io/collector/model => ../../model + - go.opentelemetry.io/collector/pdata => ../../pdata diff --git a/cmd/otelcorecol/go.mod b/cmd/otelcorecol/go.mod index 9164866c8cb..59dd159a2b8 100644 --- a/cmd/otelcorecol/go.mod +++ b/cmd/otelcorecol/go.mod @@ -54,6 +54,7 @@ require ( github.com/yusufpapurcu/wmi v1.2.2 // indirect go.opencensus.io v0.23.0 // indirect go.opentelemetry.io/collector/model v0.48.0 // indirect + go.opentelemetry.io/collector/pdata v0.0.0-00010101000000-000000000000 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.31.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 // indirect go.opentelemetry.io/contrib/zpages v0.31.0 // indirect @@ -78,3 +79,5 @@ require ( replace go.opentelemetry.io/collector => ../../ replace go.opentelemetry.io/collector/model => ../../model + +replace go.opentelemetry.io/collector/pdata => ../../pdata diff --git a/component/componenttest/nop_exporter_test.go b/component/componenttest/nop_exporter_test.go index d1182ff2af4..bb6f07d5060 100644 --- a/component/componenttest/nop_exporter_test.go +++ b/component/componenttest/nop_exporter_test.go @@ -22,7 +22,9 @@ import ( "github.com/stretchr/testify/require" "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" ) func TestNewNopExporterFactory(t *testing.T) { @@ -35,18 +37,18 @@ func TestNewNopExporterFactory(t *testing.T) { traces, err := factory.CreateTracesExporter(context.Background(), NewNopExporterCreateSettings(), cfg) require.NoError(t, err) assert.NoError(t, traces.Start(context.Background(), NewNopHost())) - assert.NoError(t, traces.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.NoError(t, traces.ConsumeTraces(context.Background(), ptrace.NewTraces())) assert.NoError(t, traces.Shutdown(context.Background())) metrics, err := factory.CreateMetricsExporter(context.Background(), NewNopExporterCreateSettings(), cfg) require.NoError(t, err) assert.NoError(t, metrics.Start(context.Background(), NewNopHost())) - assert.NoError(t, metrics.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.NoError(t, metrics.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) assert.NoError(t, metrics.Shutdown(context.Background())) logs, err := factory.CreateLogsExporter(context.Background(), NewNopExporterCreateSettings(), cfg) require.NoError(t, err) assert.NoError(t, logs.Start(context.Background(), NewNopHost())) - assert.NoError(t, logs.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.NoError(t, logs.ConsumeLogs(context.Background(), plog.NewLogs())) assert.NoError(t, logs.Shutdown(context.Background())) } diff --git a/component/componenttest/nop_processor_test.go b/component/componenttest/nop_processor_test.go index b82b1c344e2..ad508499209 100644 --- a/component/componenttest/nop_processor_test.go +++ b/component/componenttest/nop_processor_test.go @@ -24,7 +24,9 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) func TestNewNopProcessorFactory(t *testing.T) { @@ -38,20 +40,20 @@ func TestNewNopProcessorFactory(t *testing.T) { require.NoError(t, err) assert.Equal(t, consumer.Capabilities{MutatesData: false}, traces.Capabilities()) assert.NoError(t, traces.Start(context.Background(), NewNopHost())) - assert.NoError(t, traces.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.NoError(t, traces.ConsumeTraces(context.Background(), ptrace.NewTraces())) assert.NoError(t, traces.Shutdown(context.Background())) metrics, err := factory.CreateMetricsProcessor(context.Background(), NewNopProcessorCreateSettings(), cfg, consumertest.NewNop()) require.NoError(t, err) assert.Equal(t, consumer.Capabilities{MutatesData: false}, metrics.Capabilities()) assert.NoError(t, metrics.Start(context.Background(), NewNopHost())) - assert.NoError(t, metrics.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.NoError(t, metrics.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) assert.NoError(t, metrics.Shutdown(context.Background())) logs, err := factory.CreateLogsProcessor(context.Background(), NewNopProcessorCreateSettings(), cfg, consumertest.NewNop()) require.NoError(t, err) assert.Equal(t, consumer.Capabilities{MutatesData: false}, logs.Capabilities()) assert.NoError(t, logs.Start(context.Background(), NewNopHost())) - assert.NoError(t, logs.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.NoError(t, logs.ConsumeLogs(context.Background(), plog.NewLogs())) assert.NoError(t, logs.Shutdown(context.Background())) } diff --git a/component/receiver.go b/component/receiver.go index 6ed6c44217e..93111f26248 100644 --- a/component/receiver.go +++ b/component/receiver.go @@ -67,7 +67,7 @@ type Receiver interface { // Its purpose is to translate data from any format to the collector's internal trace format. // TracesReceiver feeds a consumer.Traces with data. // -// For example it could be Zipkin data source which translates Zipkin spans into pdata.Traces. +// For example it could be Zipkin data source which translates Zipkin spans into ptrace.Traces. type TracesReceiver interface { Receiver } @@ -76,7 +76,7 @@ type TracesReceiver interface { // Its purpose is to translate data from any format to the collector's internal metrics format. // MetricsReceiver feeds a consumer.Metrics with data. // -// For example it could be Prometheus data source which translates Prometheus metrics into pdata.Metrics. +// For example it could be Prometheus data source which translates Prometheus metrics into pmetric.Metrics. type MetricsReceiver interface { Receiver } @@ -85,7 +85,7 @@ type MetricsReceiver interface { // Its purpose is to translate data from any format to the collector's internal logs data format. // LogsReceiver feeds a consumer.Logs with data. // -// For example a LogsReceiver can read syslogs and convert them into pdata.Logs. +// For example a LogsReceiver can read syslogs and convert them into plog.Logs. type LogsReceiver interface { Receiver } diff --git a/config/configgrpc/configgrpc_benchmark_test.go b/config/configgrpc/configgrpc_benchmark_test.go index a96446e2eb7..dbd7a234e84 100644 --- a/config/configgrpc/configgrpc_benchmark_test.go +++ b/config/configgrpc/configgrpc_benchmark_test.go @@ -31,8 +31,9 @@ import ( "google.golang.org/grpc/status" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) func BenchmarkCompressors(b *testing.B) { @@ -106,34 +107,34 @@ type marshaler interface { } type logMarshaler struct { - pdata.LogsMarshaler + plog.Marshaler } func (m *logMarshaler) marshal(e interface{}) ([]byte, error) { - return m.MarshalLogs(e.(pdata.Logs)) + return m.MarshalLogs(e.(plog.Logs)) } type traceMarshaler struct { - pdata.TracesMarshaler + ptrace.Marshaler } func (m *traceMarshaler) marshal(e interface{}) ([]byte, error) { - return m.MarshalTraces(e.(pdata.Traces)) + return m.MarshalTraces(e.(ptrace.Traces)) } type metricsMarshaler struct { - pdata.MetricsMarshaler + pmetric.Marshaler } func (m *metricsMarshaler) marshal(e interface{}) ([]byte, error) { - return m.MarshalMetrics(e.(pdata.Metrics)) + return m.MarshalMetrics(e.(pmetric.Metrics)) } func setupTestPayloads() []testPayload { payloads := make([]testPayload, 0) // log payloads - logMarshaler := &logMarshaler{otlp.NewProtobufLogsMarshaler()} + logMarshaler := &logMarshaler{plog.NewProtoMarshaler()} payloads = append(payloads, testPayload{ name: "sm_log_request", message: testdata.GenerateLogsOneLogRecord(), @@ -148,7 +149,7 @@ func setupTestPayloads() []testPayload { marshaler: logMarshaler}) // trace payloads - tracesMarshaler := &traceMarshaler{otlp.NewProtobufTracesMarshaler()} + tracesMarshaler := &traceMarshaler{ptrace.NewProtoMarshaler()} payloads = append(payloads, testPayload{ name: "sm_trace_request", message: testdata.GenerateTracesOneSpan(), @@ -163,7 +164,7 @@ func setupTestPayloads() []testPayload { marshaler: tracesMarshaler}) // metric payloads - metricsMarshaler := &metricsMarshaler{otlp.NewProtobufMetricsMarshaler()} + metricsMarshaler := &metricsMarshaler{pmetric.NewProtoMarshaler()} payloads = append(payloads, testPayload{ name: "sm_metric_request", message: testdata.GenerateMetricsOneMetric(), diff --git a/config/configgrpc/configgrpc_test.go b/config/configgrpc/configgrpc_test.go index 606d32f1ab2..85e96e1ec65 100644 --- a/config/configgrpc/configgrpc_test.go +++ b/config/configgrpc/configgrpc_test.go @@ -39,8 +39,8 @@ import ( "go.opentelemetry.io/collector/config/configcompression" "go.opentelemetry.io/collector/config/confignet" "go.opentelemetry.io/collector/config/configtls" - "go.opentelemetry.io/collector/model/otlpgrpc" "go.opentelemetry.io/collector/obsreport/obsreporttest" + "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" ) func TestDefaultGrpcClientSettings(t *testing.T) { @@ -567,7 +567,7 @@ func TestHttpReception(t *testing.T) { opts, err := gss.ToServerOption(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) assert.NoError(t, err) s := grpc.NewServer(opts...) - otlpgrpc.RegisterTracesServer(s, &grpcTraceServer{}) + ptraceotlp.RegisterServer(s, &grpcTraceServer{}) go func() { _ = s.Serve(ln) @@ -581,9 +581,9 @@ func TestHttpReception(t *testing.T) { assert.NoError(t, errClient) grpcClientConn, errDial := grpc.Dial(gcs.Endpoint, clientOpts...) assert.NoError(t, errDial) - client := otlpgrpc.NewTracesClient(grpcClientConn) + client := ptraceotlp.NewClient(grpcClientConn) ctx, cancelFunc := context.WithTimeout(context.Background(), 2*time.Second) - resp, errResp := client.Export(ctx, otlpgrpc.NewTracesRequest(), grpc.WaitForReady(true)) + resp, errResp := client.Export(ctx, ptraceotlp.NewRequest(), grpc.WaitForReady(true)) if test.hasError { assert.Error(t, errResp) } else { @@ -616,7 +616,7 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) { opts, err := gss.ToServerOption(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) assert.NoError(t, err) s := grpc.NewServer(opts...) - otlpgrpc.RegisterTracesServer(s, &grpcTraceServer{}) + ptraceotlp.RegisterServer(s, &grpcTraceServer{}) go func() { _ = s.Serve(ln) @@ -632,9 +632,9 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) { assert.NoError(t, errClient) grpcClientConn, errDial := grpc.Dial(gcs.Endpoint, clientOpts...) assert.NoError(t, errDial) - client := otlpgrpc.NewTracesClient(grpcClientConn) + client := ptraceotlp.NewClient(grpcClientConn) ctx, cancelFunc := context.WithTimeout(context.Background(), 2*time.Second) - resp, errResp := client.Export(ctx, otlpgrpc.NewTracesRequest(), grpc.WaitForReady(true)) + resp, errResp := client.Export(ctx, ptraceotlp.NewRequest(), grpc.WaitForReady(true)) assert.NoError(t, errResp) assert.NotNil(t, resp) cancelFunc() @@ -783,14 +783,14 @@ func (ms *mockedStream) Context() context.Context { func TestClientInfoInterceptors(t *testing.T) { testCases := []struct { desc string - tester func(context.Context, otlpgrpc.TracesClient) + tester func(context.Context, ptraceotlp.Client) }{ { // we only have unary services, we don't have any clients we could use // to test with streaming services desc: "unary", - tester: func(ctx context.Context, cl otlpgrpc.TracesClient) { - resp, errResp := cl.Export(ctx, otlpgrpc.NewTracesRequest()) + tester: func(ctx context.Context, cl ptraceotlp.Client) { + resp, errResp := cl.Export(ctx, ptraceotlp.NewRequest()) require.NoError(t, errResp) require.NotNil(t, resp) }, @@ -812,7 +812,7 @@ func TestClientInfoInterceptors(t *testing.T) { opts, err := gss.ToServerOption(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) require.NoError(t, err) srv := grpc.NewServer(opts...) - otlpgrpc.RegisterTracesServer(srv, mock) + ptraceotlp.RegisterServer(srv, mock) defer srv.Stop() @@ -845,7 +845,7 @@ func TestClientInfoInterceptors(t *testing.T) { grpcClientConn, errDial := grpc.Dial(gcs.Endpoint, clientOpts...) require.NoError(t, errDial) - cl := otlpgrpc.NewTracesClient(grpcClientConn) + cl := ptraceotlp.NewClient(grpcClientConn) ctx, cancelFunc := context.WithTimeout(context.Background(), 2*time.Second) defer cancelFunc() @@ -1025,9 +1025,9 @@ type grpcTraceServer struct { recordedContext context.Context } -func (gts *grpcTraceServer) Export(ctx context.Context, _ otlpgrpc.TracesRequest) (otlpgrpc.TracesResponse, error) { +func (gts *grpcTraceServer) Export(ctx context.Context, _ ptraceotlp.Request) (ptraceotlp.Response, error) { gts.recordedContext = ctx - return otlpgrpc.NewTracesResponse(), nil + return ptraceotlp.NewResponse(), nil } // tempSocketName provides a temporary Unix socket name for testing. diff --git a/consumer/consumererror/signalerrors.go b/consumer/consumererror/signalerrors.go index f8c7e5bd53d..c13a4abc9b6 100644 --- a/consumer/consumererror/signalerrors.go +++ b/consumer/consumererror/signalerrors.go @@ -15,18 +15,20 @@ package consumererror // import "go.opentelemetry.io/collector/consumer/consumererror" import ( - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // Traces is an error that may carry associated Trace data for a subset of received data // that failed to be processed or sent. type Traces struct { error - failed pdata.Traces + failed ptrace.Traces } // NewTraces creates a Traces that can encapsulate received data that failed to be processed or sent. -func NewTraces(err error, failed pdata.Traces) error { +func NewTraces(err error, failed ptrace.Traces) error { return Traces{ error: err, failed: failed, @@ -34,7 +36,7 @@ func NewTraces(err error, failed pdata.Traces) error { } // GetTraces returns failed traces from the associated error. -func (err Traces) GetTraces() pdata.Traces { +func (err Traces) GetTraces() ptrace.Traces { return err.failed } @@ -47,11 +49,11 @@ func (err Traces) Unwrap() error { // that failed to be processed or sent. type Logs struct { error - failed pdata.Logs + failed plog.Logs } // NewLogs creates a Logs that can encapsulate received data that failed to be processed or sent. -func NewLogs(err error, failed pdata.Logs) error { +func NewLogs(err error, failed plog.Logs) error { return Logs{ error: err, failed: failed, @@ -59,7 +61,7 @@ func NewLogs(err error, failed pdata.Logs) error { } // GetLogs returns failed logs from the associated error. -func (err Logs) GetLogs() pdata.Logs { +func (err Logs) GetLogs() plog.Logs { return err.failed } @@ -72,11 +74,11 @@ func (err Logs) Unwrap() error { // that failed to be processed or sent. type Metrics struct { error - failed pdata.Metrics + failed pmetric.Metrics } // NewMetrics creates a Metrics that can encapsulate received data that failed to be processed or sent. -func NewMetrics(err error, failed pdata.Metrics) error { +func NewMetrics(err error, failed pmetric.Metrics) error { return Metrics{ error: err, failed: failed, @@ -84,7 +86,7 @@ func NewMetrics(err error, failed pdata.Metrics) error { } // GetMetrics returns failed metrics from the associated error. -func (err Metrics) GetMetrics() pdata.Metrics { +func (err Metrics) GetMetrics() pmetric.Metrics { return err.failed } diff --git a/consumer/consumertest/consumer.go b/consumer/consumertest/consumer.go index a9cee267436..a50e52b5b55 100644 --- a/consumer/consumertest/consumer.go +++ b/consumer/consumertest/consumer.go @@ -18,7 +18,9 @@ import ( "context" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // Consumer is a convenience interface that implements all consumer interfaces. @@ -29,11 +31,11 @@ type Consumer interface { // Capabilities to implement the base consumer functionality. Capabilities() consumer.Capabilities // ConsumeTraces to implement the consumer.Traces. - ConsumeTraces(context.Context, pdata.Traces) error + ConsumeTraces(context.Context, ptrace.Traces) error // ConsumeMetrics to implement the consumer.Metrics. - ConsumeMetrics(context.Context, pdata.Metrics) error + ConsumeMetrics(context.Context, pmetric.Metrics) error // ConsumeLogs to implement the consumer.Logs. - ConsumeLogs(context.Context, pdata.Logs) error + ConsumeLogs(context.Context, plog.Logs) error unexported() } diff --git a/consumer/consumertest/err.go b/consumer/consumertest/err.go index dc0cf989cc1..0d5eadf6fc7 100644 --- a/consumer/consumertest/err.go +++ b/consumer/consumertest/err.go @@ -17,7 +17,9 @@ package consumertest // import "go.opentelemetry.io/collector/consumer/consumert import ( "context" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) type errConsumer struct { @@ -27,15 +29,15 @@ type errConsumer struct { func (er *errConsumer) unexported() {} -func (er *errConsumer) ConsumeTraces(context.Context, pdata.Traces) error { +func (er *errConsumer) ConsumeTraces(context.Context, ptrace.Traces) error { return er.err } -func (er *errConsumer) ConsumeMetrics(context.Context, pdata.Metrics) error { +func (er *errConsumer) ConsumeMetrics(context.Context, pmetric.Metrics) error { return er.err } -func (er *errConsumer) ConsumeLogs(context.Context, pdata.Logs) error { +func (er *errConsumer) ConsumeLogs(context.Context, plog.Logs) error { return er.err } diff --git a/consumer/consumertest/err_test.go b/consumer/consumertest/err_test.go index 382b3809086..decb0fc2af5 100644 --- a/consumer/consumertest/err_test.go +++ b/consumer/consumertest/err_test.go @@ -22,7 +22,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) func TestErr(t *testing.T) { @@ -30,7 +32,7 @@ func TestErr(t *testing.T) { ec := NewErr(err) require.NotNil(t, ec) assert.NotPanics(t, ec.unexported) - assert.Equal(t, err, ec.ConsumeLogs(context.Background(), pdata.NewLogs())) - assert.Equal(t, err, ec.ConsumeMetrics(context.Background(), pdata.NewMetrics())) - assert.Equal(t, err, ec.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.Equal(t, err, ec.ConsumeLogs(context.Background(), plog.NewLogs())) + assert.Equal(t, err, ec.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) + assert.Equal(t, err, ec.ConsumeTraces(context.Background(), ptrace.NewTraces())) } diff --git a/consumer/consumertest/nop.go b/consumer/consumertest/nop.go index f48123677ca..d0c8f0ad220 100644 --- a/consumer/consumertest/nop.go +++ b/consumer/consumertest/nop.go @@ -17,7 +17,9 @@ package consumertest // import "go.opentelemetry.io/collector/consumer/consumert import ( "context" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) var ( @@ -30,15 +32,15 @@ type nopConsumer struct { func (nc *nopConsumer) unexported() {} -func (nc *nopConsumer) ConsumeTraces(context.Context, pdata.Traces) error { +func (nc *nopConsumer) ConsumeTraces(context.Context, ptrace.Traces) error { return nil } -func (nc *nopConsumer) ConsumeMetrics(context.Context, pdata.Metrics) error { +func (nc *nopConsumer) ConsumeMetrics(context.Context, pmetric.Metrics) error { return nil } -func (nc *nopConsumer) ConsumeLogs(context.Context, pdata.Logs) error { +func (nc *nopConsumer) ConsumeLogs(context.Context, plog.Logs) error { return nil } diff --git a/consumer/consumertest/nop_test.go b/consumer/consumertest/nop_test.go index a16b129808a..450762fc361 100644 --- a/consumer/consumertest/nop_test.go +++ b/consumer/consumertest/nop_test.go @@ -21,14 +21,16 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) func TestNop(t *testing.T) { nc := NewNop() require.NotNil(t, nc) assert.NotPanics(t, nc.unexported) - assert.NoError(t, nc.ConsumeLogs(context.Background(), pdata.NewLogs())) - assert.NoError(t, nc.ConsumeMetrics(context.Background(), pdata.NewMetrics())) - assert.NoError(t, nc.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.NoError(t, nc.ConsumeLogs(context.Background(), plog.NewLogs())) + assert.NoError(t, nc.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) + assert.NoError(t, nc.ConsumeTraces(context.Background(), ptrace.NewTraces())) } diff --git a/consumer/consumertest/sink.go b/consumer/consumertest/sink.go index d9a23602222..ed97bff5386 100644 --- a/consumer/consumertest/sink.go +++ b/consumer/consumertest/sink.go @@ -19,7 +19,9 @@ import ( "sync" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // TracesSink is a consumer.Traces that acts like a sink that @@ -27,14 +29,14 @@ import ( type TracesSink struct { nonMutatingConsumer mu sync.Mutex - traces []pdata.Traces + traces []ptrace.Traces spanCount int } var _ consumer.Traces = (*TracesSink)(nil) // ConsumeTraces stores traces to this sink. -func (ste *TracesSink) ConsumeTraces(_ context.Context, td pdata.Traces) error { +func (ste *TracesSink) ConsumeTraces(_ context.Context, td ptrace.Traces) error { ste.mu.Lock() defer ste.mu.Unlock() @@ -45,11 +47,11 @@ func (ste *TracesSink) ConsumeTraces(_ context.Context, td pdata.Traces) error { } // AllTraces returns the traces stored by this sink since last Reset. -func (ste *TracesSink) AllTraces() []pdata.Traces { +func (ste *TracesSink) AllTraces() []ptrace.Traces { ste.mu.Lock() defer ste.mu.Unlock() - copyTraces := make([]pdata.Traces, len(ste.traces)) + copyTraces := make([]ptrace.Traces, len(ste.traces)) copy(copyTraces, ste.traces) return copyTraces } @@ -75,14 +77,14 @@ func (ste *TracesSink) Reset() { type MetricsSink struct { nonMutatingConsumer mu sync.Mutex - metrics []pdata.Metrics + metrics []pmetric.Metrics dataPointCount int } var _ consumer.Metrics = (*MetricsSink)(nil) // ConsumeMetrics stores metrics to this sink. -func (sme *MetricsSink) ConsumeMetrics(_ context.Context, md pdata.Metrics) error { +func (sme *MetricsSink) ConsumeMetrics(_ context.Context, md pmetric.Metrics) error { sme.mu.Lock() defer sme.mu.Unlock() @@ -93,11 +95,11 @@ func (sme *MetricsSink) ConsumeMetrics(_ context.Context, md pdata.Metrics) erro } // AllMetrics returns the metrics stored by this sink since last Reset. -func (sme *MetricsSink) AllMetrics() []pdata.Metrics { +func (sme *MetricsSink) AllMetrics() []pmetric.Metrics { sme.mu.Lock() defer sme.mu.Unlock() - copyMetrics := make([]pdata.Metrics, len(sme.metrics)) + copyMetrics := make([]pmetric.Metrics, len(sme.metrics)) copy(copyMetrics, sme.metrics) return copyMetrics } @@ -123,14 +125,14 @@ func (sme *MetricsSink) Reset() { type LogsSink struct { nonMutatingConsumer mu sync.Mutex - logs []pdata.Logs + logs []plog.Logs logRecordCount int } var _ consumer.Logs = (*LogsSink)(nil) // ConsumeLogs stores logs to this sink. -func (sle *LogsSink) ConsumeLogs(_ context.Context, ld pdata.Logs) error { +func (sle *LogsSink) ConsumeLogs(_ context.Context, ld plog.Logs) error { sle.mu.Lock() defer sle.mu.Unlock() @@ -141,11 +143,11 @@ func (sle *LogsSink) ConsumeLogs(_ context.Context, ld pdata.Logs) error { } // AllLogs returns the logs stored by this sink since last Reset. -func (sle *LogsSink) AllLogs() []pdata.Logs { +func (sle *LogsSink) AllLogs() []plog.Logs { sle.mu.Lock() defer sle.mu.Unlock() - copyLogs := make([]pdata.Logs, len(sle.logs)) + copyLogs := make([]plog.Logs, len(sle.logs)) copy(copyLogs, sle.logs) return copyLogs } diff --git a/consumer/consumertest/sink_test.go b/consumer/consumertest/sink_test.go index 2098019471f..0be180a1ace 100644 --- a/consumer/consumertest/sink_test.go +++ b/consumer/consumertest/sink_test.go @@ -22,13 +22,15 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) func TestTracesSink(t *testing.T) { sink := new(TracesSink) td := testdata.GenerateTracesOneSpan() - want := make([]pdata.Traces, 0, 7) + want := make([]ptrace.Traces, 0, 7) for i := 0; i < 7; i++ { require.NoError(t, sink.ConsumeTraces(context.Background(), td)) want = append(want, td) @@ -43,7 +45,7 @@ func TestTracesSink(t *testing.T) { func TestMetricsSink(t *testing.T) { sink := new(MetricsSink) md := testdata.GenerateMetricsOneMetric() - want := make([]pdata.Metrics, 0, 7) + want := make([]pmetric.Metrics, 0, 7) for i := 0; i < 7; i++ { require.NoError(t, sink.ConsumeMetrics(context.Background(), md)) want = append(want, md) @@ -58,7 +60,7 @@ func TestMetricsSink(t *testing.T) { func TestLogsSink(t *testing.T) { sink := new(LogsSink) md := testdata.GenerateLogsOneLogRecord() - want := make([]pdata.Logs, 0, 7) + want := make([]plog.Logs, 0, 7) for i := 0; i < 7; i++ { require.NoError(t, sink.ConsumeLogs(context.Background(), md)) want = append(want, md) diff --git a/consumer/logs.go b/consumer/logs.go index 2876c14978e..635fb785bd4 100644 --- a/consumer/logs.go +++ b/consumer/logs.go @@ -17,22 +17,22 @@ package consumer // import "go.opentelemetry.io/collector/consumer" import ( "context" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) -// Logs is an interface that receives pdata.Logs, processes it +// Logs is an interface that receives plog.Logs, processes it // as needed, and sends it to the next processing node if any or to the destination. type Logs interface { baseConsumer - // ConsumeLogs receives pdata.Logs for consumption. - ConsumeLogs(ctx context.Context, ld pdata.Logs) error + // ConsumeLogs receives plog.Logs for consumption. + ConsumeLogs(ctx context.Context, ld plog.Logs) error } // ConsumeLogsFunc is a helper function that is similar to ConsumeLogs. -type ConsumeLogsFunc func(ctx context.Context, ld pdata.Logs) error +type ConsumeLogsFunc func(ctx context.Context, ld plog.Logs) error // ConsumeLogs calls f(ctx, ld). -func (f ConsumeLogsFunc) ConsumeLogs(ctx context.Context, ld pdata.Logs) error { +func (f ConsumeLogsFunc) ConsumeLogs(ctx context.Context, ld plog.Logs) error { return f(ctx, ld) } diff --git a/consumer/logs_test.go b/consumer/logs_test.go index d3815937d96..7850f7647e1 100644 --- a/consumer/logs_test.go +++ b/consumer/logs_test.go @@ -21,13 +21,13 @@ import ( "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) func TestDefaultLogs(t *testing.T) { - cp, err := NewLogs(func(context.Context, pdata.Logs) error { return nil }) + cp, err := NewLogs(func(context.Context, plog.Logs) error { return nil }) assert.NoError(t, err) - assert.NoError(t, cp.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.NoError(t, cp.ConsumeLogs(context.Background(), plog.NewLogs())) assert.Equal(t, Capabilities{MutatesData: false}, cp.Capabilities()) } @@ -38,24 +38,24 @@ func TestNilFuncLogs(t *testing.T) { func TestWithCapabilitiesLogs(t *testing.T) { cp, err := NewLogs( - func(context.Context, pdata.Logs) error { return nil }, + func(context.Context, plog.Logs) error { return nil }, WithCapabilities(Capabilities{MutatesData: true})) assert.NoError(t, err) - assert.NoError(t, cp.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.NoError(t, cp.ConsumeLogs(context.Background(), plog.NewLogs())) assert.Equal(t, Capabilities{MutatesData: true}, cp.Capabilities()) } func TestConsumeLogs(t *testing.T) { consumeCalled := false - cp, err := NewLogs(func(context.Context, pdata.Logs) error { consumeCalled = true; return nil }) + cp, err := NewLogs(func(context.Context, plog.Logs) error { consumeCalled = true; return nil }) assert.NoError(t, err) - assert.NoError(t, cp.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.NoError(t, cp.ConsumeLogs(context.Background(), plog.NewLogs())) assert.True(t, consumeCalled) } func TestConsumeLogs_ReturnError(t *testing.T) { want := errors.New("my_error") - cp, err := NewLogs(func(context.Context, pdata.Logs) error { return want }) + cp, err := NewLogs(func(context.Context, plog.Logs) error { return want }) assert.NoError(t, err) - assert.Equal(t, want, cp.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.Equal(t, want, cp.ConsumeLogs(context.Background(), plog.NewLogs())) } diff --git a/consumer/metrics.go b/consumer/metrics.go index 43102cee7f1..4b96a73142f 100644 --- a/consumer/metrics.go +++ b/consumer/metrics.go @@ -17,22 +17,22 @@ package consumer // import "go.opentelemetry.io/collector/consumer" import ( "context" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" ) -// Metrics is the new metrics consumer interface that receives pdata.Metrics, processes it +// Metrics is the new metrics consumer interface that receives pmetric.Metrics, processes it // as needed, and sends it to the next processing node if any or to the destination. type Metrics interface { baseConsumer - // ConsumeMetrics receives pdata.Metrics for consumption. - ConsumeMetrics(ctx context.Context, md pdata.Metrics) error + // ConsumeMetrics receives pmetric.Metrics for consumption. + ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error } // ConsumeMetricsFunc is a helper function that is similar to ConsumeMetrics. -type ConsumeMetricsFunc func(ctx context.Context, ld pdata.Metrics) error +type ConsumeMetricsFunc func(ctx context.Context, ld pmetric.Metrics) error // ConsumeMetrics calls f(ctx, ld). -func (f ConsumeMetricsFunc) ConsumeMetrics(ctx context.Context, ld pdata.Metrics) error { +func (f ConsumeMetricsFunc) ConsumeMetrics(ctx context.Context, ld pmetric.Metrics) error { return f(ctx, ld) } diff --git a/consumer/metrics_test.go b/consumer/metrics_test.go index f6b88568869..744d6a017d1 100644 --- a/consumer/metrics_test.go +++ b/consumer/metrics_test.go @@ -21,13 +21,13 @@ import ( "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" ) func TestDefaultMetrics(t *testing.T) { - cp, err := NewMetrics(func(context.Context, pdata.Metrics) error { return nil }) + cp, err := NewMetrics(func(context.Context, pmetric.Metrics) error { return nil }) assert.NoError(t, err) - assert.NoError(t, cp.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.NoError(t, cp.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) assert.Equal(t, Capabilities{MutatesData: false}, cp.Capabilities()) } @@ -38,24 +38,24 @@ func TestNilFuncMetrics(t *testing.T) { func TestWithCapabilitiesMetrics(t *testing.T) { cp, err := NewMetrics( - func(context.Context, pdata.Metrics) error { return nil }, + func(context.Context, pmetric.Metrics) error { return nil }, WithCapabilities(Capabilities{MutatesData: true})) assert.NoError(t, err) - assert.NoError(t, cp.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.NoError(t, cp.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) assert.Equal(t, Capabilities{MutatesData: true}, cp.Capabilities()) } func TestConsumeMetrics(t *testing.T) { consumeCalled := false - cp, err := NewMetrics(func(context.Context, pdata.Metrics) error { consumeCalled = true; return nil }) + cp, err := NewMetrics(func(context.Context, pmetric.Metrics) error { consumeCalled = true; return nil }) assert.NoError(t, err) - assert.NoError(t, cp.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.NoError(t, cp.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) assert.True(t, consumeCalled) } func TestConsumeMetrics_ReturnError(t *testing.T) { want := errors.New("my_error") - cp, err := NewMetrics(func(context.Context, pdata.Metrics) error { return want }) + cp, err := NewMetrics(func(context.Context, pmetric.Metrics) error { return want }) assert.NoError(t, err) - assert.Equal(t, want, cp.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.Equal(t, want, cp.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) } diff --git a/consumer/traces.go b/consumer/traces.go index 3852d7d253b..8efd0302cc9 100644 --- a/consumer/traces.go +++ b/consumer/traces.go @@ -17,22 +17,22 @@ package consumer // import "go.opentelemetry.io/collector/consumer" import ( "context" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) -// Traces is an interface that receives pdata.Traces, processes it +// Traces is an interface that receives ptrace.Traces, processes it // as needed, and sends it to the next processing node if any or to the destination. type Traces interface { baseConsumer - // ConsumeTraces receives pdata.Traces for consumption. - ConsumeTraces(ctx context.Context, td pdata.Traces) error + // ConsumeTraces receives ptrace.Traces for consumption. + ConsumeTraces(ctx context.Context, td ptrace.Traces) error } // ConsumeTracesFunc is a helper function that is similar to ConsumeTraces. -type ConsumeTracesFunc func(ctx context.Context, ld pdata.Traces) error +type ConsumeTracesFunc func(ctx context.Context, ld ptrace.Traces) error // ConsumeTraces calls f(ctx, ld). -func (f ConsumeTracesFunc) ConsumeTraces(ctx context.Context, ld pdata.Traces) error { +func (f ConsumeTracesFunc) ConsumeTraces(ctx context.Context, ld ptrace.Traces) error { return f(ctx, ld) } diff --git a/consumer/traces_test.go b/consumer/traces_test.go index 41cd269cfe0..f0d886500ec 100644 --- a/consumer/traces_test.go +++ b/consumer/traces_test.go @@ -21,13 +21,13 @@ import ( "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) func TestDefaultTraces(t *testing.T) { - cp, err := NewTraces(func(context.Context, pdata.Traces) error { return nil }) + cp, err := NewTraces(func(context.Context, ptrace.Traces) error { return nil }) assert.NoError(t, err) - assert.NoError(t, cp.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.NoError(t, cp.ConsumeTraces(context.Background(), ptrace.NewTraces())) assert.Equal(t, Capabilities{MutatesData: false}, cp.Capabilities()) } @@ -38,24 +38,24 @@ func TestNilFuncTraces(t *testing.T) { func TestWithCapabilitiesTraces(t *testing.T) { cp, err := NewTraces( - func(context.Context, pdata.Traces) error { return nil }, + func(context.Context, ptrace.Traces) error { return nil }, WithCapabilities(Capabilities{MutatesData: true})) assert.NoError(t, err) - assert.NoError(t, cp.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.NoError(t, cp.ConsumeTraces(context.Background(), ptrace.NewTraces())) assert.Equal(t, Capabilities{MutatesData: true}, cp.Capabilities()) } func TestConsumeTraces(t *testing.T) { consumeCalled := false - cp, err := NewTraces(func(context.Context, pdata.Traces) error { consumeCalled = true; return nil }) + cp, err := NewTraces(func(context.Context, ptrace.Traces) error { consumeCalled = true; return nil }) assert.NoError(t, err) - assert.NoError(t, cp.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.NoError(t, cp.ConsumeTraces(context.Background(), ptrace.NewTraces())) assert.True(t, consumeCalled) } func TestConsumeTraces_ReturnError(t *testing.T) { want := errors.New("my_error") - cp, err := NewTraces(func(context.Context, pdata.Traces) error { return want }) + cp, err := NewTraces(func(context.Context, ptrace.Traces) error { return want }) assert.NoError(t, err) - assert.Equal(t, want, cp.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.Equal(t, want, cp.ConsumeTraces(context.Background(), ptrace.NewTraces())) } diff --git a/exporter/exporterhelper/common_test.go b/exporter/exporterhelper/common_test.go index 42559e212a2..8fc92626940 100644 --- a/exporter/exporterhelper/common_test.go +++ b/exporter/exporterhelper/common_test.go @@ -28,7 +28,7 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter/exporterhelper/internal" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) var ( @@ -71,7 +71,7 @@ func checkStatus(t *testing.T, sd sdktrace.ReadOnlySpan, err error) { } func nopTracePusher() consumer.ConsumeTracesFunc { - return func(ctx context.Context, ld pdata.Traces) error { + return func(ctx context.Context, ld ptrace.Traces) error { return nil } } diff --git a/exporter/exporterhelper/internal/persistent_queue_test.go b/exporter/exporterhelper/internal/persistent_queue_test.go index f94a4b35aa4..5fc9bf28aad 100644 --- a/exporter/exporterhelper/internal/persistent_queue_test.go +++ b/exporter/exporterhelper/internal/persistent_queue_test.go @@ -31,7 +31,8 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/extension/experimental/storage" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" ) func createTestQueue(extension storage.Extension, capacity int) *persistentQueue { @@ -167,20 +168,20 @@ func TestPersistentQueue_ConsumersProducers(t *testing.T) { } } -func newTraces(numTraces int, numSpans int) pdata.Traces { - traces := pdata.NewTraces() +func newTraces(numTraces int, numSpans int) ptrace.Traces { + traces := ptrace.NewTraces() batch := traces.ResourceSpans().AppendEmpty() batch.Resource().Attributes().InsertString("resource-attr", "some-resource") batch.Resource().Attributes().InsertInt("num-traces", int64(numTraces)) batch.Resource().Attributes().InsertInt("num-spans", int64(numSpans)) for i := 0; i < numTraces; i++ { - traceID := pdata.NewTraceID([16]byte{1, 2, 3, byte(i)}) + traceID := pcommon.NewTraceID([16]byte{1, 2, 3, byte(i)}) ils := batch.ScopeSpans().AppendEmpty() for j := 0; j < numSpans; j++ { span := ils.Spans().AppendEmpty() span.SetTraceID(traceID) - span.SetSpanID(pdata.NewSpanID([8]byte{1, 2, 3, byte(j)})) + span.SetSpanID(pcommon.NewSpanID([8]byte{1, 2, 3, byte(j)})) span.SetName("should-not-be-changed") span.Attributes().InsertInt("int-attribute", int64(j)) span.Attributes().InsertString("str-attribute-1", "foobar") diff --git a/exporter/exporterhelper/internal/persistent_storage_test.go b/exporter/exporterhelper/internal/persistent_storage_test.go index d0a83ddfc42..81a41aac7ef 100644 --- a/exporter/exporterhelper/internal/persistent_storage_test.go +++ b/exporter/exporterhelper/internal/persistent_storage_test.go @@ -34,8 +34,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/extension/experimental/storage" - "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) func createStorageExtension(_ string) storage.Extension { @@ -69,19 +68,19 @@ func createTemporaryDirectory() string { } type fakeTracesRequest struct { - td pdata.Traces + td ptrace.Traces processingFinishedCallback func() PersistentRequest } -func newFakeTracesRequest(td pdata.Traces) *fakeTracesRequest { +func newFakeTracesRequest(td ptrace.Traces) *fakeTracesRequest { return &fakeTracesRequest{ td: td, } } func (fd *fakeTracesRequest) Marshal() ([]byte, error) { - return otlp.NewProtobufTracesMarshaler().MarshalTraces(fd.td) + return ptrace.NewProtoMarshaler().MarshalTraces(fd.td) } func (fd *fakeTracesRequest) OnProcessingFinished() { @@ -96,7 +95,7 @@ func (fd *fakeTracesRequest) SetOnProcessingFinished(callback func()) { func newFakeTracesRequestUnmarshalerFunc() RequestUnmarshaler { return func(bytes []byte) (PersistentRequest, error) { - traces, err := otlp.NewProtobufTracesUnmarshaler().UnmarshalTraces(bytes) + traces, err := ptrace.NewProtoUnmarshaler().UnmarshalTraces(bytes) if err != nil { return nil, err } diff --git a/exporter/exporterhelper/logs.go b/exporter/exporterhelper/logs.go index 3837d9a901c..ace0670827e 100644 --- a/exporter/exporterhelper/logs.go +++ b/exporter/exporterhelper/logs.go @@ -23,20 +23,19 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter/exporterhelper/internal" - "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) -var logsMarshaler = otlp.NewProtobufLogsMarshaler() -var logsUnmarshaler = otlp.NewProtobufLogsUnmarshaler() +var logsMarshaler = plog.NewProtoMarshaler() +var logsUnmarshaler = plog.NewProtoUnmarshaler() type logsRequest struct { baseRequest - ld pdata.Logs + ld plog.Logs pusher consumer.ConsumeLogsFunc } -func newLogsRequest(ctx context.Context, ld pdata.Logs, pusher consumer.ConsumeLogsFunc) request { +func newLogsRequest(ctx context.Context, ld plog.Logs, pusher consumer.ConsumeLogsFunc) request { return &logsRequest{ baseRequest: baseRequest{ctx: ctx}, ld: ld, @@ -107,7 +106,7 @@ func NewLogsExporter( } }) - lc, err := consumer.NewLogs(func(ctx context.Context, ld pdata.Logs) error { + lc, err := consumer.NewLogs(func(ctx context.Context, ld plog.Logs) error { req := newLogsRequest(ctx, ld, pusher) err := be.sender.send(req) if errors.Is(err, errSendingQueueIsFull) { diff --git a/exporter/exporterhelper/logs_test.go b/exporter/exporterhelper/logs_test.go index 3bd0dcc9b3f..08e1463e7b0 100644 --- a/exporter/exporterhelper/logs_test.go +++ b/exporter/exporterhelper/logs_test.go @@ -33,8 +33,8 @@ import ( "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" "go.opentelemetry.io/collector/obsreport/obsreporttest" + "go.opentelemetry.io/collector/pdata/plog" ) const ( @@ -50,10 +50,10 @@ var ( func TestLogsRequest(t *testing.T) { lr := newLogsRequest(context.Background(), testdata.GenerateLogsOneLogRecord(), nil) - logErr := consumererror.NewLogs(errors.New("some error"), pdata.NewLogs()) + logErr := consumererror.NewLogs(errors.New("some error"), plog.NewLogs()) assert.EqualValues( t, - newLogsRequest(context.Background(), pdata.NewLogs(), nil), + newLogsRequest(context.Background(), plog.NewLogs(), nil), lr.onError(logErr), ) } @@ -77,7 +77,7 @@ func TestLogsExporter_NilPushLogsData(t *testing.T) { } func TestLogsExporter_Default(t *testing.T) { - ld := pdata.NewLogs() + ld := plog.NewLogs() le, err := NewLogsExporter(&fakeLogsExporterConfig, componenttest.NewNopExporterCreateSettings(), newPushLogsData(nil)) assert.NotNil(t, le) assert.NoError(t, err) @@ -98,7 +98,7 @@ func TestLogsExporter_WithCapabilities(t *testing.T) { } func TestLogsExporter_Default_ReturnError(t *testing.T) { - ld := pdata.NewLogs() + ld := plog.NewLogs() want := errors.New("my_error") le, err := NewLogsExporter(&fakeLogsExporterConfig, componenttest.NewNopExporterCreateSettings(), newPushLogsData(want)) require.NoError(t, err) @@ -199,7 +199,7 @@ func TestLogsExporter_WithShutdown_ReturnError(t *testing.T) { } func newPushLogsData(retError error) consumer.ConsumeLogsFunc { - return func(ctx context.Context, td pdata.Logs) error { + return func(ctx context.Context, td plog.Logs) error { return retError } } diff --git a/exporter/exporterhelper/metrics.go b/exporter/exporterhelper/metrics.go index f17eefee955..05def85ae02 100644 --- a/exporter/exporterhelper/metrics.go +++ b/exporter/exporterhelper/metrics.go @@ -23,20 +23,19 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter/exporterhelper/internal" - "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" ) -var metricsMarshaler = otlp.NewProtobufMetricsMarshaler() -var metricsUnmarshaler = otlp.NewProtobufMetricsUnmarshaler() +var metricsMarshaler = pmetric.NewProtoMarshaler() +var metricsUnmarshaler = pmetric.NewProtoUnmarshaler() type metricsRequest struct { baseRequest - md pdata.Metrics + md pmetric.Metrics pusher consumer.ConsumeMetricsFunc } -func newMetricsRequest(ctx context.Context, md pdata.Metrics, pusher consumer.ConsumeMetricsFunc) request { +func newMetricsRequest(ctx context.Context, md pmetric.Metrics, pusher consumer.ConsumeMetricsFunc) request { return &metricsRequest{ baseRequest: baseRequest{ctx: ctx}, md: md, @@ -108,7 +107,7 @@ func NewMetricsExporter( } }) - mc, err := consumer.NewMetrics(func(ctx context.Context, md pdata.Metrics) error { + mc, err := consumer.NewMetrics(func(ctx context.Context, md pmetric.Metrics) error { req := newMetricsRequest(ctx, md, pusher) err := be.sender.send(req) if errors.Is(err, errSendingQueueIsFull) { diff --git a/exporter/exporterhelper/metrics_test.go b/exporter/exporterhelper/metrics_test.go index 0dfc62db76a..7d050d8725e 100644 --- a/exporter/exporterhelper/metrics_test.go +++ b/exporter/exporterhelper/metrics_test.go @@ -33,8 +33,8 @@ import ( "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" "go.opentelemetry.io/collector/obsreport/obsreporttest" + "go.opentelemetry.io/collector/pdata/pmetric" ) const ( @@ -49,10 +49,10 @@ var ( func TestMetricsRequest(t *testing.T) { mr := newMetricsRequest(context.Background(), testdata.GenerateMetricsOneMetric(), nil) - metricsErr := consumererror.NewMetrics(errors.New("some error"), pdata.NewMetrics()) + metricsErr := consumererror.NewMetrics(errors.New("some error"), pmetric.NewMetrics()) assert.EqualValues( t, - newMetricsRequest(context.Background(), pdata.NewMetrics(), nil), + newMetricsRequest(context.Background(), pmetric.NewMetrics(), nil), mr.onError(metricsErr), ) } @@ -76,7 +76,7 @@ func TestMetricsExporter_NilPushMetricsData(t *testing.T) { } func TestMetricsExporter_Default(t *testing.T) { - md := pdata.NewMetrics() + md := pmetric.NewMetrics() me, err := NewMetricsExporter(&fakeMetricsExporterConfig, componenttest.NewNopExporterCreateSettings(), newPushMetricsData(nil)) assert.NoError(t, err) assert.NotNil(t, me) @@ -97,7 +97,7 @@ func TestMetricsExporter_WithCapabilities(t *testing.T) { } func TestMetricsExporter_Default_ReturnError(t *testing.T) { - md := pdata.NewMetrics() + md := pmetric.NewMetrics() want := errors.New("my_error") me, err := NewMetricsExporter(&fakeMetricsExporterConfig, componenttest.NewNopExporterCreateSettings(), newPushMetricsData(want)) require.NoError(t, err) @@ -200,7 +200,7 @@ func TestMetricsExporter_WithShutdown_ReturnError(t *testing.T) { } func newPushMetricsData(retError error) consumer.ConsumeMetricsFunc { - return func(ctx context.Context, td pdata.Metrics) error { + return func(ctx context.Context, td pmetric.Metrics) error { return retError } } diff --git a/exporter/exporterhelper/queued_retry_test.go b/exporter/exporterhelper/queued_retry_test.go index 34c9b77daed..8cd3955ba8e 100644 --- a/exporter/exporterhelper/queued_retry_test.go +++ b/exporter/exporterhelper/queued_retry_test.go @@ -33,9 +33,8 @@ import ( "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter/exporterhelper/internal" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/pdata" "go.opentelemetry.io/collector/obsreport/obsreporttest" + "go.opentelemetry.io/collector/pdata/ptrace" ) func mockRequestUnmarshaler(mr *mockRequest) internal.RequestUnmarshaler { @@ -428,7 +427,7 @@ func (m *mockRequest) export(ctx context.Context) error { } func (m *mockRequest) Marshal() ([]byte, error) { - return otlp.NewProtobufTracesMarshaler().MarshalTraces(pdata.NewTraces()) + return ptrace.NewProtoMarshaler().MarshalTraces(ptrace.NewTraces()) } func (m *mockRequest) onError(error) request { diff --git a/exporter/exporterhelper/traces.go b/exporter/exporterhelper/traces.go index 1a10fb4c9c9..641d8801069 100644 --- a/exporter/exporterhelper/traces.go +++ b/exporter/exporterhelper/traces.go @@ -23,20 +23,19 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter/exporterhelper/internal" - "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) -var tracesMarshaler = otlp.NewProtobufTracesMarshaler() -var tracesUnmarshaler = otlp.NewProtobufTracesUnmarshaler() +var tracesMarshaler = ptrace.NewProtoMarshaler() +var tracesUnmarshaler = ptrace.NewProtoUnmarshaler() type tracesRequest struct { baseRequest - td pdata.Traces + td ptrace.Traces pusher consumer.ConsumeTracesFunc } -func newTracesRequest(ctx context.Context, td pdata.Traces, pusher consumer.ConsumeTracesFunc) request { +func newTracesRequest(ctx context.Context, td ptrace.Traces, pusher consumer.ConsumeTracesFunc) request { return &tracesRequest{ baseRequest: baseRequest{ctx: ctx}, td: td, @@ -109,7 +108,7 @@ func NewTracesExporter( } }) - tc, err := consumer.NewTraces(func(ctx context.Context, td pdata.Traces) error { + tc, err := consumer.NewTraces(func(ctx context.Context, td ptrace.Traces) error { req := newTracesRequest(ctx, td, pusher) err := be.sender.send(req) if errors.Is(err, errSendingQueueIsFull) { diff --git a/exporter/exporterhelper/traces_test.go b/exporter/exporterhelper/traces_test.go index efa81c908c9..7fd571d887e 100644 --- a/exporter/exporterhelper/traces_test.go +++ b/exporter/exporterhelper/traces_test.go @@ -33,8 +33,8 @@ import ( "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" "go.opentelemetry.io/collector/obsreport/obsreporttest" + "go.opentelemetry.io/collector/pdata/ptrace" ) const ( @@ -49,8 +49,8 @@ var ( func TestTracesRequest(t *testing.T) { mr := newTracesRequest(context.Background(), testdata.GenerateTracesOneSpan(), nil) - traceErr := consumererror.NewTraces(errors.New("some error"), pdata.NewTraces()) - assert.EqualValues(t, newTracesRequest(context.Background(), pdata.NewTraces(), nil), mr.onError(traceErr)) + traceErr := consumererror.NewTraces(errors.New("some error"), ptrace.NewTraces()) + assert.EqualValues(t, newTracesRequest(context.Background(), ptrace.NewTraces(), nil), mr.onError(traceErr)) } func TestTracesExporter_InvalidName(t *testing.T) { @@ -72,7 +72,7 @@ func TestTracesExporter_NilPushTraceData(t *testing.T) { } func TestTracesExporter_Default(t *testing.T) { - td := pdata.NewTraces() + td := ptrace.NewTraces() te, err := NewTracesExporter(&fakeTracesExporterConfig, componenttest.NewNopExporterCreateSettings(), newTraceDataPusher(nil)) assert.NotNil(t, te) assert.NoError(t, err) @@ -93,7 +93,7 @@ func TestTracesExporter_WithCapabilities(t *testing.T) { } func TestTracesExporter_Default_ReturnError(t *testing.T) { - td := pdata.NewTraces() + td := ptrace.NewTraces() want := errors.New("my_error") te, err := NewTracesExporter(&fakeTracesExporterConfig, componenttest.NewNopExporterCreateSettings(), newTraceDataPusher(want)) require.NoError(t, err) @@ -200,7 +200,7 @@ func TestTracesExporter_WithShutdown_ReturnError(t *testing.T) { } func newTraceDataPusher(retError error) consumer.ConsumeTracesFunc { - return func(ctx context.Context, td pdata.Traces) error { + return func(ctx context.Context, td ptrace.Traces) error { return retError } } @@ -225,7 +225,7 @@ func checkRecordedMetricsForTracesExporter(t *testing.T, te component.TracesExpo } func generateTraceTraffic(t *testing.T, tracer trace.Tracer, te component.TracesExporter, numRequests int, wantError error) { - td := pdata.NewTraces() + td := ptrace.NewTraces() td.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty().Spans().AppendEmpty() ctx, span := tracer.Start(context.Background(), fakeTraceParentSpanName) defer span.End() diff --git a/exporter/loggingexporter/logging_exporter.go b/exporter/loggingexporter/logging_exporter.go index 301e1b372b6..fb86e6ca7bc 100644 --- a/exporter/loggingexporter/logging_exporter.go +++ b/exporter/loggingexporter/logging_exporter.go @@ -26,17 +26,19 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter/exporterhelper" "go.opentelemetry.io/collector/internal/otlptext" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) type loggingExporter struct { logger *zap.Logger - logsMarshaler pdata.LogsMarshaler - metricsMarshaler pdata.MetricsMarshaler - tracesMarshaler pdata.TracesMarshaler + logsMarshaler plog.Marshaler + metricsMarshaler pmetric.Marshaler + tracesMarshaler ptrace.Marshaler } -func (s *loggingExporter) pushTraces(_ context.Context, td pdata.Traces) error { +func (s *loggingExporter) pushTraces(_ context.Context, td ptrace.Traces) error { s.logger.Info("TracesExporter", zap.Int("#spans", td.SpanCount())) if !s.logger.Core().Enabled(zapcore.DebugLevel) { return nil @@ -50,7 +52,7 @@ func (s *loggingExporter) pushTraces(_ context.Context, td pdata.Traces) error { return nil } -func (s *loggingExporter) pushMetrics(_ context.Context, md pdata.Metrics) error { +func (s *loggingExporter) pushMetrics(_ context.Context, md pmetric.Metrics) error { s.logger.Info("MetricsExporter", zap.Int("#metrics", md.MetricCount())) if !s.logger.Core().Enabled(zapcore.DebugLevel) { @@ -65,7 +67,7 @@ func (s *loggingExporter) pushMetrics(_ context.Context, md pdata.Metrics) error return nil } -func (s *loggingExporter) pushLogs(_ context.Context, ld pdata.Logs) error { +func (s *loggingExporter) pushLogs(_ context.Context, ld plog.Logs) error { s.logger.Info("LogsExporter", zap.Int("#logs", ld.LogRecordCount())) if !s.logger.Core().Enabled(zapcore.DebugLevel) { diff --git a/exporter/loggingexporter/logging_exporter_test.go b/exporter/loggingexporter/logging_exporter_test.go index d6ec66b5af5..473b2c04d22 100644 --- a/exporter/loggingexporter/logging_exporter_test.go +++ b/exporter/loggingexporter/logging_exporter_test.go @@ -26,7 +26,9 @@ import ( "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) func TestLoggingTracesExporterNoErrors(t *testing.T) { @@ -34,7 +36,7 @@ func TestLoggingTracesExporterNoErrors(t *testing.T) { require.NotNil(t, lte) assert.NoError(t, err) - assert.NoError(t, lte.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.NoError(t, lte.ConsumeTraces(context.Background(), ptrace.NewTraces())) assert.NoError(t, lte.ConsumeTraces(context.Background(), testdata.GenerateTracesTwoSpansSameResourceOneDifferent())) assert.NoError(t, lte.Shutdown(context.Background())) @@ -45,7 +47,7 @@ func TestLoggingMetricsExporterNoErrors(t *testing.T) { require.NotNil(t, lme) assert.NoError(t, err) - assert.NoError(t, lme.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.NoError(t, lme.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) assert.NoError(t, lme.ConsumeMetrics(context.Background(), testdata.GeneratMetricsAllTypesWithSampleDatapoints())) assert.NoError(t, lme.ConsumeMetrics(context.Background(), testdata.GenerateMetricsAllTypesEmptyDataPoint())) assert.NoError(t, lme.ConsumeMetrics(context.Background(), testdata.GenerateMetricsMetricTypeInvalid())) @@ -58,7 +60,7 @@ func TestLoggingLogsExporterNoErrors(t *testing.T) { require.NotNil(t, lle) assert.NoError(t, err) - assert.NoError(t, lle.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.NoError(t, lle.ConsumeLogs(context.Background(), plog.NewLogs())) assert.NoError(t, lle.ConsumeLogs(context.Background(), testdata.GenerateLogsOneEmptyResourceLogs())) assert.NoError(t, lle.ConsumeLogs(context.Background(), testdata.GenerateLogsNoLogRecords())) assert.NoError(t, lle.ConsumeLogs(context.Background(), testdata.GenerateLogsOneEmptyLogRecord())) @@ -74,23 +76,23 @@ func TestLoggingExporterErrors(t *testing.T) { le.tracesMarshaler = &errMarshaler{err: errWant} le.metricsMarshaler = &errMarshaler{err: errWant} le.logsMarshaler = &errMarshaler{err: errWant} - assert.Equal(t, errWant, le.pushTraces(context.Background(), pdata.NewTraces())) - assert.Equal(t, errWant, le.pushMetrics(context.Background(), pdata.NewMetrics())) - assert.Equal(t, errWant, le.pushLogs(context.Background(), pdata.NewLogs())) + assert.Equal(t, errWant, le.pushTraces(context.Background(), ptrace.NewTraces())) + assert.Equal(t, errWant, le.pushMetrics(context.Background(), pmetric.NewMetrics())) + assert.Equal(t, errWant, le.pushLogs(context.Background(), plog.NewLogs())) } type errMarshaler struct { err error } -func (e errMarshaler) MarshalLogs(pdata.Logs) ([]byte, error) { +func (e errMarshaler) MarshalLogs(plog.Logs) ([]byte, error) { return nil, e.err } -func (e errMarshaler) MarshalMetrics(pdata.Metrics) ([]byte, error) { +func (e errMarshaler) MarshalMetrics(pmetric.Metrics) ([]byte, error) { return nil, e.err } -func (e errMarshaler) MarshalTraces(pdata.Traces) ([]byte, error) { +func (e errMarshaler) MarshalTraces(ptrace.Traces) ([]byte, error) { return nil, e.err } diff --git a/exporter/otlpexporter/otlp.go b/exporter/otlpexporter/otlp.go index e8adbf44417..83138775b3c 100644 --- a/exporter/otlpexporter/otlp.go +++ b/exporter/otlpexporter/otlp.go @@ -31,8 +31,12 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter/exporterhelper" - "go.opentelemetry.io/collector/model/otlpgrpc" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/plog/plogotlp" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp" + "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" ) type exporter struct { @@ -40,9 +44,9 @@ type exporter struct { config *Config // gRPC clients and connection. - traceExporter otlpgrpc.TracesClient - metricExporter otlpgrpc.MetricsClient - logExporter otlpgrpc.LogsClient + traceExporter ptraceotlp.Client + metricExporter pmetricotlp.Client + logExporter plogotlp.Client clientConn *grpc.ClientConn metadata metadata.MD callOptions []grpc.CallOption @@ -81,9 +85,9 @@ func (e *exporter) start(_ context.Context, host component.Host) (err error) { return err } - e.traceExporter = otlpgrpc.NewTracesClient(e.clientConn) - e.metricExporter = otlpgrpc.NewMetricsClient(e.clientConn) - e.logExporter = otlpgrpc.NewLogsClient(e.clientConn) + e.traceExporter = ptraceotlp.NewClient(e.clientConn) + e.metricExporter = pmetricotlp.NewClient(e.clientConn) + e.logExporter = plogotlp.NewClient(e.clientConn) e.metadata = metadata.New(e.config.GRPCClientSettings.Headers) e.callOptions = []grpc.CallOption{ grpc.WaitForReady(e.config.GRPCClientSettings.WaitForReady), @@ -96,22 +100,22 @@ func (e *exporter) shutdown(context.Context) error { return e.clientConn.Close() } -func (e *exporter) pushTraces(ctx context.Context, td pdata.Traces) error { - req := otlpgrpc.NewTracesRequest() +func (e *exporter) pushTraces(ctx context.Context, td ptrace.Traces) error { + req := ptraceotlp.NewRequest() req.SetTraces(td) _, err := e.traceExporter.Export(e.enhanceContext(ctx), req, e.callOptions...) return processError(err) } -func (e *exporter) pushMetrics(ctx context.Context, md pdata.Metrics) error { - req := otlpgrpc.NewMetricsRequest() +func (e *exporter) pushMetrics(ctx context.Context, md pmetric.Metrics) error { + req := pmetricotlp.NewRequest() req.SetMetrics(md) _, err := e.metricExporter.Export(e.enhanceContext(ctx), req, e.callOptions...) return processError(err) } -func (e *exporter) pushLogs(ctx context.Context, ld pdata.Logs) error { - req := otlpgrpc.NewLogsRequest() +func (e *exporter) pushLogs(ctx context.Context, ld plog.Logs) error { + req := plogotlp.NewRequest() req.SetLogs(ld) _, err := e.logExporter.Export(e.enhanceContext(ctx), req, e.callOptions...) return processError(err) diff --git a/exporter/otlpexporter/otlp_test.go b/exporter/otlpexporter/otlp_test.go index 90075c4c075..ee0b96a5273 100644 --- a/exporter/otlpexporter/otlp_test.go +++ b/exporter/otlpexporter/otlp_test.go @@ -35,8 +35,12 @@ import ( "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/otlpgrpc" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/plog/plogotlp" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp" + "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" ) type mockReceiver struct { @@ -55,10 +59,10 @@ func (r *mockReceiver) GetMetadata() metadata.MD { type mockTracesReceiver struct { mockReceiver - lastRequest pdata.Traces + lastRequest ptrace.Traces } -func (r *mockTracesReceiver) Export(ctx context.Context, req otlpgrpc.TracesRequest) (otlpgrpc.TracesResponse, error) { +func (r *mockTracesReceiver) Export(ctx context.Context, req ptraceotlp.Request) (ptraceotlp.Response, error) { atomic.AddInt32(&r.requestCount, 1) td := req.Traces() atomic.AddInt32(&r.totalItems, int32(td.SpanCount())) @@ -66,10 +70,10 @@ func (r *mockTracesReceiver) Export(ctx context.Context, req otlpgrpc.TracesRequ defer r.mux.Unlock() r.lastRequest = td r.metadata, _ = metadata.FromIncomingContext(ctx) - return otlpgrpc.NewTracesResponse(), nil + return ptraceotlp.NewResponse(), nil } -func (r *mockTracesReceiver) GetLastRequest() pdata.Traces { +func (r *mockTracesReceiver) GetLastRequest() ptrace.Traces { r.mux.Lock() defer r.mux.Unlock() return r.lastRequest @@ -98,7 +102,7 @@ func otlpTracesReceiverOnGRPCServer(ln net.Listener, useTLS bool) (*mockTracesRe } // Now run it as a gRPC server - otlpgrpc.RegisterTracesServer(rcv.srv, rcv) + ptraceotlp.RegisterServer(rcv.srv, rcv) go func() { _ = rcv.srv.Serve(ln) }() @@ -108,10 +112,10 @@ func otlpTracesReceiverOnGRPCServer(ln net.Listener, useTLS bool) (*mockTracesRe type mockLogsReceiver struct { mockReceiver - lastRequest pdata.Logs + lastRequest plog.Logs } -func (r *mockLogsReceiver) Export(ctx context.Context, req otlpgrpc.LogsRequest) (otlpgrpc.LogsResponse, error) { +func (r *mockLogsReceiver) Export(ctx context.Context, req plogotlp.Request) (plogotlp.Response, error) { atomic.AddInt32(&r.requestCount, 1) ld := req.Logs() atomic.AddInt32(&r.totalItems, int32(ld.LogRecordCount())) @@ -119,10 +123,10 @@ func (r *mockLogsReceiver) Export(ctx context.Context, req otlpgrpc.LogsRequest) defer r.mux.Unlock() r.lastRequest = ld r.metadata, _ = metadata.FromIncomingContext(ctx) - return otlpgrpc.NewLogsResponse(), nil + return plogotlp.NewResponse(), nil } -func (r *mockLogsReceiver) GetLastRequest() pdata.Logs { +func (r *mockLogsReceiver) GetLastRequest() plog.Logs { r.mux.Lock() defer r.mux.Unlock() return r.lastRequest @@ -136,7 +140,7 @@ func otlpLogsReceiverOnGRPCServer(ln net.Listener) *mockLogsReceiver { } // Now run it as a gRPC server - otlpgrpc.RegisterLogsServer(rcv.srv, rcv) + plogotlp.RegisterServer(rcv.srv, rcv) go func() { _ = rcv.srv.Serve(ln) }() @@ -146,10 +150,10 @@ func otlpLogsReceiverOnGRPCServer(ln net.Listener) *mockLogsReceiver { type mockMetricsReceiver struct { mockReceiver - lastRequest pdata.Metrics + lastRequest pmetric.Metrics } -func (r *mockMetricsReceiver) Export(ctx context.Context, req otlpgrpc.MetricsRequest) (otlpgrpc.MetricsResponse, error) { +func (r *mockMetricsReceiver) Export(ctx context.Context, req pmetricotlp.Request) (pmetricotlp.Response, error) { md := req.Metrics() atomic.AddInt32(&r.requestCount, 1) atomic.AddInt32(&r.totalItems, int32(md.DataPointCount())) @@ -157,10 +161,10 @@ func (r *mockMetricsReceiver) Export(ctx context.Context, req otlpgrpc.MetricsRe defer r.mux.Unlock() r.lastRequest = md r.metadata, _ = metadata.FromIncomingContext(ctx) - return otlpgrpc.NewMetricsResponse(), nil + return pmetricotlp.NewResponse(), nil } -func (r *mockMetricsReceiver) GetLastRequest() pdata.Metrics { +func (r *mockMetricsReceiver) GetLastRequest() pmetric.Metrics { r.mux.Lock() defer r.mux.Unlock() return r.lastRequest @@ -174,7 +178,7 @@ func otlpMetricsReceiverOnGRPCServer(ln net.Listener) *mockMetricsReceiver { } // Now run it as a gRPC server - otlpgrpc.RegisterMetricsServer(rcv.srv, rcv) + pmetricotlp.RegisterServer(rcv.srv, rcv) go func() { _ = rcv.srv.Serve(ln) }() @@ -220,7 +224,7 @@ func TestSendTraces(t *testing.T) { assert.EqualValues(t, 0, atomic.LoadInt32(&rcv.requestCount)) // Send empty trace. - td := pdata.NewTraces() + td := ptrace.NewTraces() assert.NoError(t, exp.ConsumeTraces(context.Background(), td)) // Wait until it is received. @@ -314,7 +318,7 @@ func TestSendTracesWhenEndpointHasHttpScheme(t *testing.T) { assert.EqualValues(t, 0, atomic.LoadInt32(&rcv.requestCount)) // Send empty trace. - td := pdata.NewTraces() + td := ptrace.NewTraces() assert.NoError(t, exp.ConsumeTraces(context.Background(), td)) // Wait until it is received. @@ -366,7 +370,7 @@ func TestSendMetrics(t *testing.T) { assert.EqualValues(t, 0, atomic.LoadInt32(&rcv.requestCount)) // Send empty metric. - md := pdata.NewMetrics() + md := pmetric.NewMetrics() assert.NoError(t, exp.ConsumeMetrics(context.Background(), md)) // Wait until it is received. @@ -513,7 +517,7 @@ func TestSendTraceDataServerStartWhileRequest(t *testing.T) { cancel() } -func startServerAndMakeRequest(t *testing.T, exp component.TracesExporter, td pdata.Traces, ln net.Listener) { +func startServerAndMakeRequest(t *testing.T, exp component.TracesExporter, td ptrace.Traces, ln net.Listener) { rcv, _ := otlpTracesReceiverOnGRPCServer(ln, false) defer rcv.srv.GracefulStop() // Ensure that initially there is no data in the receiver. @@ -572,7 +576,7 @@ func TestSendLogData(t *testing.T) { assert.EqualValues(t, 0, atomic.LoadInt32(&rcv.requestCount)) // Send empty request. - ld := pdata.NewLogs() + ld := plog.NewLogs() assert.NoError(t, exp.ConsumeLogs(context.Background(), ld)) // Wait until it is received. diff --git a/exporter/otlphttpexporter/otlp.go b/exporter/otlphttpexporter/otlp.go index 717e00e4931..2a02d7eb653 100644 --- a/exporter/otlphttpexporter/otlp.go +++ b/exporter/otlphttpexporter/otlp.go @@ -35,8 +35,12 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter/exporterhelper" - "go.opentelemetry.io/collector/model/otlpgrpc" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/plog/plogotlp" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp" + "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" ) type exporter struct { @@ -91,8 +95,8 @@ func (e *exporter) start(_ context.Context, host component.Host) error { return nil } -func (e *exporter) pushTraces(ctx context.Context, td pdata.Traces) error { - tr := otlpgrpc.NewTracesRequest() +func (e *exporter) pushTraces(ctx context.Context, td ptrace.Traces) error { + tr := ptraceotlp.NewRequest() tr.SetTraces(td) request, err := tr.MarshalProto() if err != nil { @@ -102,8 +106,8 @@ func (e *exporter) pushTraces(ctx context.Context, td pdata.Traces) error { return e.export(ctx, e.tracesURL, request) } -func (e *exporter) pushMetrics(ctx context.Context, md pdata.Metrics) error { - tr := otlpgrpc.NewMetricsRequest() +func (e *exporter) pushMetrics(ctx context.Context, md pmetric.Metrics) error { + tr := pmetricotlp.NewRequest() tr.SetMetrics(md) request, err := tr.MarshalProto() if err != nil { @@ -112,8 +116,8 @@ func (e *exporter) pushMetrics(ctx context.Context, md pdata.Metrics) error { return e.export(ctx, e.metricsURL, request) } -func (e *exporter) pushLogs(ctx context.Context, ld pdata.Logs) error { - tr := otlpgrpc.NewLogsRequest() +func (e *exporter) pushLogs(ctx context.Context, ld plog.Logs) error { + tr := plogotlp.NewRequest() tr.SetLogs(ld) request, err := tr.MarshalProto() if err != nil { diff --git a/exporter/otlphttpexporter/otlp_test.go b/exporter/otlphttpexporter/otlp_test.go index d4391d5a1df..ebd4bfdcf6e 100644 --- a/exporter/otlphttpexporter/otlp_test.go +++ b/exporter/otlphttpexporter/otlp_test.go @@ -45,8 +45,11 @@ import ( "go.opentelemetry.io/collector/exporter/exporterhelper" "go.opentelemetry.io/collector/internal/testdata" "go.opentelemetry.io/collector/internal/testutil" - "go.opentelemetry.io/collector/model/otlpgrpc" - "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.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" "go.opentelemetry.io/collector/receiver/otlpreceiver" ) @@ -256,7 +259,7 @@ func TestIssue_4221(t *testing.T) { assert.Equal(t, "CscBCkkKIAoMc2VydmljZS5uYW1lEhAKDnVvcC5zdGFnZS1ldS0xCiUKGW91dHN5c3RlbXMubW9kdWxlLnZlcnNpb24SCAoGOTAzMzg2EnoKEQoMdW9wX2NhbmFyaWVzEgExEmUKEEMDhT8Ib0+Mhs8Zi2VR34QSCOVRPDJ5XEG5IgA5QE41aASRrxZBQE41aASRrxZKEAoKc3Bhbl9pbmRleBICGANKHwoNY29kZS5mdW5jdGlvbhIOCgxteUZ1bmN0aW9uMzZ6AA==", base64Data) unbase64Data, err := base64.StdEncoding.DecodeString(base64Data) require.NoError(t, err) - tr := otlpgrpc.NewTracesRequest() + tr := ptraceotlp.NewRequest() require.NoError(t, tr.UnmarshalProto(unbase64Data)) span := tr.Traces().ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0) assert.Equal(t, "4303853f086f4f8c86cf198b6551df84", span.TraceID().HexString()) @@ -265,7 +268,7 @@ func TestIssue_4221(t *testing.T) { exp := startTracesExporter(t, "", svr.URL) - md := pdata.NewTraces() + md := ptrace.NewTraces() rms := md.ResourceSpans().AppendEmpty() rms.Resource().Attributes().UpsertString("service.name", "uop.stage-eu-1") rms.Resource().Attributes().UpsertString("outsystems.module.version", "903386") @@ -278,14 +281,14 @@ func TestIssue_4221(t *testing.T) { traceIDBytesSlice, err := hex.DecodeString("4303853f086f4f8c86cf198b6551df84") require.NoError(t, err) copy(traceIDBytes[:], traceIDBytesSlice) - span.SetTraceID(pdata.NewTraceID(traceIDBytes)) + span.SetTraceID(pcommon.NewTraceID(traceIDBytes)) assert.Equal(t, "4303853f086f4f8c86cf198b6551df84", span.TraceID().HexString()) var spanIDBytes [8]byte spanIDBytesSlice, err := hex.DecodeString("e5513c32795c41b9") require.NoError(t, err) copy(spanIDBytes[:], spanIDBytesSlice) - span.SetSpanID(pdata.NewSpanID(spanIDBytes)) + span.SetSpanID(pcommon.NewSpanID(spanIDBytes)) assert.Equal(t, "e5513c32795c41b9", span.SpanID().HexString()) span.SetEndTimestamp(1634684637873000000) @@ -464,7 +467,7 @@ func TestErrorResponses(t *testing.T) { }) // generate traces - traces := pdata.NewTraces() + traces := ptrace.NewTraces() err = exp.ConsumeTraces(context.Background(), traces) assert.Error(t, err) @@ -542,7 +545,7 @@ func TestUserAgent(t *testing.T) { }) // generate data - traces := pdata.NewTraces() + traces := ptrace.NewTraces() err = exp.ConsumeTraces(context.Background(), traces) require.NoError(t, err) @@ -587,7 +590,7 @@ func TestUserAgent(t *testing.T) { }) // generate data - metrics := pdata.NewMetrics() + metrics := pmetric.NewMetrics() err = exp.ConsumeMetrics(context.Background(), metrics) require.NoError(t, err) @@ -632,7 +635,7 @@ func TestUserAgent(t *testing.T) { }) // generate data - logs := pdata.NewLogs() + logs := plog.NewLogs() err = exp.ConsumeLogs(context.Background(), logs) require.NoError(t, err) diff --git a/go.mod b/go.mod index e39f1354cc8..802008a20fc 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ require ( github.com/stretchr/testify v1.7.1 go.opencensus.io v0.23.0 go.opentelemetry.io/collector/model v0.48.0 + go.opentelemetry.io/collector/pdata v0.0.0-00010101000000-000000000000 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.31.0 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 go.opentelemetry.io/contrib/zpages v0.31.0 @@ -76,4 +77,6 @@ require ( replace go.opentelemetry.io/collector/model => ./model +replace go.opentelemetry.io/collector/pdata => ./pdata + retract v0.32.0 // Contains incomplete metrics transition to proto 0.9.0, random components are not working. diff --git a/internal/internalconsumertest/err_or_sink_consumer.go b/internal/internalconsumertest/err_or_sink_consumer.go index fb5f8914bf7..6936e07246d 100644 --- a/internal/internalconsumertest/err_or_sink_consumer.go +++ b/internal/internalconsumertest/err_or_sink_consumer.go @@ -20,7 +20,8 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) type ErrOrSinkConsumer struct { @@ -42,7 +43,7 @@ func (esc *ErrOrSinkConsumer) Capabilities() consumer.Capabilities { } // ConsumeTraces stores traces to this sink. -func (esc *ErrOrSinkConsumer) ConsumeTraces(ctx context.Context, td pdata.Traces) error { +func (esc *ErrOrSinkConsumer) ConsumeTraces(ctx context.Context, td ptrace.Traces) error { esc.mu.Lock() defer esc.mu.Unlock() @@ -54,7 +55,7 @@ func (esc *ErrOrSinkConsumer) ConsumeTraces(ctx context.Context, td pdata.Traces } // ConsumeMetrics stores metrics to this sink. -func (esc *ErrOrSinkConsumer) ConsumeMetrics(ctx context.Context, md pdata.Metrics) error { +func (esc *ErrOrSinkConsumer) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error { esc.mu.Lock() defer esc.mu.Unlock() diff --git a/internal/otlptext/databuffer.go b/internal/otlptext/databuffer.go index 356e26b91ab..b6b3f168589 100644 --- a/internal/otlptext/databuffer.go +++ b/internal/otlptext/databuffer.go @@ -21,7 +21,9 @@ import ( "strconv" "strings" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) type dataBuffer struct { @@ -37,26 +39,26 @@ func (b *dataBuffer) logAttr(label string, value string) { b.logEntry(" %-15s: %s", label, value) } -func (b *dataBuffer) logAttributes(label string, m pdata.Map) { +func (b *dataBuffer) logAttributes(label string, m pcommon.Map) { if m.Len() == 0 { return } b.logEntry("%s:", label) - m.Range(func(k string, v pdata.Value) bool { + m.Range(func(k string, v pcommon.Value) bool { b.logEntry(" -> %s: %s(%s)", k, v.Type().String(), attributeValueToString(v)) return true }) } -func (b *dataBuffer) logInstrumentationScope(il pdata.InstrumentationScope) { +func (b *dataBuffer) logInstrumentationScope(il pcommon.InstrumentationScope) { b.logEntry( "InstrumentationScope %s %s", il.Name(), il.Version()) } -func (b *dataBuffer) logMetricDescriptor(md pdata.Metric) { +func (b *dataBuffer) logMetricDescriptor(md pmetric.Metric) { b.logEntry("Descriptor:") b.logEntry(" -> Name: %s", md.Name()) b.logEntry(" -> Description: %s", md.Description()) @@ -64,32 +66,32 @@ func (b *dataBuffer) logMetricDescriptor(md pdata.Metric) { b.logEntry(" -> DataType: %s", md.DataType().String()) } -func (b *dataBuffer) logMetricDataPoints(m pdata.Metric) { +func (b *dataBuffer) logMetricDataPoints(m pmetric.Metric) { switch m.DataType() { - case pdata.MetricDataTypeNone: + case pmetric.MetricDataTypeNone: return - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: b.logNumberDataPoints(m.Gauge().DataPoints()) - case pdata.MetricDataTypeSum: + case pmetric.MetricDataTypeSum: data := m.Sum() b.logEntry(" -> IsMonotonic: %t", data.IsMonotonic()) b.logEntry(" -> AggregationTemporality: %s", data.AggregationTemporality().String()) b.logNumberDataPoints(data.DataPoints()) - case pdata.MetricDataTypeHistogram: + case pmetric.MetricDataTypeHistogram: data := m.Histogram() b.logEntry(" -> AggregationTemporality: %s", data.AggregationTemporality().String()) b.logDoubleHistogramDataPoints(data.DataPoints()) - case pdata.MetricDataTypeExponentialHistogram: + case pmetric.MetricDataTypeExponentialHistogram: data := m.ExponentialHistogram() b.logEntry(" -> AggregationTemporality: %s", data.AggregationTemporality().String()) b.logExponentialHistogramDataPoints(data.DataPoints()) - case pdata.MetricDataTypeSummary: + case pmetric.MetricDataTypeSummary: data := m.Summary() b.logDoubleSummaryDataPoints(data.DataPoints()) } } -func (b *dataBuffer) logNumberDataPoints(ps pdata.NumberDataPointSlice) { +func (b *dataBuffer) logNumberDataPoints(ps pmetric.NumberDataPointSlice) { for i := 0; i < ps.Len(); i++ { p := ps.At(i) b.logEntry("NumberDataPoints #%d", i) @@ -98,15 +100,15 @@ func (b *dataBuffer) logNumberDataPoints(ps pdata.NumberDataPointSlice) { b.logEntry("StartTimestamp: %s", p.StartTimestamp()) b.logEntry("Timestamp: %s", p.Timestamp()) switch p.ValueType() { - case pdata.MetricValueTypeInt: + case pmetric.MetricValueTypeInt: b.logEntry("Value: %d", p.IntVal()) - case pdata.MetricValueTypeDouble: + case pmetric.MetricValueTypeDouble: b.logEntry("Value: %f", p.DoubleVal()) } } } -func (b *dataBuffer) logDoubleHistogramDataPoints(ps pdata.HistogramDataPointSlice) { +func (b *dataBuffer) logDoubleHistogramDataPoints(ps pmetric.HistogramDataPointSlice) { for i := 0; i < ps.Len(); i++ { p := ps.At(i) b.logEntry("HistogramDataPoints #%d", i) @@ -133,7 +135,7 @@ func (b *dataBuffer) logDoubleHistogramDataPoints(ps pdata.HistogramDataPointSli } } -func (b *dataBuffer) logExponentialHistogramDataPoints(ps pdata.ExponentialHistogramDataPointSlice) { +func (b *dataBuffer) logExponentialHistogramDataPoints(ps pmetric.ExponentialHistogramDataPointSlice) { for i := 0; i < ps.Len(); i++ { p := ps.At(i) b.logEntry("ExponentialHistogramDataPoints #%d", i) @@ -181,7 +183,7 @@ func (b *dataBuffer) logExponentialHistogramDataPoints(ps pdata.ExponentialHisto } } -func (b *dataBuffer) logDoubleSummaryDataPoints(ps pdata.SummaryDataPointSlice) { +func (b *dataBuffer) logDoubleSummaryDataPoints(ps pmetric.SummaryDataPointSlice) { for i := 0; i < ps.Len(); i++ { p := ps.At(i) b.logEntry("SummaryDataPoints #%d", i) @@ -200,11 +202,11 @@ func (b *dataBuffer) logDoubleSummaryDataPoints(ps pdata.SummaryDataPointSlice) } } -func (b *dataBuffer) logDataPointAttributes(labels pdata.Map) { +func (b *dataBuffer) logDataPointAttributes(labels pcommon.Map) { b.logAttributes("Data point attributes", labels) } -func (b *dataBuffer) logEvents(description string, se pdata.SpanEventSlice) { +func (b *dataBuffer) logEvents(description string, se ptrace.SpanEventSlice) { if se.Len() == 0 { return } @@ -221,14 +223,14 @@ func (b *dataBuffer) logEvents(description string, se pdata.SpanEventSlice) { continue } b.logEntry(" -> Attributes:") - e.Attributes().Range(func(k string, v pdata.Value) bool { + e.Attributes().Range(func(k string, v pcommon.Value) bool { b.logEntry(" -> %s: %s(%s)", k, v.Type().String(), attributeValueToString(v)) return true }) } } -func (b *dataBuffer) logLinks(description string, sl pdata.SpanLinkSlice) { +func (b *dataBuffer) logLinks(description string, sl ptrace.SpanLinkSlice) { if sl.Len() == 0 { return } @@ -246,33 +248,33 @@ func (b *dataBuffer) logLinks(description string, sl pdata.SpanLinkSlice) { continue } b.logEntry(" -> Attributes:") - l.Attributes().Range(func(k string, v pdata.Value) bool { + l.Attributes().Range(func(k string, v pcommon.Value) bool { b.logEntry(" -> %s: %s(%s)", k, v.Type().String(), attributeValueToString(v)) return true }) } } -func attributeValueToString(v pdata.Value) string { +func attributeValueToString(v pcommon.Value) string { switch v.Type() { - case pdata.ValueTypeString: + case pcommon.ValueTypeString: return v.StringVal() - case pdata.ValueTypeBool: + case pcommon.ValueTypeBool: return strconv.FormatBool(v.BoolVal()) - case pdata.ValueTypeDouble: + case pcommon.ValueTypeDouble: return strconv.FormatFloat(v.DoubleVal(), 'f', -1, 64) - case pdata.ValueTypeInt: + case pcommon.ValueTypeInt: return strconv.FormatInt(v.IntVal(), 10) - case pdata.ValueTypeSlice: + case pcommon.ValueTypeSlice: return sliceToString(v.SliceVal()) - case pdata.ValueTypeMap: + case pcommon.ValueTypeMap: return mapToString(v.MapVal()) default: return fmt.Sprintf("", v.Type()) } } -func sliceToString(s pdata.Slice) string { +func sliceToString(s pcommon.Slice) string { var b strings.Builder b.WriteByte('[') for i := 0; i < s.Len(); i++ { @@ -287,11 +289,11 @@ func sliceToString(s pdata.Slice) string { return b.String() } -func mapToString(m pdata.Map) string { +func mapToString(m pcommon.Map) string { var b strings.Builder b.WriteString("{\n") - m.Sort().Range(func(k string, v pdata.Value) bool { + m.Sort().Range(func(k string, v pcommon.Value) bool { fmt.Fprintf(&b, " -> %s: %s(%s)\n", k, v.Type(), v.AsString()) return true }) diff --git a/internal/otlptext/databuffer_test.go b/internal/otlptext/databuffer_test.go index 01b6c23345c..2e1c92dec55 100644 --- a/internal/otlptext/databuffer_test.go +++ b/internal/otlptext/databuffer_test.go @@ -19,15 +19,15 @@ import ( "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) func TestNestedArraySerializesCorrectly(t *testing.T) { - ava := pdata.NewValueSlice() + ava := pcommon.NewValueSlice() ava.SliceVal().AppendEmpty().SetStringVal("foo") ava.SliceVal().AppendEmpty().SetIntVal(42) - ava2 := pdata.NewValueSlice() + ava2 := pcommon.NewValueSlice() ava2.SliceVal().AppendEmpty().SetStringVal("bar") ava2.CopyTo(ava.SliceVal().AppendEmpty()) @@ -39,11 +39,11 @@ func TestNestedArraySerializesCorrectly(t *testing.T) { } func TestNestedMapSerializesCorrectly(t *testing.T) { - ava := pdata.NewValueMap() + ava := pcommon.NewValueMap() av := ava.MapVal() - av.Insert("foo", pdata.NewValueString("test")) + av.Insert("foo", pcommon.NewValueString("test")) - ava2 := pdata.NewValueMap() + ava2 := pcommon.NewValueMap() av2 := ava2.MapVal() av2.InsertInt("bar", 13) av.Insert("zoo", ava2) diff --git a/internal/otlptext/logs.go b/internal/otlptext/logs.go index 12f27365b71..2c4dbeab147 100644 --- a/internal/otlptext/logs.go +++ b/internal/otlptext/logs.go @@ -15,18 +15,18 @@ package otlptext // import "go.opentelemetry.io/collector/internal/otlptext" import ( - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) -// NewTextLogsMarshaler returns a serializer.LogsMarshaler to encode to OTLP text bytes. -func NewTextLogsMarshaler() pdata.LogsMarshaler { +// NewTextLogsMarshaler returns a serializer.Marshaler to encode to OTLP text bytes. +func NewTextLogsMarshaler() plog.Marshaler { return textLogsMarshaler{} } type textLogsMarshaler struct{} -// MarshalLogs pdata.Logs to OTLP text. -func (textLogsMarshaler) MarshalLogs(ld pdata.Logs) ([]byte, error) { +// MarshalLogs plog.Logs to OTLP text. +func (textLogsMarshaler) MarshalLogs(ld plog.Logs) ([]byte, error) { buf := dataBuffer{} rls := ld.ResourceLogs() for i := 0; i < rls.Len(); i++ { diff --git a/internal/otlptext/logs_test.go b/internal/otlptext/logs_test.go index 137e3c73a25..ec645dfe178 100644 --- a/internal/otlptext/logs_test.go +++ b/internal/otlptext/logs_test.go @@ -20,19 +20,19 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) func TestLogsText(t *testing.T) { type args struct { - ld pdata.Logs + ld plog.Logs } tests := []struct { name string args args empty bool }{ - {"empty logs", args{pdata.NewLogs()}, true}, + {"empty logs", args{plog.NewLogs()}, true}, {"logs data with empty resource log", args{testdata.GenerateLogsOneEmptyResourceLogs()}, false}, {"logs data with no log records", args{testdata.GenerateLogsNoLogRecords()}, false}, {"logs with one empty log", args{testdata.GenerateLogsOneEmptyLogRecord()}, false}, diff --git a/internal/otlptext/metrics.go b/internal/otlptext/metrics.go index 4e3d5e69b14..25a72ed1a03 100644 --- a/internal/otlptext/metrics.go +++ b/internal/otlptext/metrics.go @@ -14,19 +14,17 @@ package otlptext // import "go.opentelemetry.io/collector/internal/otlptext" -import ( - "go.opentelemetry.io/collector/model/pdata" -) +import "go.opentelemetry.io/collector/pdata/pmetric" -// NewTextMetricsMarshaler returns a serializer.MetricsMarshaler to encode to OTLP text bytes. -func NewTextMetricsMarshaler() pdata.MetricsMarshaler { +// NewTextMetricsMarshaler returns a serializer.Marshaler to encode to OTLP text bytes. +func NewTextMetricsMarshaler() pmetric.Marshaler { return textMetricsMarshaler{} } type textMetricsMarshaler struct{} -// MarshalMetrics pdata.Metrics to OTLP text. -func (textMetricsMarshaler) MarshalMetrics(md pdata.Metrics) ([]byte, error) { +// MarshalMetrics pmetric.Metrics to OTLP text. +func (textMetricsMarshaler) MarshalMetrics(md pmetric.Metrics) ([]byte, error) { buf := dataBuffer{} rms := md.ResourceMetrics() for i := 0; i < rms.Len(); i++ { diff --git a/internal/otlptext/metrics_test.go b/internal/otlptext/metrics_test.go index 5213bda8df8..06669d13362 100644 --- a/internal/otlptext/metrics_test.go +++ b/internal/otlptext/metrics_test.go @@ -20,19 +20,19 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" ) func TestMetricsText(t *testing.T) { type args struct { - md pdata.Metrics + md pmetric.Metrics } tests := []struct { name string args args empty bool }{ - {"empty metrics", args{pdata.NewMetrics()}, true}, + {"empty metrics", args{pmetric.NewMetrics()}, true}, {"metrics with all types and datapoints", args{testdata.GeneratMetricsAllTypesWithSampleDatapoints()}, false}, {"metrics with all types without datapoints", args{testdata.GenerateMetricsAllTypesEmptyDataPoint()}, false}, {"metrics with invalid metric types", args{testdata.GenerateMetricsMetricTypeInvalid()}, false}, diff --git a/internal/otlptext/traces.go b/internal/otlptext/traces.go index 7eb86f3c0df..10998d51461 100644 --- a/internal/otlptext/traces.go +++ b/internal/otlptext/traces.go @@ -15,18 +15,18 @@ package otlptext // import "go.opentelemetry.io/collector/internal/otlptext" import ( - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) -// NewTextTracesMarshaler returns a serializer.TracesMarshaler to encode to OTLP text bytes. -func NewTextTracesMarshaler() pdata.TracesMarshaler { +// NewTextTracesMarshaler returns a serializer.Marshaler to encode to OTLP text bytes. +func NewTextTracesMarshaler() ptrace.Marshaler { return textTracesMarshaler{} } type textTracesMarshaler struct{} -// MarshalTraces pdata.Traces to OTLP text. -func (textTracesMarshaler) MarshalTraces(td pdata.Traces) ([]byte, error) { +// MarshalTraces ptrace.Traces to OTLP text. +func (textTracesMarshaler) MarshalTraces(td ptrace.Traces) ([]byte, error) { buf := dataBuffer{} rss := td.ResourceSpans() for i := 0; i < rss.Len(); i++ { diff --git a/internal/otlptext/traces_test.go b/internal/otlptext/traces_test.go index 875dfb3227a..b9a91ac879b 100644 --- a/internal/otlptext/traces_test.go +++ b/internal/otlptext/traces_test.go @@ -20,19 +20,19 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) func TestTracesText(t *testing.T) { type args struct { - td pdata.Traces + td ptrace.Traces } tests := []struct { name string args args empty bool }{ - {"empty traces", args{pdata.NewTraces()}, true}, + {"empty traces", args{ptrace.NewTraces()}, true}, {"traces with two spans", args{testdata.GenerateTracesTwoSpansSameResource()}, false}, } for _, tt := range tests { diff --git a/internal/testcomponents/example_exporter.go b/internal/testcomponents/example_exporter.go index 984a3fb7dd3..c0cc6d0e5bf 100644 --- a/internal/testcomponents/example_exporter.go +++ b/internal/testcomponents/example_exporter.go @@ -20,7 +20,9 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) var _ config.Unmarshallable = (*ExampleExporter)(nil) @@ -74,9 +76,9 @@ func createLogsExporter(context.Context, component.ExporterCreateSettings, confi // ExampleExporterConsumer stores consumed traces and metrics for testing purposes. type ExampleExporterConsumer struct { - Traces []pdata.Traces - Metrics []pdata.Metrics - Logs []pdata.Logs + Traces []ptrace.Traces + Metrics []pmetric.Metrics + Logs []plog.Logs ExporterStarted bool ExporterShutdown bool } @@ -89,8 +91,8 @@ func (exp *ExampleExporterConsumer) Start(_ context.Context, _ component.Host) e return nil } -// ConsumeTraces receives pdata.Traces for processing by the consumer.Traces. -func (exp *ExampleExporterConsumer) ConsumeTraces(_ context.Context, td pdata.Traces) error { +// ConsumeTraces receives ptrace.Traces for processing by the consumer.Traces. +func (exp *ExampleExporterConsumer) ConsumeTraces(_ context.Context, td ptrace.Traces) error { exp.Traces = append(exp.Traces, td) return nil } @@ -99,13 +101,13 @@ func (exp *ExampleExporterConsumer) Capabilities() consumer.Capabilities { return consumer.Capabilities{MutatesData: false} } -// ConsumeMetrics receives pdata.Metrics for processing by the Metrics. -func (exp *ExampleExporterConsumer) ConsumeMetrics(_ context.Context, md pdata.Metrics) error { +// ConsumeMetrics receives pmetric.Metrics for processing by the Metrics. +func (exp *ExampleExporterConsumer) ConsumeMetrics(_ context.Context, md pmetric.Metrics) error { exp.Metrics = append(exp.Metrics, md) return nil } -func (exp *ExampleExporterConsumer) ConsumeLogs(_ context.Context, ld pdata.Logs) error { +func (exp *ExampleExporterConsumer) ConsumeLogs(_ context.Context, ld plog.Logs) error { exp.Logs = append(exp.Logs, ld) return nil } diff --git a/internal/testcomponents/example_exporter_test.go b/internal/testcomponents/example_exporter_test.go index 48ae7907b34..3a772d15f7f 100644 --- a/internal/testcomponents/example_exporter_test.go +++ b/internal/testcomponents/example_exporter_test.go @@ -21,7 +21,8 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/component/componenttest" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) func TestExampleExporterConsumer(t *testing.T) { @@ -33,12 +34,12 @@ func TestExampleExporterConsumer(t *testing.T) { assert.True(t, exp.ExporterStarted) assert.Equal(t, 0, len(exp.Traces)) - err = exp.ConsumeTraces(context.Background(), pdata.Traces{}) + err = exp.ConsumeTraces(context.Background(), ptrace.Traces{}) assert.NoError(t, err) assert.Equal(t, 1, len(exp.Traces)) assert.Equal(t, 0, len(exp.Metrics)) - err = exp.ConsumeMetrics(context.Background(), pdata.Metrics{}) + err = exp.ConsumeMetrics(context.Background(), pmetric.Metrics{}) assert.NoError(t, err) assert.Equal(t, 1, len(exp.Metrics)) diff --git a/internal/testdata/common.go b/internal/testdata/common.go index 73b454ae7ce..e965cdc0193 100644 --- a/internal/testdata/common.go +++ b/internal/testdata/common.go @@ -15,16 +15,16 @@ package testdata import ( - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) var ( - resourceAttributes1 = pdata.NewMapFromRaw(map[string]interface{}{"resource-attr": "resource-attr-val-1"}) - resourceAttributes2 = pdata.NewMapFromRaw(map[string]interface{}{"resource-attr": "resource-attr-val-2"}) - spanEventAttributes = pdata.NewMapFromRaw(map[string]interface{}{"span-event-attr": "span-event-attr-val"}) - spanLinkAttributes = pdata.NewMapFromRaw(map[string]interface{}{"span-link-attr": "span-link-attr-val"}) - spanAttributes = pdata.NewMapFromRaw(map[string]interface{}{"span-attr": "span-attr-val"}) - metricAttachment = pdata.NewMapFromRaw(map[string]interface{}{"exemplar-attachment": "exemplar-attachment-value"}) + resourceAttributes1 = pcommon.NewMapFromRaw(map[string]interface{}{"resource-attr": "resource-attr-val-1"}) + resourceAttributes2 = pcommon.NewMapFromRaw(map[string]interface{}{"resource-attr": "resource-attr-val-2"}) + spanEventAttributes = pcommon.NewMapFromRaw(map[string]interface{}{"span-event-attr": "span-event-attr-val"}) + spanLinkAttributes = pcommon.NewMapFromRaw(map[string]interface{}{"span-link-attr": "span-link-attr-val"}) + spanAttributes = pcommon.NewMapFromRaw(map[string]interface{}{"span-attr": "span-attr-val"}) + metricAttachment = pcommon.NewMapFromRaw(map[string]interface{}{"exemplar-attachment": "exemplar-attachment-value"}) ) const ( @@ -36,52 +36,52 @@ const ( TestLabelValue3 = "label-value-3" ) -func initResourceAttributes1(dest pdata.Map) { +func initResourceAttributes1(dest pcommon.Map) { dest.Clear() resourceAttributes1.CopyTo(dest) } -func initResourceAttributes2(dest pdata.Map) { +func initResourceAttributes2(dest pcommon.Map) { dest.Clear() resourceAttributes2.CopyTo(dest) } -func initSpanAttributes(dest pdata.Map) { +func initSpanAttributes(dest pcommon.Map) { dest.Clear() spanAttributes.CopyTo(dest) } -func initSpanEventAttributes(dest pdata.Map) { +func initSpanEventAttributes(dest pcommon.Map) { dest.Clear() spanEventAttributes.CopyTo(dest) } -func initSpanLinkAttributes(dest pdata.Map) { +func initSpanLinkAttributes(dest pcommon.Map) { dest.Clear() spanLinkAttributes.CopyTo(dest) } -func initMetricAttachment(dest pdata.Map) { +func initMetricAttachment(dest pcommon.Map) { dest.Clear() metricAttachment.CopyTo(dest) } -func initMetricAttributes1(dest pdata.Map) { +func initMetricAttributes1(dest pcommon.Map) { dest.Clear() dest.InsertString(TestLabelKey1, TestLabelValue1) } -func initMetricAttributes12(dest pdata.Map) { +func initMetricAttributes12(dest pcommon.Map) { initMetricAttributes1(dest) dest.InsertString(TestLabelKey2, TestLabelValue2) } -func initMetricAttributes13(dest pdata.Map) { +func initMetricAttributes13(dest pcommon.Map) { initMetricAttributes1(dest) dest.InsertString(TestLabelKey3, TestLabelValue3) } -func initMetricAttributes2(dest pdata.Map) { +func initMetricAttributes2(dest pcommon.Map) { dest.Clear() dest.InsertString(TestLabelKey2, TestLabelValue2) } diff --git a/internal/testdata/log.go b/internal/testdata/log.go index 01167385829..777f5e65fd8 100644 --- a/internal/testdata/log.go +++ b/internal/testdata/log.go @@ -17,40 +17,41 @@ package testdata import ( "time" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" ) var ( TestLogTime = time.Date(2020, 2, 11, 20, 26, 13, 789, time.UTC) - TestLogTimestamp = pdata.NewTimestampFromTime(TestLogTime) + TestLogTimestamp = pcommon.NewTimestampFromTime(TestLogTime) ) -func GenerateLogsOneEmptyResourceLogs() pdata.Logs { - ld := pdata.NewLogs() +func GenerateLogsOneEmptyResourceLogs() plog.Logs { + ld := plog.NewLogs() ld.ResourceLogs().AppendEmpty() return ld } -func GenerateLogsNoLogRecords() pdata.Logs { +func GenerateLogsNoLogRecords() plog.Logs { ld := GenerateLogsOneEmptyResourceLogs() initResource1(ld.ResourceLogs().At(0).Resource()) return ld } -func GenerateLogsOneEmptyLogRecord() pdata.Logs { +func GenerateLogsOneEmptyLogRecord() plog.Logs { ld := GenerateLogsNoLogRecords() rs0 := ld.ResourceLogs().At(0) rs0.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty() return ld } -func GenerateLogsOneLogRecord() pdata.Logs { +func GenerateLogsOneLogRecord() plog.Logs { ld := GenerateLogsOneEmptyLogRecord() fillLogOne(ld.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0)) return ld } -func GenerateLogsTwoLogRecordsSameResource() pdata.Logs { +func GenerateLogsTwoLogRecordsSameResource() plog.Logs { ld := GenerateLogsOneEmptyLogRecord() logs := ld.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords() fillLogOne(logs.At(0)) @@ -58,8 +59,8 @@ func GenerateLogsTwoLogRecordsSameResource() pdata.Logs { return ld } -func GenerateLogsTwoLogRecordsSameResourceOneDifferent() pdata.Logs { - ld := pdata.NewLogs() +func GenerateLogsTwoLogRecordsSameResourceOneDifferent() plog.Logs { + ld := plog.NewLogs() rl0 := ld.ResourceLogs().AppendEmpty() initResource1(rl0.Resource()) logs := rl0.ScopeLogs().AppendEmpty().LogRecords() @@ -70,13 +71,13 @@ func GenerateLogsTwoLogRecordsSameResourceOneDifferent() pdata.Logs { fillLogThree(rl1.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty()) return ld } -func fillLogOne(log pdata.LogRecord) { +func fillLogOne(log plog.LogRecord) { log.SetTimestamp(TestLogTimestamp) log.SetDroppedAttributesCount(1) - log.SetSeverityNumber(pdata.SeverityNumberINFO) + log.SetSeverityNumber(plog.SeverityNumberINFO) log.SetSeverityText("Info") - log.SetSpanID(pdata.NewSpanID([8]byte{0x01, 0x02, 0x04, 0x08})) - log.SetTraceID(pdata.NewTraceID([16]byte{0x08, 0x04, 0x02, 0x01})) + log.SetSpanID(pcommon.NewSpanID([8]byte{0x01, 0x02, 0x04, 0x08})) + log.SetTraceID(pcommon.NewTraceID([16]byte{0x08, 0x04, 0x02, 0x01})) attrs := log.Attributes() attrs.InsertString("app", "server") @@ -85,10 +86,10 @@ func fillLogOne(log pdata.LogRecord) { log.Body().SetStringVal("This is a log message") } -func fillLogTwo(log pdata.LogRecord) { +func fillLogTwo(log plog.LogRecord) { log.SetTimestamp(TestLogTimestamp) log.SetDroppedAttributesCount(1) - log.SetSeverityNumber(pdata.SeverityNumberINFO) + log.SetSeverityNumber(plog.SeverityNumberINFO) log.SetSeverityText("Info") attrs := log.Attributes() @@ -98,21 +99,21 @@ func fillLogTwo(log pdata.LogRecord) { log.Body().SetStringVal("something happened") } -func fillLogThree(log pdata.LogRecord) { +func fillLogThree(log plog.LogRecord) { log.SetTimestamp(TestLogTimestamp) log.SetDroppedAttributesCount(1) - log.SetSeverityNumber(pdata.SeverityNumberWARN) + log.SetSeverityNumber(plog.SeverityNumberWARN) log.SetSeverityText("Warning") log.Body().SetStringVal("something else happened") } -func GenerateLogsManyLogRecordsSameResource(count int) pdata.Logs { +func GenerateLogsManyLogRecordsSameResource(count int) plog.Logs { ld := GenerateLogsOneEmptyLogRecord() logs := ld.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords() logs.EnsureCapacity(count) for i := 0; i < count; i++ { - var l pdata.LogRecord + var l plog.LogRecord if i < logs.Len() { l = logs.At(i) } else { diff --git a/internal/testdata/metric.go b/internal/testdata/metric.go index 4fc2fe1e4cb..76387d21ec4 100644 --- a/internal/testdata/metric.go +++ b/internal/testdata/metric.go @@ -17,18 +17,19 @@ package testdata import ( "time" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) var ( TestMetricStartTime = time.Date(2020, 2, 11, 20, 26, 12, 321, time.UTC) - TestMetricStartTimestamp = pdata.NewTimestampFromTime(TestMetricStartTime) + TestMetricStartTimestamp = pcommon.NewTimestampFromTime(TestMetricStartTime) TestMetricExemplarTime = time.Date(2020, 2, 11, 20, 26, 13, 123, time.UTC) - TestMetricExemplarTimestamp = pdata.NewTimestampFromTime(TestMetricExemplarTime) + TestMetricExemplarTimestamp = pcommon.NewTimestampFromTime(TestMetricExemplarTime) TestMetricTime = time.Date(2020, 2, 11, 20, 26, 13, 789, time.UTC) - TestMetricTimestamp = pdata.NewTimestampFromTime(TestMetricTime) + TestMetricTimestamp = pcommon.NewTimestampFromTime(TestMetricTime) ) const ( @@ -41,33 +42,33 @@ const ( TestSummaryMetricName = "summary" ) -func GenerateMetricsOneEmptyResourceMetrics() pdata.Metrics { - md := pdata.NewMetrics() +func GenerateMetricsOneEmptyResourceMetrics() pmetric.Metrics { + md := pmetric.NewMetrics() md.ResourceMetrics().AppendEmpty() return md } -func GenerateMetricsNoLibraries() pdata.Metrics { +func GenerateMetricsNoLibraries() pmetric.Metrics { md := GenerateMetricsOneEmptyResourceMetrics() ms0 := md.ResourceMetrics().At(0) initResource1(ms0.Resource()) return md } -func GenerateMetricsOneEmptyInstrumentationScope() pdata.Metrics { +func GenerateMetricsOneEmptyInstrumentationScope() pmetric.Metrics { md := GenerateMetricsNoLibraries() md.ResourceMetrics().At(0).ScopeMetrics().AppendEmpty() return md } -func GenerateMetricsOneMetric() pdata.Metrics { +func GenerateMetricsOneMetric() pmetric.Metrics { md := GenerateMetricsOneEmptyInstrumentationScope() rm0ils0 := md.ResourceMetrics().At(0).ScopeMetrics().At(0) initSumIntMetric(rm0ils0.Metrics().AppendEmpty()) return md } -func GenerateMetricsTwoMetrics() pdata.Metrics { +func GenerateMetricsTwoMetrics() pmetric.Metrics { md := GenerateMetricsOneEmptyInstrumentationScope() rm0ils0 := md.ResourceMetrics().At(0).ScopeMetrics().At(0) initSumIntMetric(rm0ils0.Metrics().AppendEmpty()) @@ -75,40 +76,40 @@ func GenerateMetricsTwoMetrics() pdata.Metrics { return md } -func GenerateMetricsAllTypesEmptyDataPoint() pdata.Metrics { +func GenerateMetricsAllTypesEmptyDataPoint() pmetric.Metrics { md := GenerateMetricsOneEmptyInstrumentationScope() ilm0 := md.ResourceMetrics().At(0).ScopeMetrics().At(0) ms := ilm0.Metrics() doubleGauge := ms.AppendEmpty() - initMetric(doubleGauge, TestGaugeDoubleMetricName, pdata.MetricDataTypeGauge) + initMetric(doubleGauge, TestGaugeDoubleMetricName, pmetric.MetricDataTypeGauge) doubleGauge.Gauge().DataPoints().AppendEmpty() intGauge := ms.AppendEmpty() - initMetric(intGauge, TestGaugeIntMetricName, pdata.MetricDataTypeGauge) + initMetric(intGauge, TestGaugeIntMetricName, pmetric.MetricDataTypeGauge) intGauge.Gauge().DataPoints().AppendEmpty() doubleSum := ms.AppendEmpty() - initMetric(doubleSum, TestSumDoubleMetricName, pdata.MetricDataTypeSum) + initMetric(doubleSum, TestSumDoubleMetricName, pmetric.MetricDataTypeSum) doubleSum.Sum().DataPoints().AppendEmpty() intSum := ms.AppendEmpty() - initMetric(intSum, TestSumIntMetricName, pdata.MetricDataTypeSum) + initMetric(intSum, TestSumIntMetricName, pmetric.MetricDataTypeSum) intSum.Sum().DataPoints().AppendEmpty() histogram := ms.AppendEmpty() - initMetric(histogram, TestHistogramMetricName, pdata.MetricDataTypeHistogram) + initMetric(histogram, TestHistogramMetricName, pmetric.MetricDataTypeHistogram) histogram.Histogram().DataPoints().AppendEmpty() summary := ms.AppendEmpty() - initMetric(summary, TestSummaryMetricName, pdata.MetricDataTypeSummary) + initMetric(summary, TestSummaryMetricName, pmetric.MetricDataTypeSummary) summary.Summary().DataPoints().AppendEmpty() return md } -func GenerateMetricsMetricTypeInvalid() pdata.Metrics { +func GenerateMetricsMetricTypeInvalid() pmetric.Metrics { md := GenerateMetricsOneEmptyInstrumentationScope() ilm0 := md.ResourceMetrics().At(0).ScopeMetrics().At(0) - initMetric(ilm0.Metrics().AppendEmpty(), TestSumIntMetricName, pdata.MetricDataTypeNone) + initMetric(ilm0.Metrics().AppendEmpty(), TestSumIntMetricName, pmetric.MetricDataTypeNone) return md } -func GeneratMetricsAllTypesWithSampleDatapoints() pdata.Metrics { +func GeneratMetricsAllTypesWithSampleDatapoints() pmetric.Metrics { md := GenerateMetricsOneEmptyInstrumentationScope() ilm := md.ResourceMetrics().At(0).ScopeMetrics().At(0) @@ -123,8 +124,8 @@ func GeneratMetricsAllTypesWithSampleDatapoints() pdata.Metrics { return md } -func initGaugeIntMetric(im pdata.Metric) { - initMetric(im, TestGaugeIntMetricName, pdata.MetricDataTypeGauge) +func initGaugeIntMetric(im pmetric.Metric) { + initMetric(im, TestGaugeIntMetricName, pmetric.MetricDataTypeGauge) idps := im.Gauge().DataPoints() idp0 := idps.AppendEmpty() @@ -139,8 +140,8 @@ func initGaugeIntMetric(im pdata.Metric) { idp1.SetIntVal(456) } -func initGaugeDoubleMetric(im pdata.Metric) { - initMetric(im, TestGaugeDoubleMetricName, pdata.MetricDataTypeGauge) +func initGaugeDoubleMetric(im pmetric.Metric) { + initMetric(im, TestGaugeDoubleMetricName, pmetric.MetricDataTypeGauge) idps := im.Gauge().DataPoints() idp0 := idps.AppendEmpty() @@ -155,8 +156,8 @@ func initGaugeDoubleMetric(im pdata.Metric) { idp1.SetDoubleVal(4.56) } -func initSumIntMetric(im pdata.Metric) { - initMetric(im, TestSumIntMetricName, pdata.MetricDataTypeSum) +func initSumIntMetric(im pmetric.Metric) { + initMetric(im, TestSumIntMetricName, pmetric.MetricDataTypeSum) idps := im.Sum().DataPoints() idp0 := idps.AppendEmpty() @@ -171,8 +172,8 @@ func initSumIntMetric(im pdata.Metric) { idp1.SetIntVal(456) } -func initSumDoubleMetric(dm pdata.Metric) { - initMetric(dm, TestSumDoubleMetricName, pdata.MetricDataTypeSum) +func initSumDoubleMetric(dm pmetric.Metric) { + initMetric(dm, TestSumDoubleMetricName, pmetric.MetricDataTypeSum) ddps := dm.Sum().DataPoints() ddp0 := ddps.AppendEmpty() @@ -188,8 +189,8 @@ func initSumDoubleMetric(dm pdata.Metric) { ddp1.SetDoubleVal(4.56) } -func initHistogramMetric(hm pdata.Metric) { - initMetric(hm, TestHistogramMetricName, pdata.MetricDataTypeHistogram) +func initHistogramMetric(hm pmetric.Metric) { + initMetric(hm, TestHistogramMetricName, pmetric.MetricDataTypeHistogram) hdps := hm.Histogram().DataPoints() hdp0 := hdps.AppendEmpty() @@ -213,8 +214,8 @@ func initHistogramMetric(hm pdata.Metric) { hdp1.SetExplicitBounds([]float64{1}) } -func initExponentialHistogramMetric(hm pdata.Metric) { - initMetric(hm, TestExponentialHistogramMetricName, pdata.MetricDataTypeExponentialHistogram) +func initExponentialHistogramMetric(hm pmetric.Metric) { + initMetric(hm, TestExponentialHistogramMetricName, pmetric.MetricDataTypeExponentialHistogram) hdps := hm.ExponentialHistogram().DataPoints() hdp0 := hdps.AppendEmpty() @@ -264,8 +265,8 @@ func initExponentialHistogramMetric(hm pdata.Metric) { initMetricAttachment(exemplar.FilteredAttributes()) } -func initSummaryMetric(sm pdata.Metric) { - initMetric(sm, TestSummaryMetricName, pdata.MetricDataTypeSummary) +func initSummaryMetric(sm pmetric.Metric) { + initMetric(sm, TestSummaryMetricName, pmetric.MetricDataTypeSummary) sdps := sm.Summary().DataPoints() sdp0 := sdps.AppendEmpty() @@ -287,26 +288,26 @@ func initSummaryMetric(sm pdata.Metric) { quantile.SetValue(15) } -func initMetric(m pdata.Metric, name string, ty pdata.MetricDataType) { +func initMetric(m pmetric.Metric, name string, ty pmetric.MetricDataType) { m.SetName(name) m.SetDescription("") m.SetUnit("1") m.SetDataType(ty) switch ty { - case pdata.MetricDataTypeSum: + case pmetric.MetricDataTypeSum: sum := m.Sum() sum.SetIsMonotonic(true) - sum.SetAggregationTemporality(pdata.MetricAggregationTemporalityCumulative) - case pdata.MetricDataTypeHistogram: + sum.SetAggregationTemporality(pmetric.MetricAggregationTemporalityCumulative) + case pmetric.MetricDataTypeHistogram: histo := m.Histogram() - histo.SetAggregationTemporality(pdata.MetricAggregationTemporalityCumulative) - case pdata.MetricDataTypeExponentialHistogram: + histo.SetAggregationTemporality(pmetric.MetricAggregationTemporalityCumulative) + case pmetric.MetricDataTypeExponentialHistogram: histo := m.ExponentialHistogram() - histo.SetAggregationTemporality(pdata.MetricAggregationTemporalityDelta) + histo.SetAggregationTemporality(pmetric.MetricAggregationTemporalityDelta) } } -func GenerateMetricsManyMetricsSameResource(metricsCount int) pdata.Metrics { +func GenerateMetricsManyMetricsSameResource(metricsCount int) pmetric.Metrics { md := GenerateMetricsOneEmptyInstrumentationScope() rs0ilm0 := md.ResourceMetrics().At(0).ScopeMetrics().At(0) rs0ilm0.Metrics().EnsureCapacity(metricsCount) diff --git a/internal/testdata/resource.go b/internal/testdata/resource.go index f5d2b8f726d..6dd3d85c5cf 100644 --- a/internal/testdata/resource.go +++ b/internal/testdata/resource.go @@ -14,14 +14,12 @@ package testdata -import ( - "go.opentelemetry.io/collector/model/pdata" -) +import "go.opentelemetry.io/collector/pdata/pcommon" -func initResource1(r pdata.Resource) { +func initResource1(r pcommon.Resource) { initResourceAttributes1(r.Attributes()) } -func initResource2(r pdata.Resource) { +func initResource2(r pcommon.Resource) { initResourceAttributes2(r.Attributes()) } diff --git a/internal/testdata/trace.go b/internal/testdata/trace.go index e96207c6d63..1ed2e86a8d1 100644 --- a/internal/testdata/trace.go +++ b/internal/testdata/trace.go @@ -17,47 +17,48 @@ package testdata import ( "time" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" ) var ( TestSpanStartTime = time.Date(2020, 2, 11, 20, 26, 12, 321, time.UTC) - TestSpanStartTimestamp = pdata.NewTimestampFromTime(TestSpanStartTime) + TestSpanStartTimestamp = pcommon.NewTimestampFromTime(TestSpanStartTime) TestSpanEventTime = time.Date(2020, 2, 11, 20, 26, 13, 123, time.UTC) - TestSpanEventTimestamp = pdata.NewTimestampFromTime(TestSpanEventTime) + TestSpanEventTimestamp = pcommon.NewTimestampFromTime(TestSpanEventTime) TestSpanEndTime = time.Date(2020, 2, 11, 20, 26, 13, 789, time.UTC) - TestSpanEndTimestamp = pdata.NewTimestampFromTime(TestSpanEndTime) + TestSpanEndTimestamp = pcommon.NewTimestampFromTime(TestSpanEndTime) ) -func GenerateTracesOneEmptyResourceSpans() pdata.Traces { - td := pdata.NewTraces() +func GenerateTracesOneEmptyResourceSpans() ptrace.Traces { + td := ptrace.NewTraces() td.ResourceSpans().AppendEmpty() return td } -func GenerateTracesNoLibraries() pdata.Traces { +func GenerateTracesNoLibraries() ptrace.Traces { td := GenerateTracesOneEmptyResourceSpans() rs0 := td.ResourceSpans().At(0) initResource1(rs0.Resource()) return td } -func GenerateTracesOneEmptyInstrumentationScope() pdata.Traces { +func GenerateTracesOneEmptyInstrumentationScope() ptrace.Traces { td := GenerateTracesNoLibraries() td.ResourceSpans().At(0).ScopeSpans().AppendEmpty() return td } -func GenerateTracesOneSpan() pdata.Traces { +func GenerateTracesOneSpan() ptrace.Traces { td := GenerateTracesOneEmptyInstrumentationScope() rs0ils0 := td.ResourceSpans().At(0).ScopeSpans().At(0) fillSpanOne(rs0ils0.Spans().AppendEmpty()) return td } -func GenerateTracesTwoSpansSameResource() pdata.Traces { +func GenerateTracesTwoSpansSameResource() ptrace.Traces { td := GenerateTracesOneEmptyInstrumentationScope() rs0ils0 := td.ResourceSpans().At(0).ScopeSpans().At(0) fillSpanOne(rs0ils0.Spans().AppendEmpty()) @@ -65,8 +66,8 @@ func GenerateTracesTwoSpansSameResource() pdata.Traces { return td } -func GenerateTracesTwoSpansSameResourceOneDifferent() pdata.Traces { - td := pdata.NewTraces() +func GenerateTracesTwoSpansSameResourceOneDifferent() ptrace.Traces { + td := ptrace.NewTraces() rs0 := td.ResourceSpans().AppendEmpty() initResource1(rs0.Resource()) rs0ils0 := rs0.ScopeSpans().AppendEmpty() @@ -79,7 +80,7 @@ func GenerateTracesTwoSpansSameResourceOneDifferent() pdata.Traces { return td } -func GenerateTracesManySpansSameResource(spanCount int) pdata.Traces { +func GenerateTracesManySpansSameResource(spanCount int) ptrace.Traces { td := GenerateTracesOneEmptyInstrumentationScope() rs0ils0 := td.ResourceSpans().At(0).ScopeSpans().At(0) rs0ils0.Spans().EnsureCapacity(spanCount) @@ -89,13 +90,13 @@ func GenerateTracesManySpansSameResource(spanCount int) pdata.Traces { return td } -func fillSpanOne(span pdata.Span) { +func fillSpanOne(span ptrace.Span) { span.SetName("operationA") span.SetStartTimestamp(TestSpanStartTimestamp) span.SetEndTimestamp(TestSpanEndTimestamp) span.SetDroppedAttributesCount(1) - span.SetTraceID(pdata.NewTraceID([16]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10})) - span.SetSpanID(pdata.NewSpanID([8]byte{0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18})) + span.SetTraceID(pcommon.NewTraceID([16]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10})) + span.SetSpanID(pcommon.NewSpanID([8]byte{0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18})) evs := span.Events() ev0 := evs.AppendEmpty() ev0.SetTimestamp(TestSpanEventTimestamp) @@ -108,11 +109,11 @@ func fillSpanOne(span pdata.Span) { ev1.SetDroppedAttributesCount(2) span.SetDroppedEventsCount(1) status := span.Status() - status.SetCode(pdata.StatusCodeError) + status.SetCode(ptrace.StatusCodeError) status.SetMessage("status-cancelled") } -func fillSpanTwo(span pdata.Span) { +func fillSpanTwo(span ptrace.Span) { span.SetName("operationB") span.SetStartTimestamp(TestSpanStartTimestamp) span.SetEndTimestamp(TestSpanEndTimestamp) @@ -124,7 +125,7 @@ func fillSpanTwo(span pdata.Span) { span.SetDroppedLinksCount(3) } -func fillSpanThree(span pdata.Span) { +func fillSpanThree(span ptrace.Span) { span.SetName("operationC") span.SetStartTimestamp(TestSpanStartTimestamp) span.SetEndTimestamp(TestSpanEndTimestamp) diff --git a/model/go.mod b/model/go.mod index b2f47c30622..b77729f148a 100644 --- a/model/go.mod +++ b/model/go.mod @@ -3,19 +3,22 @@ module go.opentelemetry.io/collector/model go 1.17 require ( - github.com/gogo/protobuf v1.3.2 github.com/stretchr/testify v1.7.1 - google.golang.org/grpc v1.45.0 - google.golang.org/protobuf v1.28.0 + go.opentelemetry.io/collector/pdata v0.0.0-00010101000000-000000000000 ) require ( github.com/davecgh/go-spew v1.1.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect golang.org/x/text v0.3.3 // indirect google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect + google.golang.org/grpc v1.45.0 // indirect + google.golang.org/protobuf v1.28.0 // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) + +replace go.opentelemetry.io/collector/pdata => ../pdata diff --git a/model/otlp/json_marshaler.go b/model/otlp/json_marshaler.go index 3d2f0c3d40f..50bcbc93801 100644 --- a/model/otlp/json_marshaler.go +++ b/model/otlp/json_marshaler.go @@ -15,51 +15,19 @@ package otlp // import "go.opentelemetry.io/collector/model/otlp" import ( - "bytes" - - "github.com/gogo/protobuf/jsonpb" - - ipdata "go.opentelemetry.io/collector/model/internal" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // NewJSONTracesMarshaler returns a model.TracesMarshaler. Marshals to OTLP json bytes. -func NewJSONTracesMarshaler() pdata.TracesMarshaler { - return newJSONMarshaler() -} +// Deprecated: [v0.49.0] Use ptrace.NewJSONMarshaler instead. +var NewJSONTracesMarshaler = ptrace.NewJSONMarshaler // NewJSONMetricsMarshaler returns a model.MetricsMarshaler. Marshals to OTLP json bytes. -func NewJSONMetricsMarshaler() pdata.MetricsMarshaler { - return newJSONMarshaler() -} +// Deprecated: [v0.49.0] Use pmetric.NewJSONMarshaler instead. +var NewJSONMetricsMarshaler = pmetric.NewJSONMarshaler // NewJSONLogsMarshaler returns a model.LogsMarshaler. Marshals to OTLP json bytes. -func NewJSONLogsMarshaler() pdata.LogsMarshaler { - return newJSONMarshaler() -} - -type jsonMarshaler struct { - delegate jsonpb.Marshaler -} - -func newJSONMarshaler() *jsonMarshaler { - return &jsonMarshaler{delegate: jsonpb.Marshaler{}} -} - -func (e *jsonMarshaler) MarshalLogs(ld pdata.Logs) ([]byte, error) { - buf := bytes.Buffer{} - err := e.delegate.Marshal(&buf, ipdata.LogsToOtlp(ld)) - return buf.Bytes(), err -} - -func (e *jsonMarshaler) MarshalMetrics(md pdata.Metrics) ([]byte, error) { - buf := bytes.Buffer{} - err := e.delegate.Marshal(&buf, ipdata.MetricsToOtlp(md)) - return buf.Bytes(), err -} - -func (e *jsonMarshaler) MarshalTraces(td pdata.Traces) ([]byte, error) { - buf := bytes.Buffer{} - err := e.delegate.Marshal(&buf, ipdata.TracesToOtlp(td)) - return buf.Bytes(), err -} +// Deprecated: [v0.49.0] Use plog.NewJSONMarshaler instead. +var NewJSONLogsMarshaler = plog.NewJSONMarshaler diff --git a/model/otlp/json_unmarshaler.go b/model/otlp/json_unmarshaler.go index 805efe25e46..d1e3981d07e 100644 --- a/model/otlp/json_unmarshaler.go +++ b/model/otlp/json_unmarshaler.go @@ -15,64 +15,19 @@ package otlp // import "go.opentelemetry.io/collector/model/otlp" import ( - "bytes" - - "github.com/gogo/protobuf/jsonpb" - - ipdata "go.opentelemetry.io/collector/model/internal" - otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" - otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" - otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" - "go.opentelemetry.io/collector/model/internal/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) -type jsonUnmarshaler struct { - delegate jsonpb.Unmarshaler -} - // NewJSONTracesUnmarshaler returns a model.TracesUnmarshaler. Unmarshals from OTLP json bytes. -func NewJSONTracesUnmarshaler() pdata.TracesUnmarshaler { - return newJSONUnmarshaler() -} +// Deprecated: [v0.49.0] Use ptrace.NewJSONUnmarshaler instead. +var NewJSONTracesUnmarshaler = ptrace.NewJSONUnmarshaler // NewJSONMetricsUnmarshaler returns a model.MetricsUnmarshaler. Unmarshals from OTLP json bytes. -func NewJSONMetricsUnmarshaler() pdata.MetricsUnmarshaler { - return newJSONUnmarshaler() -} +// Deprecated: [v0.49.0] Use pmetric.NewJSONUnmarshaler instead. +var NewJSONMetricsUnmarshaler = pmetric.NewJSONUnmarshaler // NewJSONLogsUnmarshaler returns a model.LogsUnmarshaler. Unmarshals from OTLP json bytes. -func NewJSONLogsUnmarshaler() pdata.LogsUnmarshaler { - return newJSONUnmarshaler() -} - -func newJSONUnmarshaler() *jsonUnmarshaler { - return &jsonUnmarshaler{delegate: jsonpb.Unmarshaler{}} -} - -func (d *jsonUnmarshaler) UnmarshalLogs(buf []byte) (pdata.Logs, error) { - ld := &otlplogs.LogsData{} - if err := d.delegate.Unmarshal(bytes.NewReader(buf), ld); err != nil { - return pdata.Logs{}, err - } - otlp.InstrumentationLibraryLogsToScope(ld.ResourceLogs) - return ipdata.LogsFromOtlp(ld), nil -} - -func (d *jsonUnmarshaler) UnmarshalMetrics(buf []byte) (pdata.Metrics, error) { - md := &otlpmetrics.MetricsData{} - if err := d.delegate.Unmarshal(bytes.NewReader(buf), md); err != nil { - return pdata.Metrics{}, err - } - otlp.InstrumentationLibraryMetricsToScope(md.ResourceMetrics) - return ipdata.MetricsFromOtlp(md), nil -} - -func (d *jsonUnmarshaler) UnmarshalTraces(buf []byte) (pdata.Traces, error) { - td := &otlptrace.TracesData{} - if err := d.delegate.Unmarshal(bytes.NewReader(buf), td); err != nil { - return pdata.Traces{}, err - } - otlp.InstrumentationLibrarySpansToScope(td.ResourceSpans) - return ipdata.TracesFromOtlp(td), nil -} +// Deprecated: [v0.49.0] Use plog.NewJSONUnmarshaler instead. +var NewJSONLogsUnmarshaler = plog.NewJSONUnmarshaler diff --git a/model/otlp/pb_marshaler.go b/model/otlp/pb_marshaler.go index e5a8279b640..1d0b1702ebe 100644 --- a/model/otlp/pb_marshaler.go +++ b/model/otlp/pb_marshaler.go @@ -15,56 +15,19 @@ package otlp // import "go.opentelemetry.io/collector/model/otlp" import ( - ipdata "go.opentelemetry.io/collector/model/internal" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // NewProtobufTracesMarshaler returns a pdata.TracesMarshaler. Marshals to OTLP binary protobuf bytes. -func NewProtobufTracesMarshaler() pdata.TracesMarshaler { - return newPbMarshaler() -} +// Deprecated: [v0.49.0] Use ptrace.NewProtoMarshaler instead. +var NewProtobufTracesMarshaler = ptrace.NewProtoMarshaler // NewProtobufMetricsMarshaler returns a pdata.MetricsMarshaler. Marshals to OTLP binary protobuf bytes. -func NewProtobufMetricsMarshaler() pdata.MetricsMarshaler { - return newPbMarshaler() -} +// Deprecated: [v0.49.0] Use pmetric.NewProtoMarshaler instead. +var NewProtobufMetricsMarshaler = pmetric.NewProtoMarshaler // NewProtobufLogsMarshaler returns a pdata.LogsMarshaler. Marshals to OTLP binary protobuf bytes. -func NewProtobufLogsMarshaler() pdata.LogsMarshaler { - return newPbMarshaler() -} - -// TODO(#3842): Figure out how we want to represent/return *Sizers. -type pbMarshaler struct{} - -func newPbMarshaler() *pbMarshaler { - return &pbMarshaler{} -} - -var _ pdata.TracesSizer = (*pbMarshaler)(nil) -var _ pdata.MetricsSizer = (*pbMarshaler)(nil) -var _ pdata.LogsSizer = (*pbMarshaler)(nil) - -func (e *pbMarshaler) MarshalLogs(ld pdata.Logs) ([]byte, error) { - return ipdata.LogsToOtlp(ld).Marshal() -} - -func (e *pbMarshaler) MarshalMetrics(md pdata.Metrics) ([]byte, error) { - return ipdata.MetricsToOtlp(md).Marshal() -} - -func (e *pbMarshaler) MarshalTraces(td pdata.Traces) ([]byte, error) { - return ipdata.TracesToOtlp(td).Marshal() -} - -func (e *pbMarshaler) TracesSize(td pdata.Traces) int { - return ipdata.TracesToOtlp(td).Size() -} - -func (e *pbMarshaler) MetricsSize(md pdata.Metrics) int { - return ipdata.MetricsToOtlp(md).Size() -} - -func (e *pbMarshaler) LogsSize(ld pdata.Logs) int { - return ipdata.LogsToOtlp(ld).Size() -} +// Deprecated: [v0.49.0] Use plog.NewProtoMarshaler instead. +var NewProtobufLogsMarshaler = plog.NewProtoMarshaler diff --git a/model/otlp/pb_test.go b/model/otlp/pb_test.go deleted file mode 100644 index 3053f23fdd5..00000000000 --- a/model/otlp/pb_test.go +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package otlp - -import ( - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "go.opentelemetry.io/collector/model/pdata" -) - -func TestProtobufLogsUnmarshaler_error(t *testing.T) { - p := NewProtobufLogsUnmarshaler() - _, err := p.UnmarshalLogs([]byte("+$%")) - assert.Error(t, err) -} - -func TestProtobufMetricsUnmarshaler_error(t *testing.T) { - p := NewProtobufMetricsUnmarshaler() - _, err := p.UnmarshalMetrics([]byte("+$%")) - assert.Error(t, err) -} - -func TestProtobufTracesUnmarshaler_error(t *testing.T) { - p := NewProtobufTracesUnmarshaler() - _, err := p.UnmarshalTraces([]byte("+$%")) - assert.Error(t, err) -} - -func TestProtobufTracesSizer(t *testing.T) { - sizer := NewProtobufTracesMarshaler().(pdata.TracesSizer) - marshaler := NewProtobufTracesMarshaler() - td := pdata.NewTraces() - rms := td.ResourceSpans() - rms.AppendEmpty().ScopeSpans().AppendEmpty().Spans().AppendEmpty().SetName("foo") - - size := sizer.TracesSize(td) - - bytes, err := marshaler.MarshalTraces(td) - require.NoError(t, err) - assert.Equal(t, len(bytes), size) -} - -func TestProtobufTracesSizer_withNil(t *testing.T) { - sizer := NewProtobufTracesMarshaler().(pdata.TracesSizer) - - assert.Equal(t, 0, sizer.TracesSize(pdata.NewTraces())) -} - -func TestProtobufMetricsSizer(t *testing.T) { - sizer := NewProtobufMetricsMarshaler().(pdata.MetricsSizer) - marshaler := NewProtobufMetricsMarshaler() - md := pdata.NewMetrics() - md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty().SetName("foo") - - size := sizer.MetricsSize(md) - - bytes, err := marshaler.MarshalMetrics(md) - require.NoError(t, err) - assert.Equal(t, len(bytes), size) -} - -func TestProtobufMetricsSizer_withNil(t *testing.T) { - sizer := NewProtobufMetricsMarshaler().(pdata.MetricsSizer) - - assert.Equal(t, 0, sizer.MetricsSize(pdata.NewMetrics())) -} - -func TestProtobufLogsSizer(t *testing.T) { - sizer := NewProtobufLogsMarshaler().(pdata.LogsSizer) - marshaler := NewProtobufLogsMarshaler() - ld := pdata.NewLogs() - ld.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty().SetSeverityText("error") - - size := sizer.LogsSize(ld) - - bytes, err := marshaler.MarshalLogs(ld) - require.NoError(t, err) - assert.Equal(t, len(bytes), size) - -} - -func TestProtobufLogsSizer_withNil(t *testing.T) { - sizer := NewProtobufLogsMarshaler().(pdata.LogsSizer) - - assert.Equal(t, 0, sizer.LogsSize(pdata.NewLogs())) -} - -func BenchmarkLogsToProtobuf(b *testing.B) { - marshaler := NewProtobufLogsMarshaler() - logs := generateBenchmarkLogs(128) - b.ResetTimer() - for n := 0; n < b.N; n++ { - buf, err := marshaler.MarshalLogs(logs) - require.NoError(b, err) - assert.NotEqual(b, 0, len(buf)) - } -} - -func BenchmarkLogsFromProtobuf(b *testing.B) { - marshaler := NewProtobufLogsMarshaler() - unmarshaler := NewProtobufLogsUnmarshaler() - baseLogs := generateBenchmarkLogs(128) - buf, err := marshaler.MarshalLogs(baseLogs) - require.NoError(b, err) - assert.NotEqual(b, 0, len(buf)) - b.ResetTimer() - b.ReportAllocs() - for n := 0; n < b.N; n++ { - logs, err := unmarshaler.UnmarshalLogs(buf) - require.NoError(b, err) - assert.Equal(b, baseLogs.ResourceLogs().Len(), logs.ResourceLogs().Len()) - } -} - -func BenchmarkMetricsToProtobuf(b *testing.B) { - marshaler := NewProtobufMetricsMarshaler() - metrics := generateBenchmarkMetrics(128) - b.ResetTimer() - for n := 0; n < b.N; n++ { - buf, err := marshaler.MarshalMetrics(metrics) - require.NoError(b, err) - assert.NotEqual(b, 0, len(buf)) - } -} - -func BenchmarkMetricsFromProtobuf(b *testing.B) { - marshaler := NewProtobufMetricsMarshaler() - unmarshaler := NewProtobufMetricsUnmarshaler() - baseMetrics := generateBenchmarkMetrics(128) - buf, err := marshaler.MarshalMetrics(baseMetrics) - require.NoError(b, err) - assert.NotEqual(b, 0, len(buf)) - b.ResetTimer() - b.ReportAllocs() - for n := 0; n < b.N; n++ { - metrics, err := unmarshaler.UnmarshalMetrics(buf) - require.NoError(b, err) - assert.Equal(b, baseMetrics.ResourceMetrics().Len(), metrics.ResourceMetrics().Len()) - } -} - -func BenchmarkTracesToProtobuf(b *testing.B) { - marshaler := NewProtobufTracesMarshaler() - traces := generateBenchmarkTraces(128) - b.ResetTimer() - for n := 0; n < b.N; n++ { - buf, err := marshaler.MarshalTraces(traces) - require.NoError(b, err) - assert.NotEqual(b, 0, len(buf)) - } -} - -func BenchmarkTracesFromProtobuf(b *testing.B) { - marshaler := NewProtobufTracesMarshaler() - unmarshaler := NewProtobufTracesUnmarshaler() - baseTraces := generateBenchmarkTraces(128) - buf, err := marshaler.MarshalTraces(baseTraces) - require.NoError(b, err) - assert.NotEqual(b, 0, len(buf)) - b.ResetTimer() - b.ReportAllocs() - for n := 0; n < b.N; n++ { - traces, err := unmarshaler.UnmarshalTraces(buf) - require.NoError(b, err) - assert.Equal(b, baseTraces.ResourceSpans().Len(), traces.ResourceSpans().Len()) - } -} - -func generateBenchmarkLogs(logsCount int) pdata.Logs { - endTime := pdata.NewTimestampFromTime(time.Now()) - - md := pdata.NewLogs() - ilm := md.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty() - ilm.LogRecords().EnsureCapacity(logsCount) - for i := 0; i < logsCount; i++ { - im := ilm.LogRecords().AppendEmpty() - im.SetTimestamp(endTime) - } - return md -} - -func generateBenchmarkMetrics(metricsCount int) pdata.Metrics { - now := time.Now() - startTime := pdata.NewTimestampFromTime(now.Add(-10 * time.Second)) - endTime := pdata.NewTimestampFromTime(now) - - md := pdata.NewMetrics() - ilm := md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty() - ilm.Metrics().EnsureCapacity(metricsCount) - for i := 0; i < metricsCount; i++ { - im := ilm.Metrics().AppendEmpty() - im.SetName("test_name") - im.SetDataType(pdata.MetricDataTypeSum) - idp := im.Sum().DataPoints().AppendEmpty() - idp.SetStartTimestamp(startTime) - idp.SetTimestamp(endTime) - idp.SetIntVal(123) - } - return md -} - -func generateBenchmarkTraces(metricsCount int) pdata.Traces { - now := time.Now() - startTime := pdata.NewTimestampFromTime(now.Add(-10 * time.Second)) - endTime := pdata.NewTimestampFromTime(now) - - md := pdata.NewTraces() - ilm := md.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty() - ilm.Spans().EnsureCapacity(metricsCount) - for i := 0; i < metricsCount; i++ { - im := ilm.Spans().AppendEmpty() - im.SetName("test_name") - im.SetStartTimestamp(startTime) - im.SetEndTimestamp(endTime) - } - return md -} diff --git a/model/otlp/pb_unmarshaler.go b/model/otlp/pb_unmarshaler.go index 5a5fc1b895c..d8fc4b7a4eb 100644 --- a/model/otlp/pb_unmarshaler.go +++ b/model/otlp/pb_unmarshaler.go @@ -15,48 +15,19 @@ package otlp // import "go.opentelemetry.io/collector/model/otlp" import ( - ipdata "go.opentelemetry.io/collector/model/internal" - otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" - otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" - otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) -type pbUnmarshaler struct{} - // NewProtobufTracesUnmarshaler returns a model.TracesUnmarshaler. Unmarshals from OTLP binary protobuf bytes. -func NewProtobufTracesUnmarshaler() pdata.TracesUnmarshaler { - return newPbUnmarshaler() -} +// Deprecated: [v0.49.0] Use ptrace.NewProtoUnmarshaler instead. +var NewProtobufTracesUnmarshaler = ptrace.NewProtoUnmarshaler // NewProtobufMetricsUnmarshaler returns a model.MetricsUnmarshaler. Unmarshals from OTLP binary protobuf bytes. -func NewProtobufMetricsUnmarshaler() pdata.MetricsUnmarshaler { - return newPbUnmarshaler() -} +// Deprecated: [v0.49.0] Use pmetric.NewProtoUnmarshaler instead. +var NewProtobufMetricsUnmarshaler = pmetric.NewProtoUnmarshaler // NewProtobufLogsUnmarshaler returns a model.LogsUnmarshaler. Unmarshals from OTLP binary protobuf bytes. -func NewProtobufLogsUnmarshaler() pdata.LogsUnmarshaler { - return newPbUnmarshaler() -} - -func newPbUnmarshaler() *pbUnmarshaler { - return &pbUnmarshaler{} -} - -func (d *pbUnmarshaler) UnmarshalLogs(buf []byte) (pdata.Logs, error) { - ld := &otlplogs.LogsData{} - err := ld.Unmarshal(buf) - return ipdata.LogsFromOtlp(ld), err -} - -func (d *pbUnmarshaler) UnmarshalMetrics(buf []byte) (pdata.Metrics, error) { - md := &otlpmetrics.MetricsData{} - err := md.Unmarshal(buf) - return ipdata.MetricsFromOtlp(md), err -} - -func (d *pbUnmarshaler) UnmarshalTraces(buf []byte) (pdata.Traces, error) { - td := &otlptrace.TracesData{} - err := td.Unmarshal(buf) - return ipdata.TracesFromOtlp(td), err -} +// Deprecated: [v0.49.0] Use plog.NewProtoUnmarshaler instead. +var NewProtobufLogsUnmarshaler = plog.NewProtoUnmarshaler diff --git a/model/otlpgrpc/logs.go b/model/otlpgrpc/logs.go index 69efbc14518..2e26c1e2ba6 100644 --- a/model/otlpgrpc/logs.go +++ b/model/otlpgrpc/logs.go @@ -15,150 +15,39 @@ package otlpgrpc // import "go.opentelemetry.io/collector/model/otlpgrpc" import ( - "bytes" - "context" - - "github.com/gogo/protobuf/jsonpb" - "google.golang.org/grpc" - - ipdata "go.opentelemetry.io/collector/model/internal" - otlpcollectorlog "go.opentelemetry.io/collector/model/internal/data/protogen/collector/logs/v1" - otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" - "go.opentelemetry.io/collector/model/internal/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog/plogotlp" ) -var jsonMarshaler = &jsonpb.Marshaler{} -var jsonUnmarshaler = &jsonpb.Unmarshaler{} - // LogsResponse represents the response for gRPC client/server. -type LogsResponse struct { - orig *otlpcollectorlog.ExportLogsServiceResponse -} +// Deprecated: [v0.49.0] Use plogotlp.Response instead. +type LogsResponse = plogotlp.Response // NewLogsResponse returns an empty LogsResponse. -func NewLogsResponse() LogsResponse { - return LogsResponse{orig: &otlpcollectorlog.ExportLogsServiceResponse{}} -} - -// MarshalProto marshals LogsResponse into proto bytes. -func (lr LogsResponse) MarshalProto() ([]byte, error) { - return lr.orig.Marshal() -} - -// UnmarshalProto unmarshalls LogsResponse from proto bytes. -func (lr LogsResponse) UnmarshalProto(data []byte) error { - return lr.orig.Unmarshal(data) -} - -// MarshalJSON marshals LogsResponse into JSON bytes. -func (lr LogsResponse) MarshalJSON() ([]byte, error) { - var buf bytes.Buffer - if err := jsonMarshaler.Marshal(&buf, lr.orig); err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// UnmarshalJSON unmarshalls LogsResponse from JSON bytes. -func (lr LogsResponse) UnmarshalJSON(data []byte) error { - return jsonUnmarshaler.Unmarshal(bytes.NewReader(data), lr.orig) -} +// Deprecated: [v0.49.0] Use plogotlp.NewResponse instead. +var NewLogsResponse = plogotlp.NewResponse // LogsRequest represents the response for gRPC client/server. -type LogsRequest struct { - orig *otlpcollectorlog.ExportLogsServiceRequest -} +// Deprecated: [v0.49.0] Use plogotlp.Request instead. +type LogsRequest = plogotlp.Request // NewLogsRequest returns an empty LogsRequest. -func NewLogsRequest() LogsRequest { - return LogsRequest{orig: &otlpcollectorlog.ExportLogsServiceRequest{}} -} - -// MarshalProto marshals LogsRequest into proto bytes. -func (lr LogsRequest) MarshalProto() ([]byte, error) { - return lr.orig.Marshal() -} - -// UnmarshalProto unmarshalls LogsRequest from proto bytes. -func (lr LogsRequest) UnmarshalProto(data []byte) error { - if err := lr.orig.Unmarshal(data); err != nil { - return err - } - otlp.InstrumentationLibraryLogsToScope(lr.orig.ResourceLogs) - return nil -} - -// MarshalJSON marshals LogsRequest into JSON bytes. -func (lr LogsRequest) MarshalJSON() ([]byte, error) { - var buf bytes.Buffer - if err := jsonMarshaler.Marshal(&buf, lr.orig); err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// UnmarshalJSON unmarshalls LogsRequest from JSON bytes. -func (lr LogsRequest) UnmarshalJSON(data []byte) error { - if err := jsonUnmarshaler.Unmarshal(bytes.NewReader(data), lr.orig); err != nil { - return err - } - otlp.InstrumentationLibraryLogsToScope(lr.orig.ResourceLogs) - return nil -} - -func (lr LogsRequest) SetLogs(ld pdata.Logs) { - lr.orig.ResourceLogs = ipdata.LogsToOtlp(ld).ResourceLogs -} - -func (lr LogsRequest) Logs() pdata.Logs { - return ipdata.LogsFromOtlp(&otlplogs.LogsData{ResourceLogs: lr.orig.ResourceLogs}) -} +// Deprecated: [v0.49.0] Use plogotlp.NewRequest instead. +var NewLogsRequest = plogotlp.NewRequest // LogsClient is the client API for OTLP-GRPC Logs service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type LogsClient interface { - // Export pdata.Logs to the server. - // - // For performance reasons, it is recommended to keep this RPC - // alive for the entire life of the application. - Export(ctx context.Context, request LogsRequest, opts ...grpc.CallOption) (LogsResponse, error) -} - -type logsClient struct { - rawClient otlpcollectorlog.LogsServiceClient -} +// Deprecated: [v0.49.0] Use plogotlp.Client instead. +type LogsClient = plogotlp.Client // NewLogsClient returns a new LogsClient connected using the given connection. -func NewLogsClient(cc *grpc.ClientConn) LogsClient { - return &logsClient{rawClient: otlpcollectorlog.NewLogsServiceClient(cc)} -} - -func (c *logsClient) Export(ctx context.Context, request LogsRequest, opts ...grpc.CallOption) (LogsResponse, error) { - rsp, err := c.rawClient.Export(ctx, request.orig, opts...) - return LogsResponse{orig: rsp}, err -} +// Deprecated: [v0.49.0] Use plogotlp.NewClient instead. +var NewLogsClient = plogotlp.NewClient // LogsServer is the server API for OTLP gRPC LogsService service. -type LogsServer interface { - // Export is called every time a new request is received. - // - // For performance reasons, it is recommended to keep this RPC - // alive for the entire life of the application. - Export(context.Context, LogsRequest) (LogsResponse, error) -} +// Deprecated: [v0.49.0] Use plogotlp.Server instead. +type LogsServer = plogotlp.Server // RegisterLogsServer registers the LogsServer to the grpc.Server. -func RegisterLogsServer(s *grpc.Server, srv LogsServer) { - otlpcollectorlog.RegisterLogsServiceServer(s, &rawLogsServer{srv: srv}) -} - -type rawLogsServer struct { - srv LogsServer -} - -func (s rawLogsServer) Export(ctx context.Context, request *otlpcollectorlog.ExportLogsServiceRequest) (*otlpcollectorlog.ExportLogsServiceResponse, error) { - rsp, err := s.srv.Export(ctx, LogsRequest{orig: request}) - return rsp.orig, err -} +// Deprecated: [v0.49.0] Use plogotlp.RegisterServer instead. +var RegisterLogsServer = plogotlp.RegisterServer diff --git a/model/otlpgrpc/metrics.go b/model/otlpgrpc/metrics.go index 1abbdc22def..51ab5a55b1e 100644 --- a/model/otlpgrpc/metrics.go +++ b/model/otlpgrpc/metrics.go @@ -15,142 +15,39 @@ package otlpgrpc // import "go.opentelemetry.io/collector/model/otlpgrpc" import ( - "bytes" - "context" - - "google.golang.org/grpc" - - ipdata "go.opentelemetry.io/collector/model/internal" - otlpcollectormetrics "go.opentelemetry.io/collector/model/internal/data/protogen/collector/metrics/v1" - otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/model/internal/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp" ) // MetricsResponse represents the response for gRPC client/server. -type MetricsResponse struct { - orig *otlpcollectormetrics.ExportMetricsServiceResponse -} +// Deprecated: [v0.49.0] Use pmetricotlp.Response instead. +type MetricsResponse = pmetricotlp.Response // NewMetricsResponse returns an empty MetricsResponse. -func NewMetricsResponse() MetricsResponse { - return MetricsResponse{orig: &otlpcollectormetrics.ExportMetricsServiceResponse{}} -} - -// MarshalProto marshals MetricsResponse into proto bytes. -func (mr MetricsResponse) MarshalProto() ([]byte, error) { - return mr.orig.Marshal() -} - -// UnmarshalProto unmarshalls MetricsResponse from proto bytes. -func (mr MetricsResponse) UnmarshalProto(data []byte) error { - return mr.orig.Unmarshal(data) -} - -// MarshalJSON marshals MetricsResponse into JSON bytes. -func (mr MetricsResponse) MarshalJSON() ([]byte, error) { - var buf bytes.Buffer - if err := jsonMarshaler.Marshal(&buf, mr.orig); err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// UnmarshalJSON unmarshalls MetricsResponse from JSON bytes. -func (mr MetricsResponse) UnmarshalJSON(data []byte) error { - return jsonUnmarshaler.Unmarshal(bytes.NewReader(data), mr.orig) -} +// Deprecated: [v0.49.0] Use pmetricotlp.NewResponse instead. +var NewMetricsResponse = pmetricotlp.NewResponse // MetricsRequest represents the response for gRPC client/server. -type MetricsRequest struct { - orig *otlpcollectormetrics.ExportMetricsServiceRequest -} +// Deprecated: [v0.49.0] Use pmetricotlp.Request instead. +type MetricsRequest = pmetricotlp.Request // NewMetricsRequest returns an empty MetricsRequest. -func NewMetricsRequest() MetricsRequest { - return MetricsRequest{orig: &otlpcollectormetrics.ExportMetricsServiceRequest{}} -} - -// MarshalProto marshals MetricsRequest into proto bytes. -func (mr MetricsRequest) MarshalProto() ([]byte, error) { - return mr.orig.Marshal() -} - -// UnmarshalProto unmarshalls MetricsRequest from proto bytes. -func (mr MetricsRequest) UnmarshalProto(data []byte) error { - return mr.orig.Unmarshal(data) -} - -// MarshalJSON marshals MetricsRequest into JSON bytes. -func (mr MetricsRequest) MarshalJSON() ([]byte, error) { - var buf bytes.Buffer - if err := jsonMarshaler.Marshal(&buf, mr.orig); err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// UnmarshalJSON unmarshalls MetricsRequest from JSON bytes. -func (mr MetricsRequest) UnmarshalJSON(data []byte) error { - if err := jsonUnmarshaler.Unmarshal(bytes.NewReader(data), mr.orig); err != nil { - return err - } - otlp.InstrumentationLibraryMetricsToScope(mr.orig.ResourceMetrics) - return nil -} - -func (mr MetricsRequest) SetMetrics(ld pdata.Metrics) { - mr.orig.ResourceMetrics = ipdata.MetricsToOtlp(ld).ResourceMetrics -} - -func (mr MetricsRequest) Metrics() pdata.Metrics { - return ipdata.MetricsFromOtlp(&otlpmetrics.MetricsData{ResourceMetrics: mr.orig.ResourceMetrics}) -} +// Deprecated: [v0.49.0] Use pmetricotlp.NewRequest instead. +var NewMetricsRequest = pmetricotlp.NewRequest // MetricsClient is the client API for OTLP-GRPC Metrics service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MetricsClient interface { - // Export pdata.Metrics to the server. - // - // For performance reasons, it is recommended to keep this RPC - // alive for the entire life of the application. - Export(ctx context.Context, request MetricsRequest, opts ...grpc.CallOption) (MetricsResponse, error) -} - -type metricsClient struct { - rawClient otlpcollectormetrics.MetricsServiceClient -} +// Deprecated: [v0.49.0] Use pmetricotlp.Client instead. +type MetricsClient = pmetricotlp.Client // NewMetricsClient returns a new MetricsClient connected using the given connection. -func NewMetricsClient(cc *grpc.ClientConn) MetricsClient { - return &metricsClient{rawClient: otlpcollectormetrics.NewMetricsServiceClient(cc)} -} - -func (c *metricsClient) Export(ctx context.Context, request MetricsRequest, opts ...grpc.CallOption) (MetricsResponse, error) { - rsp, err := c.rawClient.Export(ctx, request.orig, opts...) - return MetricsResponse{orig: rsp}, err -} +// Deprecated: [v0.49.0] Use pmetricotlp.NewClient instead. +var NewMetricsClient = pmetricotlp.NewClient // MetricsServer is the server API for OTLP gRPC MetricsService service. -type MetricsServer interface { - // Export is called every time a new request is received. - // - // For performance reasons, it is recommended to keep this RPC - // alive for the entire life of the application. - Export(context.Context, MetricsRequest) (MetricsResponse, error) -} +// Deprecated: [v0.49.0] Use pmetricotlp.Server instead. +type MetricsServer = pmetricotlp.Server // RegisterMetricsServer registers the MetricsServer to the grpc.Server. -func RegisterMetricsServer(s *grpc.Server, srv MetricsServer) { - otlpcollectormetrics.RegisterMetricsServiceServer(s, &rawMetricsServer{srv: srv}) -} - -type rawMetricsServer struct { - srv MetricsServer -} - -func (s rawMetricsServer) Export(ctx context.Context, request *otlpcollectormetrics.ExportMetricsServiceRequest) (*otlpcollectormetrics.ExportMetricsServiceResponse, error) { - rsp, err := s.srv.Export(ctx, MetricsRequest{orig: request}) - return rsp.orig, err -} +// Deprecated: [v0.49.0] Use pmetricotlp.RegisterServer instead. +var RegisterMetricsServer = pmetricotlp.RegisterServer diff --git a/model/otlpgrpc/traces.go b/model/otlpgrpc/traces.go index c2a78b1c1c1..94a1200f98a 100644 --- a/model/otlpgrpc/traces.go +++ b/model/otlpgrpc/traces.go @@ -15,147 +15,39 @@ package otlpgrpc // import "go.opentelemetry.io/collector/model/otlpgrpc" import ( - "bytes" - "context" - - "google.golang.org/grpc" - - ipdata "go.opentelemetry.io/collector/model/internal" - otlpcollectortrace "go.opentelemetry.io/collector/model/internal/data/protogen/collector/trace/v1" - otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" - "go.opentelemetry.io/collector/model/internal/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" ) // TracesResponse represents the response for gRPC client/server. -type TracesResponse struct { - orig *otlpcollectortrace.ExportTraceServiceResponse -} +// Deprecated: [v0.49.0] Use ptraceotlp.Response instead. +type TracesResponse = ptraceotlp.Response // NewTracesResponse returns an empty TracesResponse. -func NewTracesResponse() TracesResponse { - return TracesResponse{orig: &otlpcollectortrace.ExportTraceServiceResponse{}} -} - -// MarshalProto marshals TracesResponse into proto bytes. -func (tr TracesResponse) MarshalProto() ([]byte, error) { - return tr.orig.Marshal() -} - -// UnmarshalProto unmarshalls TracesResponse from proto bytes. -func (tr TracesResponse) UnmarshalProto(data []byte) error { - return tr.orig.Unmarshal(data) -} - -// MarshalJSON marshals TracesResponse into JSON bytes. -func (tr TracesResponse) MarshalJSON() ([]byte, error) { - var buf bytes.Buffer - if err := jsonMarshaler.Marshal(&buf, tr.orig); err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// UnmarshalJSON unmarshalls TracesResponse from JSON bytes. -func (tr TracesResponse) UnmarshalJSON(data []byte) error { - return jsonUnmarshaler.Unmarshal(bytes.NewReader(data), tr.orig) -} +// Deprecated: [v0.49.0] Use ptraceotlp.NewResponse instead. +var NewTracesResponse = ptraceotlp.NewResponse // TracesRequest represents the response for gRPC client/server. -type TracesRequest struct { - orig *otlpcollectortrace.ExportTraceServiceRequest -} +// Deprecated: [v0.49.0] Use ptraceotlp.Request instead. +type TracesRequest = ptraceotlp.Request // NewTracesRequest returns an empty TracesRequest. -func NewTracesRequest() TracesRequest { - return TracesRequest{orig: &otlpcollectortrace.ExportTraceServiceRequest{}} -} - -// MarshalProto marshals TracesRequest into proto bytes. -func (tr TracesRequest) MarshalProto() ([]byte, error) { - return tr.orig.Marshal() -} - -// UnmarshalProto unmarshalls TracesRequest from proto bytes. -func (tr TracesRequest) UnmarshalProto(data []byte) error { - if err := tr.orig.Unmarshal(data); err != nil { - return err - } - otlp.InstrumentationLibrarySpansToScope(tr.orig.ResourceSpans) - return nil -} - -// MarshalJSON marshals TracesRequest into JSON bytes. -func (tr TracesRequest) MarshalJSON() ([]byte, error) { - var buf bytes.Buffer - if err := jsonMarshaler.Marshal(&buf, tr.orig); err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// UnmarshalJSON unmarshalls TracesRequest from JSON bytes. -func (tr TracesRequest) UnmarshalJSON(data []byte) error { - if err := jsonUnmarshaler.Unmarshal(bytes.NewReader(data), tr.orig); err != nil { - return err - } - otlp.InstrumentationLibrarySpansToScope(tr.orig.ResourceSpans) - return nil -} - -func (tr TracesRequest) SetTraces(td pdata.Traces) { - tr.orig.ResourceSpans = ipdata.TracesToOtlp(td).ResourceSpans -} - -func (tr TracesRequest) Traces() pdata.Traces { - return ipdata.TracesFromOtlp(&otlptrace.TracesData{ResourceSpans: tr.orig.ResourceSpans}) -} +// Deprecated: [v0.49.0] Use ptraceotlp.NewRequest instead. +var NewTracesRequest = ptraceotlp.NewRequest // TracesClient is the client API for OTLP-GRPC Traces service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type TracesClient interface { - // Export pdata.Traces to the server. - // - // For performance reasons, it is recommended to keep this RPC - // alive for the entire life of the application. - Export(ctx context.Context, request TracesRequest, opts ...grpc.CallOption) (TracesResponse, error) -} - -type tracesClient struct { - rawClient otlpcollectortrace.TraceServiceClient -} +// Deprecated: [v0.49.0] Use ptraceotlp.Client instead. +type TracesClient = ptraceotlp.Client // NewTracesClient returns a new TracesClient connected using the given connection. -func NewTracesClient(cc *grpc.ClientConn) TracesClient { - return &tracesClient{rawClient: otlpcollectortrace.NewTraceServiceClient(cc)} -} - -// Export implements the TracesClient interface. -func (c *tracesClient) Export(ctx context.Context, request TracesRequest, opts ...grpc.CallOption) (TracesResponse, error) { - rsp, err := c.rawClient.Export(ctx, request.orig, opts...) - return TracesResponse{orig: rsp}, err -} +// Deprecated: [v0.49.0] Use ptraceotlp.NewClient instead. +var NewTracesClient = ptraceotlp.NewClient // TracesServer is the server API for OTLP gRPC TracesService service. -type TracesServer interface { - // Export is called every time a new request is received. - // - // For performance reasons, it is recommended to keep this RPC - // alive for the entire life of the application. - Export(context.Context, TracesRequest) (TracesResponse, error) -} +// Deprecated: [v0.49.0] Use ptraceotlp.Server instead. +type TracesServer = ptraceotlp.Server // RegisterTracesServer registers the TracesServer to the grpc.Server. -func RegisterTracesServer(s *grpc.Server, srv TracesServer) { - otlpcollectortrace.RegisterTraceServiceServer(s, &rawTracesServer{srv: srv}) -} - -type rawTracesServer struct { - srv TracesServer -} - -func (s rawTracesServer) Export(ctx context.Context, request *otlpcollectortrace.ExportTraceServiceRequest) (*otlpcollectortrace.ExportTraceServiceResponse, error) { - rsp, err := s.srv.Export(ctx, TracesRequest{orig: request}) - return rsp.orig, err -} +// Deprecated: [v0.49.0] Use ptraceotlp.RegisterServer instead. +var RegisterTracesServer = ptraceotlp.RegisterServer diff --git a/model/pdata/common.go b/model/pdata/common.go new file mode 100644 index 00000000000..d3aabc81f85 --- /dev/null +++ b/model/pdata/common.go @@ -0,0 +1,29 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pdata // import "go.opentelemetry.io/collector/model/pdata" + +import ( + "go.opentelemetry.io/collector/pdata/pcommon" +) + +// NewAttributeMapFromMap creates a Map with values from the given map[string]Value. +// Deprecated: [v0.48.0] Use pcommon.NewMapFromRaw instead. +func NewAttributeMapFromMap(rawMap map[string]pcommon.Value) pcommon.Map { + m := pcommon.NewMap() + for k, v := range rawMap { + m.Insert(k, v) + } + return m +} diff --git a/model/pdata/common_alias.go b/model/pdata/common_alias.go index 606b834cb71..10bb8ff0d6b 100644 --- a/model/pdata/common_alias.go +++ b/model/pdata/common_alias.go @@ -17,118 +17,152 @@ package pdata // import "go.opentelemetry.io/collector/model/pdata" // This file contains aliases to data structures that are common for all // signal types, such as timestamps, attributes, etc. -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/pcommon" -// ValueType is an alias for internal.ValueType type. -type ValueType = internal.ValueType +// ValueType is an alias for pcommon.ValueType type. +// Deprecated: [v0.49.0] Use pcommon.ValueType instead. +type ValueType = pcommon.ValueType -// AttributeValueType is an alias for internal.ValueType type. +// AttributeValueType is an alias for pcommon.ValueType type. // Deprecated: [v0.48.0] Use ValueType instead. -type AttributeValueType = internal.ValueType +type AttributeValueType = pcommon.ValueType const ( - ValueTypeEmpty = internal.ValueTypeEmpty - ValueTypeString = internal.ValueTypeString - ValueTypeInt = internal.ValueTypeInt - ValueTypeDouble = internal.ValueTypeDouble - ValueTypeBool = internal.ValueTypeBool - ValueTypeMap = internal.ValueTypeMap - ValueTypeSlice = internal.ValueTypeSlice - ValueTypeBytes = internal.ValueTypeBytes + // Deprecated: [v0.49.0] Use pcommon.ValueTypeEmpty instead. + ValueTypeEmpty = pcommon.ValueTypeEmpty + + // Deprecated: [v0.49.0] Use pcommon.ValueTypeString instead. + ValueTypeString = pcommon.ValueTypeString + + // Deprecated: [v0.49.0] Use pcommon.ValueTypeInt instead. + ValueTypeInt = pcommon.ValueTypeInt + + // Deprecated: [v0.49.0] Use pcommon.ValueTypeDouble instead. + ValueTypeDouble = pcommon.ValueTypeDouble + + // Deprecated: [v0.49.0] Use pcommon.ValueTypeBool instead. + ValueTypeBool = pcommon.ValueTypeBool + + // Deprecated: [v0.49.0] Use pcommon.ValueTypeMap instead. + ValueTypeMap = pcommon.ValueTypeMap + + // Deprecated: [v0.49.0] Use pcommon.ValueTypeSlice instead. + ValueTypeSlice = pcommon.ValueTypeSlice + + // Deprecated: [v0.49.0] Use pcommon.ValueTypeBytes instead. + ValueTypeBytes = pcommon.ValueTypeBytes // Deprecated: [v0.48.0] Use ValueTypeEmpty instead. - AttributeValueTypeEmpty = internal.ValueTypeEmpty + AttributeValueTypeEmpty = pcommon.ValueTypeEmpty // Deprecated: [v0.48.0] Use ValueTypeString instead. - AttributeValueTypeString = internal.ValueTypeString + AttributeValueTypeString = pcommon.ValueTypeString // Deprecated: [v0.48.0] Use ValueTypeInt instead. - AttributeValueTypeInt = internal.ValueTypeInt + AttributeValueTypeInt = pcommon.ValueTypeInt // Deprecated: [v0.48.0] Use ValueTypeDouble instead. - AttributeValueTypeDouble = internal.ValueTypeDouble + AttributeValueTypeDouble = pcommon.ValueTypeDouble // Deprecated: [v0.48.0] Use ValueTypeBool instead. - AttributeValueTypeBool = internal.ValueTypeBool + AttributeValueTypeBool = pcommon.ValueTypeBool // Deprecated: [v0.48.0] Use ValueTypeMap instead. - AttributeValueTypeMap = internal.ValueTypeMap + AttributeValueTypeMap = pcommon.ValueTypeMap // Deprecated: [v0.48.0] Use ValueTypeSlice instead. - AttributeValueTypeArray = internal.ValueTypeSlice + AttributeValueTypeArray = pcommon.ValueTypeSlice // Deprecated: [v0.48.0] Use ValueTypeBytes instead. - AttributeValueTypeBytes = internal.ValueTypeBytes + AttributeValueTypeBytes = pcommon.ValueTypeBytes ) -// Value is an alias for internal.Value struct. -type Value = internal.Value +// Value is an alias for pcommon.Value struct. +// Deprecated: [v0.49.0] Use pcommon.Value instead. +type Value = pcommon.Value // Deprecated: [v0.48.0] Use Value instead. -type AttributeValue = internal.Value +type AttributeValue = pcommon.Value -// Aliases for functions to create internal.Value. +// Aliases for functions to create pcommon.Value. var ( - NewValueEmpty = internal.NewValueEmpty - NewValueString = internal.NewValueString - NewValueInt = internal.NewValueInt - NewValueDouble = internal.NewValueDouble - NewValueBool = internal.NewValueBool - NewValueMap = internal.NewValueMap - NewValueSlice = internal.NewValueSlice - NewValueBytes = internal.NewValueBytes + + // Deprecated: [v0.49.0] Use pcommon.NewValueEmpty instead. + NewValueEmpty = pcommon.NewValueEmpty + + // Deprecated: [v0.49.0] Use pcommon.NewValueString instead. + NewValueString = pcommon.NewValueString + + // Deprecated: [v0.49.0] Use pcommon.NewValueInt instead. + NewValueInt = pcommon.NewValueInt + + // Deprecated: [v0.49.0] Use pcommon.NewValueDouble instead. + NewValueDouble = pcommon.NewValueDouble + + // Deprecated: [v0.49.0] Use pcommon.NewValueBool instead. + NewValueBool = pcommon.NewValueBool + + // Deprecated: [v0.49.0] Use pcommon.NewValueMap instead. + NewValueMap = pcommon.NewValueMap + + // Deprecated: [v0.49.0] Use pcommon.NewValueSlice instead. + NewValueSlice = pcommon.NewValueSlice + + // Deprecated: [v0.49.0] Use pcommon.NewValueBytes instead. + NewValueBytes = pcommon.NewValueBytes // Deprecated: [v0.48.0] Use NewValueEmpty instead. - NewAttributeValueEmpty = internal.NewValueEmpty + NewAttributeValueEmpty = pcommon.NewValueEmpty // Deprecated: [v0.48.0] Use NewValueString instead. - NewAttributeValueString = internal.NewValueString + NewAttributeValueString = pcommon.NewValueString // Deprecated: [v0.48.0] Use NewValueInt instead. - NewAttributeValueInt = internal.NewValueInt + NewAttributeValueInt = pcommon.NewValueInt // Deprecated: [v0.48.0] Use NewValueDouble instead. - NewAttributeValueDouble = internal.NewValueDouble + NewAttributeValueDouble = pcommon.NewValueDouble // Deprecated: [v0.48.0] Use NewValueBool instead. - NewAttributeValueBool = internal.NewValueBool + NewAttributeValueBool = pcommon.NewValueBool // Deprecated: [v0.48.0] Use NewValueMap instead. - NewAttributeValueMap = internal.NewValueMap + NewAttributeValueMap = pcommon.NewValueMap // Deprecated: [v0.48.0] Use NewValueSlice instead. - NewAttributeValueArray = internal.NewValueSlice + NewAttributeValueArray = pcommon.NewValueSlice // Deprecated: [v0.48.0] Use NewValueBytes instead. - NewAttributeValueBytes = internal.NewValueBytes + NewAttributeValueBytes = pcommon.NewValueBytes ) -// Map is an alias for internal.Map struct. -type Map = internal.Map +// Map is an alias for pcommon.Map struct. +// Deprecated: [v0.49.0] Use pcommon.Map instead. +type Map = pcommon.Map // Deprecated: [v0.48.0] Use Map instead. -type AttributeMap = internal.Map +type AttributeMap = pcommon.Map -// Aliases for functions to create internal.Map. +// Aliases for functions to create pcommon.Map. var ( - NewMap = internal.NewMap - NewMapFromRaw = internal.NewMapFromRaw + // Deprecated: [v0.49.0] Use pcommon.NewMap instead. + NewMap = pcommon.NewMap + + // Deprecated: [v0.49.0] Use pcommon.NewMapFromRaw instead. + NewMapFromRaw = pcommon.NewMapFromRaw ) // Deprecated: [v0.48.0] Use NewMap instead. -var NewAttributeMap = internal.NewMap - -// Deprecated: [v0.48.0] Use NewMapFromRaw instead. -var NewAttributeMapFromMap = internal.NewAttributeMapFromMap +var NewAttributeMap = pcommon.NewMap // Deprecated: [v0.48.0] Use Slice instead. -type AttributeValueSlice = internal.Slice +type AttributeValueSlice = pcommon.Slice // Deprecated: [v0.48.0] Use NewSlice instead. -var NewAttributeValueSlice = internal.NewSlice +var NewAttributeValueSlice = pcommon.NewSlice // Deprecated: [v0.48.0] Use InstrumentationScope instead. -type InstrumentationLibrary = internal.InstrumentationScope +type InstrumentationLibrary = pcommon.InstrumentationScope // Deprecated: [v0.48.0] Use NewInstrumentationScope instead. -var NewInstrumentationLibrary = internal.NewInstrumentationScope +var NewInstrumentationLibrary = pcommon.NewInstrumentationScope diff --git a/model/pdata/common_test.go b/model/pdata/common_test.go new file mode 100644 index 00000000000..ef7f7c050b3 --- /dev/null +++ b/model/pdata/common_test.go @@ -0,0 +1,59 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pdata + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestNewAttributeMapFromMapDeprecated(t *testing.T) { + rawMap := map[string]Value{ + "k_string": NewValueString("123"), + "k_int": NewValueInt(int64(123)), + "k_double": NewValueDouble(float64(1.23)), + "k_bool": NewValueBool(true), + "k_null": NewValueEmpty(), + "k_bytes": NewValueBytes([]byte{1, 2, 3}), + } + + am := NewAttributeMapFromMap(rawMap) + assert.Equal(t, 6, am.Len()) + + v, ok := am.Get("k_string") + assert.True(t, ok) + assert.Equal(t, "123", v.StringVal()) + + v, ok = am.Get("k_int") + assert.True(t, ok) + assert.Equal(t, int64(123), v.IntVal()) + + v, ok = am.Get("k_double") + assert.True(t, ok) + assert.Equal(t, float64(1.23), v.DoubleVal()) + + v, ok = am.Get("k_bool") + assert.True(t, ok) + assert.Equal(t, true, v.BoolVal()) + + v, ok = am.Get("k_null") + assert.True(t, ok) + assert.Equal(t, ValueTypeEmpty, v.Type()) + + v, ok = am.Get("k_bytes") + assert.True(t, ok) + assert.Equal(t, []byte{1, 2, 3}, v.BytesVal()) +} diff --git a/model/pdata/generated_common_alias.go b/model/pdata/generated_common_alias.go index 3141c19d7b0..56f0c11b171 100644 --- a/model/pdata/generated_common_alias.go +++ b/model/pdata/generated_common_alias.go @@ -17,16 +17,20 @@ package pdata -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/pcommon" -// InstrumentationScope is an alias for internal.InstrumentationScope struct. -type InstrumentationScope = internal.InstrumentationScope +// InstrumentationScope is an alias for pcommon.InstrumentationScope struct. +// Deprecated: [v0.49.0] Use pcommon.InstrumentationScope instead. +type InstrumentationScope = pcommon.InstrumentationScope // NewInstrumentationScope is an alias for a function to create a new empty InstrumentationScope. -var NewInstrumentationScope = internal.NewInstrumentationScope +// Deprecated: [v0.49.0] Use pcommon.InstrumentationScope instead. +var NewInstrumentationScope = pcommon.NewInstrumentationScope -// Slice is an alias for internal.Slice struct. -type Slice = internal.Slice +// Slice is an alias for pcommon.Slice struct. +// Deprecated: [v0.49.0] Use pcommon.Slice instead. +type Slice = pcommon.Slice // NewSlice is an alias for a function to create Slice. -var NewSlice = internal.NewSlice +// Deprecated: [v0.49.0] Use pcommon.NewSlice instead. +var NewSlice = pcommon.NewSlice diff --git a/model/pdata/generated_plog_alias.go b/model/pdata/generated_plog_alias.go new file mode 100644 index 00000000000..668acadebff --- /dev/null +++ b/model/pdata/generated_plog_alias.go @@ -0,0 +1,68 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package pdata + +import "go.opentelemetry.io/collector/pdata/plog" + +// ResourceLogsSlice is an alias for plog.ResourceLogsSlice struct. +// Deprecated: [v0.49.0] Use plog.ResourceLogsSlice instead. +type ResourceLogsSlice = plog.ResourceLogsSlice + +// NewResourceLogsSlice is an alias for a function to create ResourceLogsSlice. +// Deprecated: [v0.49.0] Use plog.NewResourceLogsSlice instead. +var NewResourceLogsSlice = plog.NewResourceLogsSlice + +// ResourceLogs is an alias for plog.ResourceLogs struct. +// Deprecated: [v0.49.0] Use plog.ResourceLogs instead. +type ResourceLogs = plog.ResourceLogs + +// NewResourceLogs is an alias for a function to create a new empty ResourceLogs. +// Deprecated: [v0.49.0] Use plog.ResourceLogs instead. +var NewResourceLogs = plog.NewResourceLogs + +// ScopeLogsSlice is an alias for plog.ScopeLogsSlice struct. +// Deprecated: [v0.49.0] Use plog.ScopeLogsSlice instead. +type ScopeLogsSlice = plog.ScopeLogsSlice + +// NewScopeLogsSlice is an alias for a function to create ScopeLogsSlice. +// Deprecated: [v0.49.0] Use plog.NewScopeLogsSlice instead. +var NewScopeLogsSlice = plog.NewScopeLogsSlice + +// ScopeLogs is an alias for plog.ScopeLogs struct. +// Deprecated: [v0.49.0] Use plog.ScopeLogs instead. +type ScopeLogs = plog.ScopeLogs + +// NewScopeLogs is an alias for a function to create a new empty ScopeLogs. +// Deprecated: [v0.49.0] Use plog.ScopeLogs instead. +var NewScopeLogs = plog.NewScopeLogs + +// LogRecordSlice is an alias for plog.LogRecordSlice struct. +// Deprecated: [v0.49.0] Use plog.LogRecordSlice instead. +type LogRecordSlice = plog.LogRecordSlice + +// NewLogRecordSlice is an alias for a function to create LogRecordSlice. +// Deprecated: [v0.49.0] Use plog.NewLogRecordSlice instead. +var NewLogRecordSlice = plog.NewLogRecordSlice + +// LogRecord is an alias for plog.LogRecord struct. +// Deprecated: [v0.49.0] Use plog.LogRecord instead. +type LogRecord = plog.LogRecord + +// NewLogRecord is an alias for a function to create a new empty LogRecord. +// Deprecated: [v0.49.0] Use plog.LogRecord instead. +var NewLogRecord = plog.NewLogRecord diff --git a/model/pdata/generated_pmetric_alias.go b/model/pdata/generated_pmetric_alias.go new file mode 100644 index 00000000000..f97b99d6952 --- /dev/null +++ b/model/pdata/generated_pmetric_alias.go @@ -0,0 +1,212 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package pdata + +import "go.opentelemetry.io/collector/pdata/pmetric" + +// ResourceMetricsSlice is an alias for pmetric.ResourceMetricsSlice struct. +// Deprecated: [v0.49.0] Use pmetric.ResourceMetricsSlice instead. +type ResourceMetricsSlice = pmetric.ResourceMetricsSlice + +// NewResourceMetricsSlice is an alias for a function to create ResourceMetricsSlice. +// Deprecated: [v0.49.0] Use pmetric.NewResourceMetricsSlice instead. +var NewResourceMetricsSlice = pmetric.NewResourceMetricsSlice + +// ResourceMetrics is an alias for pmetric.ResourceMetrics struct. +// Deprecated: [v0.49.0] Use pmetric.ResourceMetrics instead. +type ResourceMetrics = pmetric.ResourceMetrics + +// NewResourceMetrics is an alias for a function to create a new empty ResourceMetrics. +// Deprecated: [v0.49.0] Use pmetric.ResourceMetrics instead. +var NewResourceMetrics = pmetric.NewResourceMetrics + +// ScopeMetricsSlice is an alias for pmetric.ScopeMetricsSlice struct. +// Deprecated: [v0.49.0] Use pmetric.ScopeMetricsSlice instead. +type ScopeMetricsSlice = pmetric.ScopeMetricsSlice + +// NewScopeMetricsSlice is an alias for a function to create ScopeMetricsSlice. +// Deprecated: [v0.49.0] Use pmetric.NewScopeMetricsSlice instead. +var NewScopeMetricsSlice = pmetric.NewScopeMetricsSlice + +// ScopeMetrics is an alias for pmetric.ScopeMetrics struct. +// Deprecated: [v0.49.0] Use pmetric.ScopeMetrics instead. +type ScopeMetrics = pmetric.ScopeMetrics + +// NewScopeMetrics is an alias for a function to create a new empty ScopeMetrics. +// Deprecated: [v0.49.0] Use pmetric.ScopeMetrics instead. +var NewScopeMetrics = pmetric.NewScopeMetrics + +// MetricSlice is an alias for pmetric.MetricSlice struct. +// Deprecated: [v0.49.0] Use pmetric.MetricSlice instead. +type MetricSlice = pmetric.MetricSlice + +// NewMetricSlice is an alias for a function to create MetricSlice. +// Deprecated: [v0.49.0] Use pmetric.NewMetricSlice instead. +var NewMetricSlice = pmetric.NewMetricSlice + +// Metric is an alias for pmetric.Metric struct. +// Deprecated: [v0.49.0] Use pmetric.Metric instead. +type Metric = pmetric.Metric + +// NewMetric is an alias for a function to create a new empty Metric. +// Deprecated: [v0.49.0] Use pmetric.Metric instead. +var NewMetric = pmetric.NewMetric + +// Gauge is an alias for pmetric.Gauge struct. +// Deprecated: [v0.49.0] Use pmetric.Gauge instead. +type Gauge = pmetric.Gauge + +// NewGauge is an alias for a function to create a new empty Gauge. +// Deprecated: [v0.49.0] Use pmetric.Gauge instead. +var NewGauge = pmetric.NewGauge + +// Sum is an alias for pmetric.Sum struct. +// Deprecated: [v0.49.0] Use pmetric.Sum instead. +type Sum = pmetric.Sum + +// NewSum is an alias for a function to create a new empty Sum. +// Deprecated: [v0.49.0] Use pmetric.Sum instead. +var NewSum = pmetric.NewSum + +// Histogram is an alias for pmetric.Histogram struct. +// Deprecated: [v0.49.0] Use pmetric.Histogram instead. +type Histogram = pmetric.Histogram + +// NewHistogram is an alias for a function to create a new empty Histogram. +// Deprecated: [v0.49.0] Use pmetric.Histogram instead. +var NewHistogram = pmetric.NewHistogram + +// ExponentialHistogram is an alias for pmetric.ExponentialHistogram struct. +// Deprecated: [v0.49.0] Use pmetric.ExponentialHistogram instead. +type ExponentialHistogram = pmetric.ExponentialHistogram + +// NewExponentialHistogram is an alias for a function to create a new empty ExponentialHistogram. +// Deprecated: [v0.49.0] Use pmetric.ExponentialHistogram instead. +var NewExponentialHistogram = pmetric.NewExponentialHistogram + +// Summary is an alias for pmetric.Summary struct. +// Deprecated: [v0.49.0] Use pmetric.Summary instead. +type Summary = pmetric.Summary + +// NewSummary is an alias for a function to create a new empty Summary. +// Deprecated: [v0.49.0] Use pmetric.Summary instead. +var NewSummary = pmetric.NewSummary + +// NumberDataPointSlice is an alias for pmetric.NumberDataPointSlice struct. +// Deprecated: [v0.49.0] Use pmetric.NumberDataPointSlice instead. +type NumberDataPointSlice = pmetric.NumberDataPointSlice + +// NewNumberDataPointSlice is an alias for a function to create NumberDataPointSlice. +// Deprecated: [v0.49.0] Use pmetric.NewNumberDataPointSlice instead. +var NewNumberDataPointSlice = pmetric.NewNumberDataPointSlice + +// NumberDataPoint is an alias for pmetric.NumberDataPoint struct. +// Deprecated: [v0.49.0] Use pmetric.NumberDataPoint instead. +type NumberDataPoint = pmetric.NumberDataPoint + +// NewNumberDataPoint is an alias for a function to create a new empty NumberDataPoint. +// Deprecated: [v0.49.0] Use pmetric.NumberDataPoint instead. +var NewNumberDataPoint = pmetric.NewNumberDataPoint + +// HistogramDataPointSlice is an alias for pmetric.HistogramDataPointSlice struct. +// Deprecated: [v0.49.0] Use pmetric.HistogramDataPointSlice instead. +type HistogramDataPointSlice = pmetric.HistogramDataPointSlice + +// NewHistogramDataPointSlice is an alias for a function to create HistogramDataPointSlice. +// Deprecated: [v0.49.0] Use pmetric.NewHistogramDataPointSlice instead. +var NewHistogramDataPointSlice = pmetric.NewHistogramDataPointSlice + +// HistogramDataPoint is an alias for pmetric.HistogramDataPoint struct. +// Deprecated: [v0.49.0] Use pmetric.HistogramDataPoint instead. +type HistogramDataPoint = pmetric.HistogramDataPoint + +// NewHistogramDataPoint is an alias for a function to create a new empty HistogramDataPoint. +// Deprecated: [v0.49.0] Use pmetric.HistogramDataPoint instead. +var NewHistogramDataPoint = pmetric.NewHistogramDataPoint + +// ExponentialHistogramDataPointSlice is an alias for pmetric.ExponentialHistogramDataPointSlice struct. +// Deprecated: [v0.49.0] Use pmetric.ExponentialHistogramDataPointSlice instead. +type ExponentialHistogramDataPointSlice = pmetric.ExponentialHistogramDataPointSlice + +// NewExponentialHistogramDataPointSlice is an alias for a function to create ExponentialHistogramDataPointSlice. +// Deprecated: [v0.49.0] Use pmetric.NewExponentialHistogramDataPointSlice instead. +var NewExponentialHistogramDataPointSlice = pmetric.NewExponentialHistogramDataPointSlice + +// ExponentialHistogramDataPoint is an alias for pmetric.ExponentialHistogramDataPoint struct. +// Deprecated: [v0.49.0] Use pmetric.ExponentialHistogramDataPoint instead. +type ExponentialHistogramDataPoint = pmetric.ExponentialHistogramDataPoint + +// NewExponentialHistogramDataPoint is an alias for a function to create a new empty ExponentialHistogramDataPoint. +// Deprecated: [v0.49.0] Use pmetric.ExponentialHistogramDataPoint instead. +var NewExponentialHistogramDataPoint = pmetric.NewExponentialHistogramDataPoint + +// Buckets is an alias for pmetric.Buckets struct. +// Deprecated: [v0.49.0] Use pmetric.Buckets instead. +type Buckets = pmetric.Buckets + +// NewBuckets is an alias for a function to create a new empty Buckets. +// Deprecated: [v0.49.0] Use pmetric.Buckets instead. +var NewBuckets = pmetric.NewBuckets + +// SummaryDataPointSlice is an alias for pmetric.SummaryDataPointSlice struct. +// Deprecated: [v0.49.0] Use pmetric.SummaryDataPointSlice instead. +type SummaryDataPointSlice = pmetric.SummaryDataPointSlice + +// NewSummaryDataPointSlice is an alias for a function to create SummaryDataPointSlice. +// Deprecated: [v0.49.0] Use pmetric.NewSummaryDataPointSlice instead. +var NewSummaryDataPointSlice = pmetric.NewSummaryDataPointSlice + +// SummaryDataPoint is an alias for pmetric.SummaryDataPoint struct. +// Deprecated: [v0.49.0] Use pmetric.SummaryDataPoint instead. +type SummaryDataPoint = pmetric.SummaryDataPoint + +// NewSummaryDataPoint is an alias for a function to create a new empty SummaryDataPoint. +// Deprecated: [v0.49.0] Use pmetric.SummaryDataPoint instead. +var NewSummaryDataPoint = pmetric.NewSummaryDataPoint + +// ValueAtQuantileSlice is an alias for pmetric.ValueAtQuantileSlice struct. +// Deprecated: [v0.49.0] Use pmetric.ValueAtQuantileSlice instead. +type ValueAtQuantileSlice = pmetric.ValueAtQuantileSlice + +// NewValueAtQuantileSlice is an alias for a function to create ValueAtQuantileSlice. +// Deprecated: [v0.49.0] Use pmetric.NewValueAtQuantileSlice instead. +var NewValueAtQuantileSlice = pmetric.NewValueAtQuantileSlice + +// ValueAtQuantile is an alias for pmetric.ValueAtQuantile struct. +// Deprecated: [v0.49.0] Use pmetric.ValueAtQuantile instead. +type ValueAtQuantile = pmetric.ValueAtQuantile + +// NewValueAtQuantile is an alias for a function to create a new empty ValueAtQuantile. +// Deprecated: [v0.49.0] Use pmetric.ValueAtQuantile instead. +var NewValueAtQuantile = pmetric.NewValueAtQuantile + +// ExemplarSlice is an alias for pmetric.ExemplarSlice struct. +// Deprecated: [v0.49.0] Use pmetric.ExemplarSlice instead. +type ExemplarSlice = pmetric.ExemplarSlice + +// NewExemplarSlice is an alias for a function to create ExemplarSlice. +// Deprecated: [v0.49.0] Use pmetric.NewExemplarSlice instead. +var NewExemplarSlice = pmetric.NewExemplarSlice + +// Exemplar is an alias for pmetric.Exemplar struct. +// Deprecated: [v0.49.0] Use pmetric.Exemplar instead. +type Exemplar = pmetric.Exemplar + +// NewExemplar is an alias for a function to create a new empty Exemplar. +// Deprecated: [v0.49.0] Use pmetric.Exemplar instead. +var NewExemplar = pmetric.NewExemplar diff --git a/model/pdata/generated_ptrace_alias.go b/model/pdata/generated_ptrace_alias.go new file mode 100644 index 00000000000..e6242e9b649 --- /dev/null +++ b/model/pdata/generated_ptrace_alias.go @@ -0,0 +1,108 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package pdata + +import "go.opentelemetry.io/collector/pdata/ptrace" + +// ResourceSpansSlice is an alias for ptrace.ResourceSpansSlice struct. +// Deprecated: [v0.49.0] Use ptrace.ResourceSpansSlice instead. +type ResourceSpansSlice = ptrace.ResourceSpansSlice + +// NewResourceSpansSlice is an alias for a function to create ResourceSpansSlice. +// Deprecated: [v0.49.0] Use ptrace.NewResourceSpansSlice instead. +var NewResourceSpansSlice = ptrace.NewResourceSpansSlice + +// ResourceSpans is an alias for ptrace.ResourceSpans struct. +// Deprecated: [v0.49.0] Use ptrace.ResourceSpans instead. +type ResourceSpans = ptrace.ResourceSpans + +// NewResourceSpans is an alias for a function to create a new empty ResourceSpans. +// Deprecated: [v0.49.0] Use ptrace.ResourceSpans instead. +var NewResourceSpans = ptrace.NewResourceSpans + +// ScopeSpansSlice is an alias for ptrace.ScopeSpansSlice struct. +// Deprecated: [v0.49.0] Use ptrace.ScopeSpansSlice instead. +type ScopeSpansSlice = ptrace.ScopeSpansSlice + +// NewScopeSpansSlice is an alias for a function to create ScopeSpansSlice. +// Deprecated: [v0.49.0] Use ptrace.NewScopeSpansSlice instead. +var NewScopeSpansSlice = ptrace.NewScopeSpansSlice + +// ScopeSpans is an alias for ptrace.ScopeSpans struct. +// Deprecated: [v0.49.0] Use ptrace.ScopeSpans instead. +type ScopeSpans = ptrace.ScopeSpans + +// NewScopeSpans is an alias for a function to create a new empty ScopeSpans. +// Deprecated: [v0.49.0] Use ptrace.ScopeSpans instead. +var NewScopeSpans = ptrace.NewScopeSpans + +// SpanSlice is an alias for ptrace.SpanSlice struct. +// Deprecated: [v0.49.0] Use ptrace.SpanSlice instead. +type SpanSlice = ptrace.SpanSlice + +// NewSpanSlice is an alias for a function to create SpanSlice. +// Deprecated: [v0.49.0] Use ptrace.NewSpanSlice instead. +var NewSpanSlice = ptrace.NewSpanSlice + +// Span is an alias for ptrace.Span struct. +// Deprecated: [v0.49.0] Use ptrace.Span instead. +type Span = ptrace.Span + +// NewSpan is an alias for a function to create a new empty Span. +// Deprecated: [v0.49.0] Use ptrace.Span instead. +var NewSpan = ptrace.NewSpan + +// SpanEventSlice is an alias for ptrace.SpanEventSlice struct. +// Deprecated: [v0.49.0] Use ptrace.SpanEventSlice instead. +type SpanEventSlice = ptrace.SpanEventSlice + +// NewSpanEventSlice is an alias for a function to create SpanEventSlice. +// Deprecated: [v0.49.0] Use ptrace.NewSpanEventSlice instead. +var NewSpanEventSlice = ptrace.NewSpanEventSlice + +// SpanEvent is an alias for ptrace.SpanEvent struct. +// Deprecated: [v0.49.0] Use ptrace.SpanEvent instead. +type SpanEvent = ptrace.SpanEvent + +// NewSpanEvent is an alias for a function to create a new empty SpanEvent. +// Deprecated: [v0.49.0] Use ptrace.SpanEvent instead. +var NewSpanEvent = ptrace.NewSpanEvent + +// SpanLinkSlice is an alias for ptrace.SpanLinkSlice struct. +// Deprecated: [v0.49.0] Use ptrace.SpanLinkSlice instead. +type SpanLinkSlice = ptrace.SpanLinkSlice + +// NewSpanLinkSlice is an alias for a function to create SpanLinkSlice. +// Deprecated: [v0.49.0] Use ptrace.NewSpanLinkSlice instead. +var NewSpanLinkSlice = ptrace.NewSpanLinkSlice + +// SpanLink is an alias for ptrace.SpanLink struct. +// Deprecated: [v0.49.0] Use ptrace.SpanLink instead. +type SpanLink = ptrace.SpanLink + +// NewSpanLink is an alias for a function to create a new empty SpanLink. +// Deprecated: [v0.49.0] Use ptrace.SpanLink instead. +var NewSpanLink = ptrace.NewSpanLink + +// SpanStatus is an alias for ptrace.SpanStatus struct. +// Deprecated: [v0.49.0] Use ptrace.SpanStatus instead. +type SpanStatus = ptrace.SpanStatus + +// NewSpanStatus is an alias for a function to create a new empty SpanStatus. +// Deprecated: [v0.49.0] Use ptrace.SpanStatus instead. +var NewSpanStatus = ptrace.NewSpanStatus diff --git a/model/pdata/generated_resource_alias.go b/model/pdata/generated_resource_alias.go index e2181f08cec..9cf9959d7a4 100644 --- a/model/pdata/generated_resource_alias.go +++ b/model/pdata/generated_resource_alias.go @@ -17,10 +17,12 @@ package pdata -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/pcommon" -// Resource is an alias for internal.Resource struct. -type Resource = internal.Resource +// Resource is an alias for pcommon.Resource struct. +// Deprecated: [v0.49.0] Use pcommon.Resource instead. +type Resource = pcommon.Resource // NewResource is an alias for a function to create a new empty Resource. -var NewResource = internal.NewResource +// Deprecated: [v0.49.0] Use pcommon.Resource instead. +var NewResource = pcommon.NewResource diff --git a/model/pdata/logs_alias.go b/model/pdata/logs_alias.go index 86bb070609f..9007003ba1e 100644 --- a/model/pdata/logs_alias.go +++ b/model/pdata/logs_alias.go @@ -16,62 +16,118 @@ package pdata // import "go.opentelemetry.io/collector/model/pdata" // This file contains aliases for log data structures. -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/plog" -// LogsMarshaler is an alias for internal.LogsMarshaler interface. -type LogsMarshaler = internal.LogsMarshaler +// LogsMarshaler is an alias for plog.Marshaler interface. +// Deprecated: [v0.49.0] Use plog.Marshaler instead. +type LogsMarshaler = plog.Marshaler -// LogsUnmarshaler is an alias for internal.LogsUnmarshaler interface. -type LogsUnmarshaler = internal.LogsUnmarshaler +// LogsUnmarshaler is an alias for plog.Unmarshaler interface. +// Deprecated: [v0.49.0] Use plog.Unmarshaler instead. +type LogsUnmarshaler = plog.Unmarshaler -// LogsSizer is an alias for internal.LogsSizer interface. -type LogsSizer = internal.LogsSizer +// LogsSizer is an alias for plog.Sizer interface. +// Deprecated: [v0.49.0] Use plog.Sizer instead. +type LogsSizer = plog.Sizer -// Logs is an alias for internal.Logs struct. -type Logs = internal.Logs +// Logs is an alias for plog.Logs struct. +// Deprecated: [v0.49.0] Use plog.Logs instead. +type Logs = plog.Logs // NewLogs is an alias for a function to create new Logs. -var NewLogs = internal.NewLogs +// Deprecated: [v0.49.0] Use plog.NewLogs instead. +var NewLogs = plog.NewLogs -// SeverityNumber is an alias for internal.SeverityNumber type. -type SeverityNumber = internal.SeverityNumber +// SeverityNumber is an alias for plog.SeverityNumber type. +// Deprecated: [v0.49.0] Use plog.SeverityNumber instead. +type SeverityNumber = plog.SeverityNumber const ( - SeverityNumberUNDEFINED = internal.SeverityNumberUNDEFINED - SeverityNumberTRACE = internal.SeverityNumberTRACE - SeverityNumberTRACE2 = internal.SeverityNumberTRACE2 - SeverityNumberTRACE3 = internal.SeverityNumberTRACE3 - SeverityNumberTRACE4 = internal.SeverityNumberTRACE4 - SeverityNumberDEBUG = internal.SeverityNumberDEBUG - SeverityNumberDEBUG2 = internal.SeverityNumberDEBUG2 - SeverityNumberDEBUG3 = internal.SeverityNumberDEBUG3 - SeverityNumberDEBUG4 = internal.SeverityNumberDEBUG4 - SeverityNumberINFO = internal.SeverityNumberINFO - SeverityNumberINFO2 = internal.SeverityNumberINFO2 - SeverityNumberINFO3 = internal.SeverityNumberINFO3 - SeverityNumberINFO4 = internal.SeverityNumberINFO4 - SeverityNumberWARN = internal.SeverityNumberWARN - SeverityNumberWARN2 = internal.SeverityNumberWARN2 - SeverityNumberWARN3 = internal.SeverityNumberWARN3 - SeverityNumberWARN4 = internal.SeverityNumberWARN4 - SeverityNumberERROR = internal.SeverityNumberERROR - SeverityNumberERROR2 = internal.SeverityNumberERROR2 - SeverityNumberERROR3 = internal.SeverityNumberERROR3 - SeverityNumberERROR4 = internal.SeverityNumberERROR4 - SeverityNumberFATAL = internal.SeverityNumberFATAL - SeverityNumberFATAL2 = internal.SeverityNumberFATAL2 - SeverityNumberFATAL3 = internal.SeverityNumberFATAL3 - SeverityNumberFATAL4 = internal.SeverityNumberFATAL4 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberUNDEFINED instead. + SeverityNumberUNDEFINED = plog.SeverityNumberUNDEFINED + + // Deprecated: [v0.49.0] Use plog.SeverityNumberTRACE instead. + SeverityNumberTRACE = plog.SeverityNumberTRACE + + // Deprecated: [v0.49.0] Use plog.SeverityNumberTRACE2 instead. + SeverityNumberTRACE2 = plog.SeverityNumberTRACE2 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberTRACE3 instead. + SeverityNumberTRACE3 = plog.SeverityNumberTRACE3 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberTRACE4 instead. + SeverityNumberTRACE4 = plog.SeverityNumberTRACE4 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberDEBUG instead. + SeverityNumberDEBUG = plog.SeverityNumberDEBUG + + // Deprecated: [v0.49.0] Use plog.SeverityNumberDEBUG2 instead. + SeverityNumberDEBUG2 = plog.SeverityNumberDEBUG2 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberDEBUG3 instead. + SeverityNumberDEBUG3 = plog.SeverityNumberDEBUG3 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberDEBUG4 instead. + SeverityNumberDEBUG4 = plog.SeverityNumberDEBUG4 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberINFO instead. + SeverityNumberINFO = plog.SeverityNumberINFO + + // Deprecated: [v0.49.0] Use plog.SeverityNumberINFO2 instead. + SeverityNumberINFO2 = plog.SeverityNumberINFO2 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberINFO3 instead. + SeverityNumberINFO3 = plog.SeverityNumberINFO3 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberINFO4 instead. + SeverityNumberINFO4 = plog.SeverityNumberINFO4 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberWARN instead. + SeverityNumberWARN = plog.SeverityNumberWARN + + // Deprecated: [v0.49.0] Use plog.SeverityNumberWARN2 instead. + SeverityNumberWARN2 = plog.SeverityNumberWARN2 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberWARN3 instead. + SeverityNumberWARN3 = plog.SeverityNumberWARN3 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberWARN4 instead. + SeverityNumberWARN4 = plog.SeverityNumberWARN4 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberERROR instead. + SeverityNumberERROR = plog.SeverityNumberERROR + + // Deprecated: [v0.49.0] Use plog.SeverityNumberERROR2 instead. + SeverityNumberERROR2 = plog.SeverityNumberERROR2 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberERROR3 instead. + SeverityNumberERROR3 = plog.SeverityNumberERROR3 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberERROR4 instead. + SeverityNumberERROR4 = plog.SeverityNumberERROR4 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberFATAL instead. + SeverityNumberFATAL = plog.SeverityNumberFATAL + + // Deprecated: [v0.49.0] Use plog.SeverityNumberFATAL2 instead. + SeverityNumberFATAL2 = plog.SeverityNumberFATAL2 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberFATAL3 instead. + SeverityNumberFATAL3 = plog.SeverityNumberFATAL3 + + // Deprecated: [v0.49.0] Use plog.SeverityNumberFATAL4 instead. + SeverityNumberFATAL4 = plog.SeverityNumberFATAL4 ) // Deprecated: [v0.48.0] Use ScopeLogsSlice instead. -type InstrumentationLibraryLogsSlice = internal.ScopeLogsSlice +type InstrumentationLibraryLogsSlice = plog.ScopeLogsSlice // Deprecated: [v0.48.0] Use NewScopeLogsSlice instead. -var NewInstrumentationLibraryLogsSlice = internal.NewScopeLogsSlice +var NewInstrumentationLibraryLogsSlice = plog.NewScopeLogsSlice // Deprecated: [v0.48.0] Use ScopeLogs instead. -type InstrumentationLibraryLogs = internal.ScopeLogs +type InstrumentationLibraryLogs = plog.ScopeLogs // Deprecated: [v0.48.0] Use NewScopeLogs instead. -var NewInstrumentationLibraryLogs = internal.NewScopeLogs +var NewInstrumentationLibraryLogs = plog.NewScopeLogs diff --git a/model/pdata/metrics_alias.go b/model/pdata/metrics_alias.go index 10a0c9abb0c..fb4a643a6bb 100644 --- a/model/pdata/metrics_alias.go +++ b/model/pdata/metrics_alias.go @@ -16,78 +16,115 @@ package pdata // import "go.opentelemetry.io/collector/model/pdata" // This file contains aliases for metric data structures. -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/pmetric" -// MetricsMarshaler is an alias for internal.MetricsMarshaler interface. -type MetricsMarshaler = internal.MetricsMarshaler +// MetricsMarshaler is an alias for pmetric.Marshaler interface. +// Deprecated: [v0.49.0] Use pmetric.Marshaler instead. +type MetricsMarshaler = pmetric.Marshaler -// MetricsUnmarshaler is an alias for internal.MetricsUnmarshaler interface. -type MetricsUnmarshaler = internal.MetricsUnmarshaler +// MetricsUnmarshaler is an alias for pmetric.Unmarshaler interface. +// Deprecated: [v0.49.0] Use pmetric.Unmarshaler instead. +type MetricsUnmarshaler = pmetric.Unmarshaler -// MetricsSizer is an alias for internal.MetricsSizer interface. -type MetricsSizer = internal.MetricsSizer +// MetricsSizer is an alias for pmetric.Sizer interface. +// Deprecated: [v0.49.0] Use pmetric.Sizer instead. +type MetricsSizer = pmetric.Sizer -// Metrics is an alias for internal.Metrics structure. -type Metrics = internal.Metrics +// Metrics is an alias for pmetric.Metrics structure. +// Deprecated: [v0.49.0] Use pmetric.Metrics instead. +type Metrics = pmetric.Metrics // NewMetrics is an alias for a function to create new Metrics. -var NewMetrics = internal.NewMetrics +// Deprecated: [v0.49.0] Use pmetric.NewMetrics instead. +var NewMetrics = pmetric.NewMetrics -// MetricDataType is an alias for internal.MetricDataType type. -type MetricDataType = internal.MetricDataType +// MetricDataType is an alias for pmetric.MetricDataType type. +// Deprecated: [v0.49.0] Use pmetric.MetricDataType instead. +type MetricDataType = pmetric.MetricDataType const ( - MetricDataTypeNone = internal.MetricDataTypeNone - MetricDataTypeGauge = internal.MetricDataTypeGauge - MetricDataTypeSum = internal.MetricDataTypeSum - MetricDataTypeHistogram = internal.MetricDataTypeHistogram - MetricDataTypeExponentialHistogram = internal.MetricDataTypeExponentialHistogram - MetricDataTypeSummary = internal.MetricDataTypeSummary + + // Deprecated: [v0.49.0] Use pmetric.MetricDataTypeNone instead. + MetricDataTypeNone = pmetric.MetricDataTypeNone + + // Deprecated: [v0.49.0] Use pmetric.MetricDataTypeGauge instead. + MetricDataTypeGauge = pmetric.MetricDataTypeGauge + + // Deprecated: [v0.49.0] Use pmetric.MetricDataTypeSum instead. + MetricDataTypeSum = pmetric.MetricDataTypeSum + + // Deprecated: [v0.49.0] Use pmetric.MetricDataTypeHistogram instead. + MetricDataTypeHistogram = pmetric.MetricDataTypeHistogram + + // Deprecated: [v0.49.0] Use pmetric.MetricDataTypeExponentialHistogram instead. + MetricDataTypeExponentialHistogram = pmetric.MetricDataTypeExponentialHistogram + + // Deprecated: [v0.49.0] Use pmetric.MetricDataTypeSummary instead. + MetricDataTypeSummary = pmetric.MetricDataTypeSummary ) -// MetricAggregationTemporality is an alias for internal.MetricAggregationTemporality type. -type MetricAggregationTemporality = internal.MetricAggregationTemporality +// MetricAggregationTemporality is an alias for pmetric.MetricAggregationTemporality type. +// Deprecated: [v0.49.0] Use pmetric.MetricAggregationTemporality instead. +type MetricAggregationTemporality = pmetric.MetricAggregationTemporality const ( - MetricAggregationTemporalityUnspecified = internal.MetricAggregationTemporalityUnspecified - MetricAggregationTemporalityDelta = internal.MetricAggregationTemporalityDelta - MetricAggregationTemporalityCumulative = internal.MetricAggregationTemporalityCumulative + + // Deprecated: [v0.49.0] Use pmetric.MetricAggregationTemporalityUnspecified instead. + MetricAggregationTemporalityUnspecified = pmetric.MetricAggregationTemporalityUnspecified + + // Deprecated: [v0.49.0] Use pmetric.MetricAggregationTemporalityDelta instead. + MetricAggregationTemporalityDelta = pmetric.MetricAggregationTemporalityDelta + + // Deprecated: [v0.49.0] Use pmetric.MetricAggregationTemporalityCumulative instead. + MetricAggregationTemporalityCumulative = pmetric.MetricAggregationTemporalityCumulative ) -// MetricDataPointFlags is an alias for internal.MetricDataPointFlags type. -type MetricDataPointFlags = internal.MetricDataPointFlags +// MetricDataPointFlags is an alias for pmetric.MetricDataPointFlags type. +// Deprecated: [v0.49.0] Use pmetric.MetricDataPointFlags instead. +type MetricDataPointFlags = pmetric.MetricDataPointFlags const ( - MetricDataPointFlagsNone = internal.MetricDataPointFlagsNone + // Deprecated: [v0.49.0] Use pmetric.MetricDataPointFlagsNone instead. + MetricDataPointFlagsNone = pmetric.MetricDataPointFlagsNone ) // NewMetricDataPointFlags is an alias for a function to create new MetricDataPointFlags. -var NewMetricDataPointFlags = internal.NewMetricDataPointFlags +// Deprecated: [v0.49.0] Use pmetric.NewMetricDataPointFlags instead. +var NewMetricDataPointFlags = pmetric.NewMetricDataPointFlags -// MetricDataPointFlag is an alias for internal.MetricDataPointFlag type. -type MetricDataPointFlag = internal.MetricDataPointFlag +// MetricDataPointFlag is an alias for pmetric.MetricDataPointFlag type. +// Deprecated: [v0.49.0] Use pmetric.MetricDataPointFlag instead. +type MetricDataPointFlag = pmetric.MetricDataPointFlag const ( - MetricDataPointFlagNoRecordedValue = internal.MetricDataPointFlagNoRecordedValue + // Deprecated: [v0.49.0] Use pmetric.MetricDataPointFlagNoRecordedValue instead. + MetricDataPointFlagNoRecordedValue = pmetric.MetricDataPointFlagNoRecordedValue ) -// MetricValueType is an alias for internal.MetricValueType type. -type MetricValueType = internal.MetricValueType +// MetricValueType is an alias for pmetric.MetricValueType type. +// Deprecated: [v0.49.0] Use pmetric.MetricValueType instead. +type MetricValueType = pmetric.MetricValueType const ( - MetricValueTypeNone = internal.MetricValueTypeNone - MetricValueTypeInt = internal.MetricValueTypeInt - MetricValueTypeDouble = internal.MetricValueTypeDouble + + // Deprecated: [v0.49.0] Use pmetric.MetricValueTypeNone instead. + MetricValueTypeNone = pmetric.MetricValueTypeNone + + // Deprecated: [v0.49.0] Use pmetric.MetricValueTypeInt instead. + MetricValueTypeInt = pmetric.MetricValueTypeInt + + // Deprecated: [v0.49.0] Use pmetric.MetricValueTypeDouble instead. + MetricValueTypeDouble = pmetric.MetricValueTypeDouble ) // Deprecated: [v0.48.0] Use ScopeMetricsSlice instead. -type InstrumentationLibraryMetricsSlice = internal.ScopeMetricsSlice +type InstrumentationLibraryMetricsSlice = pmetric.ScopeMetricsSlice // Deprecated: [v0.48.0] Use NewScopeMetricsSlice instead. -var NewInstrumentationLibraryMetricsSlice = internal.NewScopeMetricsSlice +var NewInstrumentationLibraryMetricsSlice = pmetric.NewScopeMetricsSlice // Deprecated: [v0.48.0] Use ScopeMetrics instead. -type InstrumentationLibraryMetrics = internal.ScopeMetrics +type InstrumentationLibraryMetrics = pmetric.ScopeMetrics // Deprecated: [v0.48.0] Use NewScopeMetrics instead. -var NewInstrumentationLibraryMetrics = internal.NewScopeMetrics +var NewInstrumentationLibraryMetrics = pmetric.NewScopeMetrics diff --git a/model/pdata/spanid_alias.go b/model/pdata/spanid_alias.go index d98d8bb179e..4e6b6bbe1ac 100644 --- a/model/pdata/spanid_alias.go +++ b/model/pdata/spanid_alias.go @@ -14,13 +14,16 @@ package pdata // import "go.opentelemetry.io/collector/model/pdata" -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/pcommon" -// SpanID is an alias for internal.SpanID struct. -type SpanID = internal.SpanID +// SpanID is an alias for pcommon.SpanID struct. +// Deprecated: [v0.49.0] Use pcommon.SpanID instead. +type SpanID = pcommon.SpanID -// InvalidSpanID is an alias for internal.InvalidSpanID function. -var InvalidSpanID = internal.InvalidSpanID +// InvalidSpanID is an alias for pcommon.InvalidSpanID function. +// Deprecated: [v0.49.0] Use pcommon.InvalidSpanID instead. +var InvalidSpanID = pcommon.InvalidSpanID // NewSpanID is an alias for a function to create new SpanID. -var NewSpanID = internal.NewSpanID +// Deprecated: [v0.49.0] Use pcommon.NewSpanID instead. +var NewSpanID = pcommon.NewSpanID diff --git a/model/pdata/timestamp_alias.go b/model/pdata/timestamp_alias.go index 6ad8dd4a565..f32c0f17b7a 100644 --- a/model/pdata/timestamp_alias.go +++ b/model/pdata/timestamp_alias.go @@ -14,10 +14,12 @@ package pdata // import "go.opentelemetry.io/collector/model/pdata" -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/pcommon" -// Timestamp is a an alias for internal.Timestamp. -type Timestamp = internal.Timestamp +// Timestamp is a an alias for pcommon.Timestamp. +// Deprecated: [v0.49.0] Use pcommon.Timestamp instead. +type Timestamp = pcommon.Timestamp -// NewTimestampFromTime is an alias for internal.NewTimestampFromTime function. -var NewTimestampFromTime = internal.NewTimestampFromTime +// NewTimestampFromTime is an alias for pcommon.NewTimestampFromTime function. +// Deprecated: [v0.49.0] Use pcommon.NewTimestampFromTime instead. +var NewTimestampFromTime = pcommon.NewTimestampFromTime diff --git a/model/pdata/traceid_alias.go b/model/pdata/traceid_alias.go index 7848fb71656..3338a563b24 100644 --- a/model/pdata/traceid_alias.go +++ b/model/pdata/traceid_alias.go @@ -14,13 +14,16 @@ package pdata // import "go.opentelemetry.io/collector/model/pdata" -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/pcommon" -// TraceID is an alias for internal.TraceID struct. -type TraceID = internal.TraceID +// TraceID is an alias for pcommon.TraceID struct. +// Deprecated: [v0.49.0] Use pcommon.TraceID instead. +type TraceID = pcommon.TraceID -// InvalidTraceID is an alias for internal.InvalidTraceID function. -var InvalidTraceID = internal.InvalidTraceID +// InvalidTraceID is an alias for pcommon.InvalidTraceID function. +// Deprecated: [v0.49.0] Use pcommon.InvalidTraceID instead. +var InvalidTraceID = pcommon.InvalidTraceID // NewTraceID is an alias for a function to create new TraceID. -var NewTraceID = internal.NewTraceID +// Deprecated: [v0.49.0] Use pcommon.NewTraceID instead. +var NewTraceID = pcommon.NewTraceID diff --git a/model/pdata/traces_alias.go b/model/pdata/traces_alias.go index a617db58cd5..4d5d08488d3 100644 --- a/model/pdata/traces_alias.go +++ b/model/pdata/traces_alias.go @@ -16,59 +16,85 @@ package pdata // import "go.opentelemetry.io/collector/model/pdata" // This file contains aliases for trace data structures. -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/ptrace" -// TracesMarshaler is an alias for internal.TracesMarshaler interface. -type TracesMarshaler = internal.TracesMarshaler +// TracesMarshaler is an alias for ptrace.Marshaler interface. +// Deprecated: [v0.49.0] Use ptrace.Marshaler instead. +type TracesMarshaler = ptrace.Marshaler -// TracesUnmarshaler is an alias for internal.TracesUnmarshaler interface. -type TracesUnmarshaler = internal.TracesUnmarshaler +// TracesUnmarshaler is an alias for ptrace.Unmarshaler interface. +// Deprecated: [v0.49.0] Use ptrace.Unmarshaler instead. +type TracesUnmarshaler = ptrace.Unmarshaler -// TracesSizer is an alias for internal.TracesSizer interface. -type TracesSizer = internal.TracesSizer +// TracesSizer is an alias for ptrace.Sizer interface. +// Deprecated: [v0.49.0] Use ptrace.Sizer instead. +type TracesSizer = ptrace.Sizer -// Traces is an alias for internal.Traces struct. -type Traces = internal.Traces +// Traces is an alias for ptrace.Traces struct. +// Deprecated: [v0.49.0] Use ptrace.Traces instead. +type Traces = ptrace.Traces // NewTraces is an alias for a function to create new Traces. -var NewTraces = internal.NewTraces +// Deprecated: [v0.49.0] Use ptrace.NewTraces instead. +var NewTraces = ptrace.NewTraces -// TraceState is an alias for internal.TraceState type. -type TraceState = internal.TraceState +// TraceState is an alias for ptrace.TraceState type. +// Deprecated: [v0.49.0] Use ptrace.TraceState instead. +type TraceState = ptrace.TraceState const ( - TraceStateEmpty = internal.TraceStateEmpty + TraceStateEmpty = ptrace.TraceStateEmpty ) -// SpanKind is an alias for internal.SpanKind type. -type SpanKind = internal.SpanKind +// SpanKind is an alias for ptrace.SpanKind type. +// Deprecated: [v0.49.0] Use ptrace.SpanKind instead. +type SpanKind = ptrace.SpanKind const ( - SpanKindUnspecified = internal.SpanKindUnspecified - SpanKindInternal = internal.SpanKindInternal - SpanKindServer = internal.SpanKindServer - SpanKindClient = internal.SpanKindClient - SpanKindProducer = internal.SpanKindProducer - SpanKindConsumer = internal.SpanKindConsumer + + // Deprecated: [v0.49.0] Use ptrace.SpanKindUnspecified instead. + SpanKindUnspecified = ptrace.SpanKindUnspecified + + // Deprecated: [v0.49.0] Use ptrace.SpanKindInternal instead. + SpanKindInternal = ptrace.SpanKindInternal + + // Deprecated: [v0.49.0] Use ptrace.SpanKindServer instead. + SpanKindServer = ptrace.SpanKindServer + + // Deprecated: [v0.49.0] Use ptrace.SpanKindClient instead. + SpanKindClient = ptrace.SpanKindClient + + // Deprecated: [v0.49.0] Use ptrace.SpanKindProducer instead. + SpanKindProducer = ptrace.SpanKindProducer + + // Deprecated: [v0.49.0] Use ptrace.SpanKindConsumer instead. + SpanKindConsumer = ptrace.SpanKindConsumer ) -// StatusCode is an alias for internal.StatusCode type. -type StatusCode = internal.StatusCode +// StatusCode is an alias for ptrace.StatusCode type. +// Deprecated: [v0.49.0] Use ptrace.StatusCode instead. +type StatusCode = ptrace.StatusCode const ( - StatusCodeUnset = internal.StatusCodeUnset - StatusCodeOk = internal.StatusCodeOk - StatusCodeError = internal.StatusCodeError + + // Deprecated: [v0.49.0] Use ptrace.StatusCodeUnset instead. + StatusCodeUnset = ptrace.StatusCodeUnset + + // Deprecated: [v0.49.0] Use ptrace.StatusCodeOk instead. + StatusCodeOk = ptrace.StatusCodeOk + + // Deprecated: [v0.49.0] Use ptrace.StatusCodeError instead. + StatusCodeError = ptrace.StatusCodeError ) // Deprecated: [v0.48.0] Use ScopeSpansSlice instead. -type InstrumentationLibrarySpansSlice = internal.ScopeSpansSlice +type InstrumentationLibrarySpansSlice = ptrace.ScopeSpansSlice // Deprecated: [v0.48.0] Use NewScopeSpansSlice instead. -var NewInstrumentationLibrarySpansSlice = internal.NewScopeSpansSlice +var NewInstrumentationLibrarySpansSlice = ptrace.NewScopeSpansSlice // Deprecated: [v0.48.0] Use ScopeSpans instead. -type InstrumentationLibrarySpans = internal.ScopeSpans +type InstrumentationLibrarySpans = ptrace.ScopeSpans // Deprecated: [v0.48.0] Use NewScopeSpans instead. -var NewInstrumentationLibrarySpans = internal.NewScopeSpans +var NewInstrumentationLibrarySpans = ptrace.NewScopeSpans diff --git a/pdata/Makefile b/pdata/Makefile new file mode 100644 index 00000000000..39734bfaebb --- /dev/null +++ b/pdata/Makefile @@ -0,0 +1 @@ +include ../Makefile.Common diff --git a/pdata/go.mod b/pdata/go.mod new file mode 100644 index 00000000000..ec7bc9de016 --- /dev/null +++ b/pdata/go.mod @@ -0,0 +1,21 @@ +module go.opentelemetry.io/collector/pdata + +go 1.17 + +require ( + github.com/gogo/protobuf v1.3.2 + github.com/stretchr/testify v1.7.1 + google.golang.org/grpc v1.45.0 + google.golang.org/protobuf v1.28.0 +) + +require ( + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect + golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect + golang.org/x/text v0.3.3 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect +) diff --git a/pdata/go.sum b/pdata/go.sum new file mode 100644 index 00000000000..f86009915ff --- /dev/null +++ b/pdata/go.sum @@ -0,0 +1,149 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/model/internal/.gitignore b/pdata/internal/.gitignore similarity index 100% rename from model/internal/.gitignore rename to pdata/internal/.gitignore diff --git a/model/internal/cmd/pdatagen/internal/base_fields.go b/pdata/internal/cmd/pdatagen/internal/base_fields.go similarity index 99% rename from model/internal/cmd/pdatagen/internal/base_fields.go rename to pdata/internal/cmd/pdatagen/internal/base_fields.go index 6ccac47f881..8a0c6e80c80 100644 --- a/model/internal/cmd/pdatagen/internal/base_fields.go +++ b/pdata/internal/cmd/pdatagen/internal/base_fields.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal/cmd/pdatagen/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" import ( "os" diff --git a/model/internal/cmd/pdatagen/internal/base_slices.go b/pdata/internal/cmd/pdatagen/internal/base_slices.go similarity index 92% rename from model/internal/cmd/pdatagen/internal/base_slices.go rename to pdata/internal/cmd/pdatagen/internal/base_slices.go index 392767193d8..d1656da03fd 100644 --- a/model/internal/cmd/pdatagen/internal/base_slices.go +++ b/pdata/internal/cmd/pdatagen/internal/base_slices.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal/cmd/pdatagen/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" import ( "os" @@ -111,11 +111,11 @@ func fillTest${structName}(tv ${structName}) { } }` -const commonSliceAliasTemplate = `// ${structName} is an alias for internal.${structName} struct. -type ${structName} = internal.${structName} +const commonSliceAliasTemplate = `// ${structName} is an alias for ${refPackage}.${structName} struct. +${extraStructComment}type ${structName} = ${refPackage}.${structName} // New${structName} is an alias for a function to create ${structName}. -var New${structName} = internal.New${structName}` +${extraNewComment}var New${structName} = ${refPackage}.New${structName}` const slicePtrTemplate = `// ${structName} logically represents a slice of ${elementName}. // @@ -477,11 +477,26 @@ func (ss *sliceOfPtrs) templateFields() func(name string) string { } } -func (ss *sliceOfPtrs) generateAlias(sb *strings.Builder) { +func (ss *sliceOfPtrs) generateAlias(sb *strings.Builder, deprecatedInFavor string) { sb.WriteString(os.Expand(commonSliceAliasTemplate, func(name string) string { switch name { case "structName": return ss.structName + case "refPackage": + if deprecatedInFavor == "" { + return "internal" + } + return deprecatedInFavor + case "extraStructComment": + if deprecatedInFavor != "" { + return "// Deprecated: [v0.49.0] Use " + deprecatedInFavor + "." + ss.structName + " instead.\n" + } + return "" + case "extraNewComment": + if deprecatedInFavor != "" { + return "// Deprecated: [v0.49.0] Use " + deprecatedInFavor + ".New" + ss.structName + " instead.\n" + } + return "" default: panic(name) } @@ -530,11 +545,26 @@ func (ss *sliceOfValues) templateFields() func(name string) string { } } -func (ss *sliceOfValues) generateAlias(sb *strings.Builder) { +func (ss *sliceOfValues) generateAlias(sb *strings.Builder, deprecatedInFavor string) { sb.WriteString(os.Expand(commonSliceAliasTemplate, func(name string) string { switch name { case "structName": return ss.structName + case "refPackage": + if deprecatedInFavor == "" { + return "internal" + } + return deprecatedInFavor + case "extraStructComment": + if deprecatedInFavor != "" { + return "// Deprecated: [v0.49.0] Use " + deprecatedInFavor + "." + ss.structName + " instead.\n" + } + return "" + case "extraNewComment": + if deprecatedInFavor != "" { + return "// Deprecated: [v0.49.0] Use " + deprecatedInFavor + ".New" + ss.structName + " instead.\n" + } + return "" default: panic(name) } diff --git a/model/internal/cmd/pdatagen/internal/base_structs.go b/pdata/internal/cmd/pdatagen/internal/base_structs.go similarity index 86% rename from model/internal/cmd/pdatagen/internal/base_structs.go rename to pdata/internal/cmd/pdatagen/internal/base_structs.go index 20dfd4dc5b4..9ec676e3e11 100644 --- a/model/internal/cmd/pdatagen/internal/base_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/base_structs.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal/cmd/pdatagen/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" import ( "os" @@ -78,11 +78,11 @@ const messageValueGenerateTestTemplate = `func generateTest${structName}() ${str const messageValueFillTestHeaderTemplate = `func fillTest${structName}(tv ${structName}) {` const messageValueFillTestFooterTemplate = `}` -const messageValueAliasTemplate = `// ${structName} is an alias for internal.${structName} struct. -type ${structName} = internal.${structName} +const messageValueAliasTemplate = `// ${structName} is an alias for ${refPackage}.${structName} struct. +${extraStructComment}type ${structName} = ${refPackage}.${structName} // New${structName} is an alias for a function to create a new empty ${structName}. -var New${structName} = internal.New${structName}` +${extraStructComment}var New${structName} = ${refPackage}.New${structName}` const newLine = "\n" @@ -97,7 +97,7 @@ type baseStruct interface { } type aliasGenerator interface { - generateAlias(sb *strings.Builder) + generateAlias(sb *strings.Builder, deprecatedInFavor string) } type messageValueStruct struct { @@ -196,11 +196,26 @@ func (ms *messageValueStruct) generateTestValueHelpers(sb *strings.Builder) { })) } -func (ms *messageValueStruct) generateAlias(sb *strings.Builder) { +func (ms *messageValueStruct) generateAlias(sb *strings.Builder, deprecatedInFavor string) { sb.WriteString(os.Expand(messageValueAliasTemplate, func(name string) string { switch name { case "structName": return ms.structName + case "refPackage": + if deprecatedInFavor == "" { + return "internal" + } + return deprecatedInFavor + case "extraStructComment": + if deprecatedInFavor != "" { + return "// Deprecated: [v0.49.0] Use " + deprecatedInFavor + "." + ms.structName + " instead.\n" + } + return "" + case "extraNewComment": + if deprecatedInFavor != "" { + return "// Deprecated: [v0.49.0] Use " + deprecatedInFavor + ".New" + ms.structName + " instead.\n" + } + return "" default: panic(name) } diff --git a/model/internal/cmd/pdatagen/internal/common_structs.go b/pdata/internal/cmd/pdatagen/internal/common_structs.go similarity index 94% rename from model/internal/cmd/pdatagen/internal/common_structs.go rename to pdata/internal/cmd/pdatagen/internal/common_structs.go index 5b9f85386e0..e9bda6754ac 100644 --- a/model/internal/cmd/pdatagen/internal/common_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/common_structs.go @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal/cmd/pdatagen/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" var commonFile = &File{ Name: "common", imports: []string{ - `otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1"`, + `otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1"`, }, testImports: []string{ `"testing"`, ``, `"github.com/stretchr/testify/assert"`, ``, - `otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1"`, + `otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1"`, }, structs: []baseStruct{ scope, diff --git a/model/internal/cmd/pdatagen/internal/files.go b/pdata/internal/cmd/pdatagen/internal/files.go similarity index 82% rename from model/internal/cmd/pdatagen/internal/files.go rename to pdata/internal/cmd/pdatagen/internal/files.go index 29e437fd31a..ea9343d84f6 100644 --- a/model/internal/cmd/pdatagen/internal/files.go +++ b/pdata/internal/cmd/pdatagen/internal/files.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal/cmd/pdatagen/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" import "strings" @@ -55,11 +55,7 @@ type File struct { func (f *File) GenerateFile() string { var sb strings.Builder - // Write headers - sb.WriteString(header) - sb.WriteString(newLine + newLine) - sb.WriteString("package internal") - sb.WriteString(newLine + newLine) + generateHeader(&sb, "internal") // Add imports sb.WriteString("import (" + newLine) @@ -85,11 +81,7 @@ func (f *File) GenerateFile() string { func (f *File) GenerateTestFile() string { var sb strings.Builder - // Write headers - sb.WriteString(header) - sb.WriteString(newLine + newLine) - sb.WriteString("package internal") - sb.WriteString(newLine + newLine) + generateHeader(&sb, "internal") // Add imports sb.WriteString("import (" + newLine) @@ -118,24 +110,35 @@ func (f *File) GenerateTestFile() string { } // GenerateFile generates the aliases for data structures for this File. -func (f *File) GenerateAliasFile() string { +func (f *File) GenerateAliasFile(packageName string, deprecatedInFavor string) string { var sb strings.Builder - // Write headers - sb.WriteString(header) - sb.WriteString(newLine + newLine) - sb.WriteString("package pdata") - sb.WriteString(newLine + newLine) + generateHeader(&sb, packageName) // Add import - sb.WriteString("import \"go.opentelemetry.io/collector/model/internal\"" + newLine + newLine) + imp := "import \"go.opentelemetry.io/collector/pdata/internal\"" + if packageName == "pdata" { + imp = "import \"go.opentelemetry.io/collector/pdata/" + deprecatedInFavor + "\"" + } + sb.WriteString(imp + newLine + newLine) // Write all types and funcs for _, s := range f.structs { if ag, ok := s.(aliasGenerator); ok { - ag.generateAlias(&sb) + ag.generateAlias(&sb, deprecatedInFavor) } } sb.WriteString(newLine) return sb.String() } + +func (f *File) IsCommon() bool { + return f.Name == "resource" || f.Name == "common" +} + +func generateHeader(sb *strings.Builder, packageName string) { + sb.WriteString(header) + sb.WriteString(newLine + newLine) + sb.WriteString("package " + packageName) + sb.WriteString(newLine + newLine) +} diff --git a/model/internal/cmd/pdatagen/internal/log_structs.go b/pdata/internal/cmd/pdatagen/internal/log_structs.go similarity index 94% rename from model/internal/cmd/pdatagen/internal/log_structs.go rename to pdata/internal/cmd/pdatagen/internal/log_structs.go index a12188a5e67..d85d0cccbcc 100644 --- a/model/internal/cmd/pdatagen/internal/log_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/log_structs.go @@ -12,21 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal/cmd/pdatagen/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" var logFile = &File{ - Name: "log", + Name: "plog", imports: []string{ `"sort"`, ``, - `otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1"`, + `otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1"`, }, testImports: []string{ `"testing"`, ``, `"github.com/stretchr/testify/assert"`, ``, - `otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1"`, + `otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1"`, }, structs: []baseStruct{ resourceLogsSlice, diff --git a/model/internal/cmd/pdatagen/internal/metrics_structs.go b/pdata/internal/cmd/pdatagen/internal/metrics_structs.go similarity index 98% rename from model/internal/cmd/pdatagen/internal/metrics_structs.go rename to pdata/internal/cmd/pdatagen/internal/metrics_structs.go index 37c3be39f09..e1d54955de6 100644 --- a/model/internal/cmd/pdatagen/internal/metrics_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/metrics_structs.go @@ -12,21 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal/cmd/pdatagen/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" var metricsFile = &File{ - Name: "metrics", + Name: "pmetric", imports: []string{ `"sort"`, ``, - `otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1"`, + `otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1"`, }, testImports: []string{ `"testing"`, ``, `"github.com/stretchr/testify/assert"`, ``, - `otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1"`, + `otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1"`, }, structs: []baseStruct{ resourceMetricsSlice, diff --git a/model/internal/cmd/pdatagen/internal/resource_structs.go b/pdata/internal/cmd/pdatagen/internal/resource_structs.go similarity index 90% rename from model/internal/cmd/pdatagen/internal/resource_structs.go rename to pdata/internal/cmd/pdatagen/internal/resource_structs.go index 4b805946d69..7831cd27c29 100644 --- a/model/internal/cmd/pdatagen/internal/resource_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/resource_structs.go @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal/cmd/pdatagen/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" var resourceFile = &File{ Name: "resource", imports: []string{ - `otlpresource "go.opentelemetry.io/collector/model/internal/data/protogen/resource/v1"`, + `otlpresource "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1"`, }, testImports: []string{ `"testing"`, diff --git a/model/internal/cmd/pdatagen/internal/trace_structs.go b/pdata/internal/cmd/pdatagen/internal/trace_structs.go similarity index 96% rename from model/internal/cmd/pdatagen/internal/trace_structs.go rename to pdata/internal/cmd/pdatagen/internal/trace_structs.go index b88fe7a8e5d..aede753093b 100644 --- a/model/internal/cmd/pdatagen/internal/trace_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/trace_structs.go @@ -12,21 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal/cmd/pdatagen/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" var traceFile = &File{ - Name: "trace", + Name: "ptrace", imports: []string{ `"sort"`, ``, - `otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1"`, + `otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1"`, }, testImports: []string{ `"testing"`, ``, `"github.com/stretchr/testify/assert"`, ``, - `otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1"`, + `otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1"`, }, structs: []baseStruct{ resourceSpansSlice, diff --git a/model/internal/cmd/pdatagen/main.go b/pdata/internal/cmd/pdatagen/main.go similarity index 62% rename from model/internal/cmd/pdatagen/main.go rename to pdata/internal/cmd/pdatagen/main.go index d91a3597d07..e5300897d2e 100644 --- a/model/internal/cmd/pdatagen/main.go +++ b/pdata/internal/cmd/pdatagen/main.go @@ -16,8 +16,9 @@ package main import ( "os" + "path/filepath" - "go.opentelemetry.io/collector/model/internal/cmd/pdatagen/internal" + "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" ) func check(e error) { @@ -28,19 +29,30 @@ func check(e error) { func main() { for _, fp := range internal.AllFiles { - f, err := os.Create("./model/internal/generated_" + fp.Name + ".go") + f, err := os.Create("./pdata/internal/generated_" + fp.Name + ".go") check(err) _, err = f.WriteString(fp.GenerateFile()) check(err) check(f.Close()) - f, err = os.Create("./model/internal/generated_" + fp.Name + "_test.go") + f, err = os.Create("./pdata/internal/generated_" + fp.Name + "_test.go") check(err) _, err = f.WriteString(fp.GenerateTestFile()) check(err) check(f.Close()) f, err = os.Create("./model/pdata/generated_" + fp.Name + "_alias.go") check(err) - _, err = f.WriteString(fp.GenerateAliasFile()) + fileName := "generated_alias.go" + packageName := fp.Name + if fp.IsCommon() { + fileName = "generated_" + fp.Name + "_alias.go" + packageName = "pcommon" + } + _, err = f.WriteString(fp.GenerateAliasFile("pdata", packageName)) + check(err) + check(f.Close()) + f, err = os.Create(filepath.Clean("./pdata/" + packageName + "/" + fileName)) + check(err) + _, err = f.WriteString(fp.GenerateAliasFile(packageName, "")) check(err) check(f.Close()) } diff --git a/model/internal/common.go b/pdata/internal/common.go similarity index 98% rename from model/internal/common.go rename to pdata/internal/common.go index 4adfdd79ce9..2d16348d6f9 100644 --- a/model/internal/common.go +++ b/pdata/internal/common.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal" // This file contains data structures that are common for all telemetry types, // such as timestamps, attributes, etc. @@ -26,7 +26,7 @@ import ( "sort" "strconv" - otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" + otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) // ValueType specifies the type of Value. @@ -574,24 +574,6 @@ func NewMapFromRaw(rawMap map[string]interface{}) Map { return Map{&origs} } -// NewMapFromRaw creates a Map with values -// from the given map[string]Value. -// Deprecated: [v0.48.0] Use NewMapFromRaw instead. -func NewAttributeMapFromMap(rawMap map[string]Value) Map { - if len(rawMap) == 0 { - kv := []otlpcommon.KeyValue(nil) - return Map{&kv} - } - origs := make([]otlpcommon.KeyValue, len(rawMap)) - ix := 0 - for k, v := range rawMap { - origs[ix].Key = k - v.copyTo(&origs[ix].Value) - ix++ - } - return Map{&origs} -} - func newMap(orig *[]otlpcommon.KeyValue) Map { return Map{orig} } diff --git a/model/internal/common_test.go b/pdata/internal/common_test.go similarity index 97% rename from model/internal/common_test.go rename to pdata/internal/common_test.go index 847d9a1513d..e4334f1a8dd 100644 --- a/model/internal/common_test.go +++ b/pdata/internal/common_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" + otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) func TestAttributeValue(t *testing.T) { @@ -618,30 +618,6 @@ func TestMap_InitFromRaw(t *testing.T) { assert.EqualValues(t, Map{orig: &rawOrig}.Sort(), am.Sort()) } -func TestMap_InitFromMapDeprecated(t *testing.T) { - am := NewAttributeMapFromMap(map[string]Value(nil)) - assert.EqualValues(t, NewMap(), am) - - rawMap := map[string]Value{ - "k_string": NewValueString("123"), - "k_int": NewValueInt(int64(123)), - "k_double": NewValueDouble(float64(1.23)), - "k_bool": NewValueBool(true), - "k_null": NewValueEmpty(), - "k_bytes": NewValueBytes([]byte{1, 2, 3}), - } - rawOrig := []otlpcommon.KeyValue{ - newAttributeKeyValueString("k_string", "123"), - newAttributeKeyValueInt("k_int", 123), - newAttributeKeyValueDouble("k_double", 1.23), - newAttributeKeyValueBool("k_bool", true), - newAttributeKeyValueNull("k_null"), - newAttributeKeyValueBytes("k_bytes", []byte{1, 2, 3}), - } - am = NewAttributeMapFromMap(rawMap) - assert.EqualValues(t, Map{orig: &rawOrig}.Sort(), am.Sort()) -} - func TestAttributeValue_CopyTo(t *testing.T) { // Test nil KvlistValue case for MapVal() func. dest := NewValueEmpty() diff --git a/model/internal/data/bytesid.go b/pdata/internal/data/bytesid.go similarity index 96% rename from model/internal/data/bytesid.go rename to pdata/internal/data/bytesid.go index 0e1ed9e23cd..4a207da1127 100644 --- a/model/internal/data/bytesid.go +++ b/pdata/internal/data/bytesid.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package data // import "go.opentelemetry.io/collector/model/internal/data" +package data // import "go.opentelemetry.io/collector/pdata/internal/data" import ( "encoding/hex" diff --git a/model/internal/data/protogen/collector/logs/v1/logs_service.pb.go b/pdata/internal/data/protogen/collector/logs/v1/logs_service.pb.go similarity index 97% rename from model/internal/data/protogen/collector/logs/v1/logs_service.pb.go rename to pdata/internal/data/protogen/collector/logs/v1/logs_service.pb.go index 0d0ec98d6c3..54736710b1e 100644 --- a/model/internal/data/protogen/collector/logs/v1/logs_service.pb.go +++ b/pdata/internal/data/protogen/collector/logs/v1/logs_service.pb.go @@ -16,7 +16,7 @@ import ( codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - v1 "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" + v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) // Reference imports to suppress errors if they are not otherwise used. @@ -125,7 +125,7 @@ func init() { } var fileDescriptor_8e3bf87aaa43acd4 = []byte{ - // 305 bytes of a gzipped FileDescriptorProto + // 302 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0xc8, 0x2f, 0x48, 0xcd, 0x2b, 0x49, 0xcd, 0x49, 0xcd, 0x4d, 0x2d, 0x29, 0xaa, 0xd4, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x4f, 0xce, 0xcf, 0xc9, 0x49, 0x4d, 0x2e, 0xc9, 0x2f, 0xd2, 0xcf, 0xc9, 0x4f, 0x2f, 0xd6, 0x2f, @@ -142,10 +142,9 @@ var fileDescriptor_8e3bf87aaa43acd4 = []byte{ 0x8c, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0xc0, 0xa5, 0x91, 0x99, 0x4f, 0x9c, 0x05, 0x4e, 0x02, 0x48, 0x66, 0x07, 0x80, 0xd4, 0x04, 0x30, 0x46, 0xf9, 0xa4, 0xa3, 0xeb, 0xce, - 0x44, 0x4e, 0x20, 0xb9, 0xf9, 0x29, 0xa9, 0x39, 0xfa, 0x99, 0x79, 0x25, 0xa9, 0x45, 0x79, 0x89, - 0x39, 0xfa, 0x29, 0x89, 0x25, 0x89, 0x90, 0xd8, 0x4c, 0x4f, 0xcd, 0xc3, 0x4c, 0x47, 0x49, 0x6c, - 0x60, 0x39, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x41, 0x87, 0x07, 0x44, 0x77, 0x02, 0x00, - 0x00, + 0x44, 0x4e, 0x20, 0x05, 0x29, 0x89, 0x25, 0x89, 0xfa, 0x99, 0x79, 0x25, 0xa9, 0x45, 0x79, 0x89, + 0x39, 0xfa, 0x60, 0x1e, 0xd8, 0xf8, 0xf4, 0xd4, 0x3c, 0xcc, 0x74, 0x94, 0xc4, 0x06, 0x96, 0x33, + 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x56, 0x81, 0x5e, 0x77, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/model/internal/data/protogen/collector/metrics/v1/metrics_service.pb.go b/pdata/internal/data/protogen/collector/metrics/v1/metrics_service.pb.go similarity index 88% rename from model/internal/data/protogen/collector/metrics/v1/metrics_service.pb.go rename to pdata/internal/data/protogen/collector/metrics/v1/metrics_service.pb.go index 4ea1ab80058..e0657f4e5b4 100644 --- a/model/internal/data/protogen/collector/metrics/v1/metrics_service.pb.go +++ b/pdata/internal/data/protogen/collector/metrics/v1/metrics_service.pb.go @@ -16,7 +16,7 @@ import ( codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - v1 "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" + v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // Reference imports to suppress errors if they are not otherwise used. @@ -125,26 +125,26 @@ func init() { } var fileDescriptor_75fb6015e6e64798 = []byte{ - // 302 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x3f, 0x4b, 0xc3, 0x40, - 0x14, 0xcf, 0x21, 0x74, 0x38, 0x41, 0x25, 0x3a, 0x48, 0x94, 0x43, 0x32, 0x15, 0x94, 0x3b, 0x5a, - 0x77, 0x87, 0x42, 0xdd, 0xc4, 0x12, 0xb7, 0x2e, 0x25, 0xa6, 0x8f, 0x10, 0x88, 0xf7, 0xe2, 0xdd, - 0x35, 0xd8, 0x6f, 0xe1, 0xea, 0x77, 0xd0, 0xef, 0xe1, 0xd8, 0xd1, 0x51, 0x92, 0x2f, 0x22, 0xe9, - 0x45, 0xe5, 0x34, 0x48, 0xc1, 0xed, 0xf1, 0x7b, 0xbf, 0x7f, 0xc9, 0x3d, 0x7a, 0x81, 0x05, 0x48, - 0x03, 0x39, 0xdc, 0x81, 0x51, 0x4b, 0x51, 0x28, 0x34, 0x28, 0x12, 0xcc, 0x73, 0x48, 0x0c, 0x2a, - 0xd1, 0xa0, 0x59, 0xa2, 0x45, 0x39, 0xf8, 0x1c, 0x67, 0x1a, 0x54, 0x99, 0x25, 0xc0, 0xd7, 0x54, - 0xbf, 0xef, 0xe8, 0x2d, 0xc8, 0xbf, 0xf4, 0xbc, 0x15, 0xf1, 0x72, 0x10, 0x1c, 0xa4, 0x98, 0xa2, - 0xf5, 0x6f, 0x26, 0x4b, 0x0d, 0xce, 0xba, 0xf2, 0x7f, 0xa7, 0x5a, 0x76, 0xb8, 0xa4, 0x47, 0xe3, - 0x87, 0x02, 0x95, 0xb9, 0xb2, 0xf0, 0x8d, 0xed, 0x12, 0xc1, 0xfd, 0x02, 0xb4, 0xf1, 0xa7, 0x74, - 0x4f, 0x81, 0xc6, 0x85, 0x4a, 0x60, 0xd6, 0x0a, 0x0f, 0xc9, 0xc9, 0x56, 0x7f, 0x7b, 0x28, 0x78, - 0x57, 0xcf, 0xef, 0x76, 0x3c, 0x6a, 0x75, 0xad, 0x71, 0xb4, 0xab, 0x5c, 0x20, 0x64, 0xf4, 0xb8, - 0x3b, 0x5a, 0x17, 0x28, 0x35, 0x0c, 0x9f, 0x09, 0xdd, 0x71, 0x57, 0xfe, 0x13, 0xa1, 0x3d, 0xab, - 0xf1, 0xc7, 0x7c, 0xd3, 0xff, 0xc4, 0xff, 0xf8, 0xc0, 0xe0, 0xf2, 0xbf, 0x36, 0xb6, 0x6c, 0xe8, - 0x8d, 0x5e, 0xc8, 0x6b, 0xc5, 0xc8, 0xaa, 0x62, 0xe4, 0xbd, 0x62, 0xe4, 0xb1, 0x66, 0xde, 0xaa, - 0x66, 0xde, 0x5b, 0xcd, 0x3c, 0x7a, 0x9a, 0xe1, 0xc6, 0x31, 0xa3, 0x7d, 0x37, 0x61, 0xd2, 0x30, - 0x27, 0x64, 0x7a, 0x9d, 0xfe, 0xf4, 0xc8, 0x9c, 0xb3, 0xc2, 0x39, 0xe4, 0x22, 0x93, 0x06, 0x94, - 0x8c, 0x73, 0x31, 0x8f, 0x4d, 0x6c, 0x9f, 0x3e, 0x05, 0xd9, 0x79, 0x7d, 0xb7, 0xbd, 0xf5, 0xfa, - 0xfc, 0x23, 0x00, 0x00, 0xff, 0xff, 0xbd, 0x25, 0x0c, 0xb5, 0xb0, 0x02, 0x00, 0x00, + // 303 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0xcb, 0x2f, 0x48, 0xcd, + 0x2b, 0x49, 0xcd, 0x49, 0xcd, 0x4d, 0x2d, 0x29, 0xaa, 0xd4, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, + 0x4f, 0xce, 0xcf, 0xc9, 0x49, 0x4d, 0x2e, 0xc9, 0x2f, 0xd2, 0x07, 0x89, 0x66, 0x26, 0x17, 0xeb, + 0x97, 0x19, 0xc2, 0x98, 0xf1, 0xc5, 0xa9, 0x45, 0x65, 0x99, 0xc9, 0xa9, 0x7a, 0x60, 0xa5, 0x42, + 0x1a, 0x28, 0xfa, 0x21, 0x82, 0x7a, 0x70, 0xfd, 0x7a, 0x50, 0x4d, 0x7a, 0x65, 0x86, 0x52, 0x22, + 0xe9, 0xf9, 0xe9, 0xf9, 0x10, 0xf3, 0x41, 0x2c, 0x88, 0x52, 0x29, 0x1d, 0x6c, 0xf6, 0x63, 0xda, + 0x0a, 0x51, 0xad, 0x54, 0xc9, 0x25, 0xed, 0x5a, 0x51, 0x90, 0x5f, 0x54, 0xe2, 0x0b, 0x11, 0x0e, + 0x86, 0xb8, 0x25, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x28, 0x8a, 0x4b, 0xa0, 0x28, 0xb5, + 0x38, 0xbf, 0xb4, 0x28, 0x39, 0x35, 0x1e, 0xaa, 0x51, 0x82, 0x51, 0x81, 0x59, 0x83, 0xdb, 0x48, + 0x5f, 0x0f, 0x9b, 0x3b, 0x11, 0xae, 0xd3, 0x0b, 0x82, 0xea, 0x83, 0x1a, 0x1c, 0xc4, 0x5f, 0x84, + 0x2a, 0xa0, 0x24, 0xc7, 0x25, 0x83, 0xdd, 0xea, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0xa3, 0x35, + 0x8c, 0x5c, 0x7c, 0xa8, 0x52, 0x42, 0x33, 0x19, 0xb9, 0xd8, 0x20, 0x7a, 0x84, 0x5c, 0xf5, 0x88, + 0x0d, 0x27, 0x3d, 0x3c, 0x1e, 0x94, 0x72, 0xa3, 0xd4, 0x18, 0x88, 0x63, 0x95, 0x18, 0x9c, 0xd6, + 0x32, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, + 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x03, 0x97, 0x76, 0x66, 0x3e, 0xd1, + 0xd6, 0x38, 0x09, 0xa3, 0xda, 0x10, 0x00, 0x52, 0x19, 0xc0, 0x18, 0xe5, 0x9f, 0x8e, 0x6e, 0x46, + 0x26, 0x72, 0xb2, 0x2a, 0x48, 0x49, 0x2c, 0x49, 0xd4, 0xcf, 0xcc, 0x2b, 0x49, 0x2d, 0xca, 0x4b, + 0xcc, 0xd1, 0x07, 0xf3, 0xc0, 0x96, 0xa4, 0xa7, 0xe6, 0x61, 0x4d, 0x7d, 0x49, 0x6c, 0x60, 0x69, + 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa1, 0x13, 0x8e, 0x3e, 0xb0, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/model/internal/data/protogen/collector/trace/v1/trace_config.pb.go b/pdata/internal/data/protogen/collector/trace/v1/trace_config.pb.go similarity index 90% rename from model/internal/data/protogen/collector/trace/v1/trace_config.pb.go rename to pdata/internal/data/protogen/collector/trace/v1/trace_config.pb.go index 8f8b47da72c..363f3c13fef 100644 --- a/model/internal/data/protogen/collector/trace/v1/trace_config.pb.go +++ b/pdata/internal/data/protogen/collector/trace/v1/trace_config.pb.go @@ -355,43 +355,43 @@ func init() { } var fileDescriptor_5936aa8fa6443e6f = []byte{ - // 566 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0x93, 0x95, 0xfd, 0x7b, 0xa7, 0x6d, 0xa9, 0xbb, 0xa1, 0x68, 0x9a, 0xc2, 0x88, 0x90, - 0xe8, 0x65, 0x8d, 0x3a, 0x0e, 0x08, 0x0e, 0x48, 0xed, 0xfe, 0x30, 0xa4, 0xd2, 0x55, 0x59, 0x25, - 0x44, 0x2f, 0x96, 0x9b, 0xb8, 0x91, 0x45, 0x62, 0x17, 0xc7, 0xab, 0xc6, 0x9d, 0x0f, 0xc0, 0x07, - 0xe0, 0x5b, 0xf0, 0x25, 0x38, 0xee, 0xc8, 0x11, 0xb5, 0x5f, 0x04, 0xc5, 0xe9, 0xba, 0xb6, 0xdb, - 0x2a, 0x71, 0xb3, 0x9f, 0xc7, 0xcf, 0xef, 0x7d, 0xdd, 0xbe, 0x31, 0x78, 0xa2, 0x4f, 0xb9, 0xa2, - 0x31, 0x4d, 0xa8, 0x92, 0xdf, 0xbc, 0xbe, 0x14, 0x4a, 0x78, 0x4a, 0x92, 0x80, 0x7a, 0x83, 0x6a, - 0xbe, 0xc0, 0x81, 0xe0, 0x3d, 0x16, 0x55, 0xb4, 0x87, 0xf6, 0x67, 0x02, 0xb9, 0x58, 0xd1, 0xe7, - 0x2a, 0x83, 0xea, 0xde, 0x4e, 0x24, 0x22, 0x91, 0x43, 0xb2, 0x55, 0x6e, 0xbb, 0xdf, 0x97, 0x61, - 0xa3, 0x9d, 0x1d, 0x39, 0xd6, 0x24, 0xd4, 0x01, 0x2b, 0x10, 0x3c, 0x55, 0x84, 0x2b, 0x9c, 0x92, - 0xa4, 0x1f, 0x53, 0x69, 0x9b, 0x07, 0x66, 0x79, 0xe3, 0xe8, 0xb0, 0xb2, 0x08, 0x5f, 0x39, 0x1e, - 0xa7, 0x2e, 0xf3, 0xd0, 0xb9, 0xe1, 0x6f, 0x07, 0xb3, 0x12, 0xea, 0xc2, 0x4e, 0xde, 0x35, 0x0b, - 0xb1, 0x24, 0x8a, 0x09, 0xdc, 0x25, 0x29, 0x0d, 0xed, 0x25, 0xcd, 0xf7, 0x16, 0xf3, 0x75, 0x93, - 0x1f, 0x42, 0x3f, 0xcb, 0xd5, 0xb3, 0xd8, 0xb9, 0xe1, 0x17, 0xd5, 0xbc, 0x88, 0x22, 0xd8, 0x95, - 0x44, 0x51, 0x1c, 0xb3, 0x84, 0x29, 0xc6, 0xa3, 0xc9, 0x25, 0x0a, 0xba, 0x48, 0x75, 0x71, 0x11, - 0x9f, 0x28, 0xda, 0x18, 0x27, 0xef, 0x2e, 0x52, 0x92, 0xf7, 0x65, 0xf4, 0x1a, 0xec, 0x84, 0x5c, - 0x63, 0x7e, 0x95, 0x74, 0xa9, 0xc4, 0xa2, 0x87, 0x89, 0x52, 0x92, 0x75, 0xaf, 0x14, 0x4d, 0xed, - 0x27, 0x07, 0x66, 0xb9, 0xe0, 0xef, 0x26, 0xe4, 0xba, 0xa9, 0xed, 0x8b, 0x5e, 0x6d, 0x62, 0xa2, - 0xb7, 0xb0, 0x37, 0x1b, 0x54, 0x2c, 0xa1, 0x21, 0xa6, 0x03, 0xca, 0x55, 0x6a, 0x2f, 0xeb, 0xe8, - 0xd3, 0xa9, 0x68, 0x3b, 0xb3, 0x4f, 0xb5, 0x8b, 0xda, 0x50, 0x7e, 0xac, 0x28, 0xee, 0x53, 0x39, - 0x8d, 0xb2, 0x57, 0x34, 0xc9, 0x7d, 0xb0, 0x89, 0x16, 0x95, 0x77, 0x58, 0x74, 0x08, 0xa5, 0x59, - 0x6a, 0xcc, 0xf8, 0x97, 0xd4, 0x5e, 0xd5, 0x00, 0x6b, 0x0a, 0xd0, 0xc8, 0x74, 0xf4, 0x1e, 0x9e, - 0x2f, 0x6c, 0x22, 0x4b, 0xdb, 0x6b, 0x3a, 0xbc, 0xff, 0x58, 0xf5, 0x8c, 0x54, 0x5f, 0x87, 0xd5, - 0xf1, 0xbf, 0xe3, 0xfe, 0x32, 0x61, 0x7b, 0x6e, 0x82, 0x50, 0x07, 0xd6, 0x42, 0x1a, 0xb0, 0x94, - 0x09, 0xae, 0x47, 0x70, 0xeb, 0xe8, 0xdd, 0x7f, 0x8d, 0xe0, 0x64, 0x7f, 0x32, 0xa6, 0xf8, 0x13, - 0x9e, 0x7b, 0x02, 0xd6, 0xbc, 0x8b, 0xb6, 0x00, 0x6a, 0x8d, 0x4f, 0xb5, 0xcf, 0x97, 0xf8, 0xe2, - 0xec, 0xcc, 0x32, 0xd0, 0x26, 0xac, 0xdf, 0xee, 0x9b, 0x96, 0x89, 0x8a, 0xb0, 0x39, 0xde, 0xb6, - 0x6a, 0xfe, 0x69, 0xb3, 0x6d, 0x2d, 0xb9, 0x6f, 0xa0, 0x78, 0x6f, 0x2c, 0xd1, 0x0b, 0xd8, 0xd4, - 0xb7, 0x62, 0x3c, 0xd2, 0xaa, 0xee, 0xdd, 0xf4, 0x67, 0x45, 0xf7, 0x25, 0x94, 0x1e, 0x18, 0x36, - 0x64, 0x41, 0xe1, 0x6b, 0x3f, 0xd5, 0x91, 0x82, 0x9f, 0x2d, 0xeb, 0x3f, 0xcd, 0xdf, 0x43, 0xc7, - 0xbc, 0x19, 0x3a, 0xe6, 0xdf, 0xa1, 0x63, 0xfe, 0x18, 0x39, 0xc6, 0xcd, 0xc8, 0x31, 0xfe, 0x8c, - 0x1c, 0x03, 0x9e, 0x31, 0xb1, 0xf0, 0x07, 0xa9, 0x5b, 0x53, 0x5f, 0x76, 0x2b, 0xb3, 0x5a, 0x66, - 0xe7, 0x63, 0x34, 0x1f, 0x62, 0xc2, 0x0b, 0x44, 0x1c, 0xd3, 0x40, 0x09, 0xe9, 0x25, 0x22, 0xa4, - 0xb1, 0xc7, 0xb8, 0xa2, 0x92, 0x93, 0xd8, 0x0b, 0x89, 0x22, 0xf9, 0xcb, 0x13, 0x51, 0x3e, 0x75, - 0xec, 0xf6, 0x19, 0xea, 0xae, 0x68, 0xf3, 0xd5, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2a, 0x5a, - 0x5f, 0x9f, 0xad, 0x04, 0x00, 0x00, + // 563 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcd, 0x6e, 0xd3, 0x40, + 0x14, 0x85, 0xed, 0x86, 0xfe, 0xdd, 0xaa, 0xad, 0x3b, 0x6d, 0x91, 0x55, 0x55, 0xa6, 0x58, 0x48, + 0x64, 0xd3, 0x58, 0x29, 0x0b, 0x04, 0x0b, 0xa4, 0xa4, 0x3f, 0x14, 0x29, 0xa4, 0x91, 0x1b, 0x09, + 0x91, 0xcd, 0x68, 0x62, 0x4f, 0xac, 0x11, 0xf6, 0x8c, 0x19, 0x4f, 0xa3, 0xb2, 0xe7, 0x01, 0x78, + 0x00, 0xde, 0x82, 0x97, 0x60, 0xd9, 0x25, 0x4b, 0x94, 0xbc, 0x08, 0xf2, 0x38, 0x4d, 0x93, 0xb4, + 0x8d, 0xc4, 0x6e, 0xee, 0x39, 0x73, 0xbe, 0x7b, 0x27, 0xb9, 0x09, 0x78, 0x22, 0xa5, 0x5c, 0xd1, + 0x98, 0x26, 0x54, 0xc9, 0x6f, 0x5e, 0x2a, 0x85, 0x12, 0x9e, 0x92, 0x24, 0xa0, 0x5e, 0xbf, 0x5a, + 0x1c, 0x70, 0x20, 0x78, 0x8f, 0x45, 0x15, 0xed, 0xa1, 0xfd, 0xa9, 0x40, 0x21, 0x56, 0xf4, 0xbd, + 0x4a, 0xbf, 0xba, 0xb7, 0x13, 0x89, 0x48, 0x14, 0x90, 0xfc, 0x54, 0xd8, 0xee, 0xf7, 0x45, 0x58, + 0x6b, 0xe7, 0x57, 0x8e, 0x35, 0x09, 0x75, 0xc0, 0x0a, 0x04, 0xcf, 0x14, 0xe1, 0x0a, 0x67, 0x24, + 0x49, 0x63, 0x2a, 0x6d, 0xf3, 0xc0, 0x2c, 0xaf, 0x1d, 0x1d, 0x56, 0xe6, 0xe1, 0x2b, 0xc7, 0xa3, + 0xd4, 0x65, 0x11, 0x3a, 0x37, 0xfc, 0xcd, 0x60, 0x5a, 0x42, 0x5d, 0xd8, 0x29, 0xa6, 0x66, 0x21, + 0x96, 0x44, 0x31, 0x81, 0xbb, 0x24, 0xa3, 0xa1, 0xbd, 0xa0, 0xf9, 0xde, 0x7c, 0xbe, 0x1e, 0xf2, + 0x43, 0xe8, 0xe7, 0xb9, 0x7a, 0x1e, 0x3b, 0x37, 0xfc, 0x2d, 0x35, 0x2b, 0xa2, 0x08, 0x76, 0x25, + 0x51, 0x14, 0xc7, 0x2c, 0x61, 0x8a, 0xf1, 0x68, 0xfc, 0x88, 0x92, 0x6e, 0x52, 0x9d, 0xdf, 0xc4, + 0x27, 0x8a, 0x36, 0x46, 0xc9, 0xbb, 0x87, 0x6c, 0xcb, 0xfb, 0x32, 0x7a, 0x0d, 0x76, 0x42, 0xae, + 0x31, 0xbf, 0x4a, 0xba, 0x54, 0x62, 0xd1, 0xc3, 0x44, 0x29, 0xc9, 0xba, 0x57, 0x8a, 0x66, 0xf6, + 0x93, 0x03, 0xb3, 0x5c, 0xf2, 0x77, 0x13, 0x72, 0xdd, 0xd4, 0xf6, 0x45, 0xaf, 0x36, 0x36, 0xd1, + 0x5b, 0xd8, 0x9b, 0x0e, 0x2a, 0x96, 0xd0, 0x10, 0xd3, 0x3e, 0xe5, 0x2a, 0xb3, 0x17, 0x75, 0xf4, + 0xe9, 0x44, 0xb4, 0x9d, 0xdb, 0xa7, 0xda, 0x45, 0x6d, 0x28, 0x3f, 0xd6, 0x14, 0xa7, 0x54, 0x4e, + 0xa2, 0xec, 0x25, 0x4d, 0x72, 0x1f, 0x1c, 0xa2, 0x45, 0xe5, 0x1d, 0x16, 0x1d, 0xc2, 0xf6, 0x34, + 0x35, 0x66, 0xfc, 0x4b, 0x66, 0x2f, 0x6b, 0x80, 0x35, 0x01, 0x68, 0xe4, 0x3a, 0x7a, 0x0f, 0xcf, + 0xe7, 0x0e, 0x91, 0xa7, 0xed, 0x15, 0x1d, 0xde, 0x7f, 0xac, 0x7b, 0x4e, 0xaa, 0xaf, 0xc2, 0xf2, + 0xe8, 0xdb, 0x71, 0x7f, 0x99, 0xb0, 0x39, 0xb3, 0x41, 0xa8, 0x03, 0x2b, 0x21, 0x0d, 0x58, 0xc6, + 0x04, 0xd7, 0x2b, 0xb8, 0x71, 0xf4, 0xee, 0xbf, 0x56, 0x70, 0x5c, 0x9f, 0x8c, 0x28, 0xfe, 0x98, + 0xe7, 0x9e, 0x80, 0x35, 0xeb, 0xa2, 0x0d, 0x80, 0x5a, 0xe3, 0x53, 0xed, 0xf3, 0x25, 0xbe, 0x38, + 0x3b, 0xb3, 0x0c, 0xb4, 0x0e, 0xab, 0xb7, 0x75, 0xd3, 0x32, 0xd1, 0x16, 0xac, 0x8f, 0xca, 0x56, + 0xcd, 0x3f, 0x6d, 0xb6, 0xad, 0x05, 0xf7, 0x0d, 0x6c, 0xdd, 0x5b, 0x4b, 0xf4, 0x02, 0xd6, 0xf5, + 0xab, 0x18, 0x8f, 0xb4, 0xaa, 0x67, 0x37, 0xfd, 0x69, 0xd1, 0x7d, 0x09, 0xdb, 0x0f, 0x2c, 0x1b, + 0xb2, 0xa0, 0xf4, 0x35, 0xcd, 0x74, 0xa4, 0xe4, 0xe7, 0xc7, 0xfa, 0x4f, 0xf3, 0xf7, 0xc0, 0x31, + 0x6f, 0x06, 0x8e, 0xf9, 0x77, 0xe0, 0x98, 0x3f, 0x86, 0x8e, 0x71, 0x33, 0x74, 0x8c, 0x3f, 0x43, + 0xc7, 0x80, 0x67, 0x4c, 0xcc, 0xfd, 0x40, 0xea, 0xd6, 0xc4, 0x2f, 0xbb, 0x95, 0x5b, 0x2d, 0xb3, + 0xf3, 0x31, 0x9a, 0x0d, 0x31, 0xe1, 0x05, 0x22, 0x8e, 0x69, 0xa0, 0x84, 0xf4, 0xd2, 0x90, 0x28, + 0xe2, 0x31, 0xae, 0xa8, 0xe4, 0x24, 0xf6, 0x74, 0xa5, 0xa9, 0x11, 0xe5, 0x13, 0xd7, 0x6e, 0xff, + 0x86, 0xba, 0x4b, 0xda, 0x7c, 0xf5, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x0e, 0xd1, 0x4d, 0x12, 0xad, + 0x04, 0x00, 0x00, } func (m *TraceConfig) Marshal() (dAtA []byte, err error) { diff --git a/model/internal/data/protogen/collector/trace/v1/trace_service.pb.go b/pdata/internal/data/protogen/collector/trace/v1/trace_service.pb.go similarity index 88% rename from model/internal/data/protogen/collector/trace/v1/trace_service.pb.go rename to pdata/internal/data/protogen/collector/trace/v1/trace_service.pb.go index dc28a719b14..0a294a27ece 100644 --- a/model/internal/data/protogen/collector/trace/v1/trace_service.pb.go +++ b/pdata/internal/data/protogen/collector/trace/v1/trace_service.pb.go @@ -16,7 +16,7 @@ import ( codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - v1 "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" + v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) // Reference imports to suppress errors if they are not otherwise used. @@ -125,27 +125,26 @@ func init() { } var fileDescriptor_192a962890318cf4 = []byte{ - // 305 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x3f, 0x4b, 0xc4, 0x30, - 0x14, 0x6f, 0x10, 0x6e, 0x88, 0x7f, 0xc0, 0xe2, 0xa0, 0x45, 0x82, 0x74, 0x90, 0x13, 0x21, 0xe1, - 0xce, 0xcd, 0xcd, 0x82, 0xa3, 0x70, 0xf4, 0x9c, 0x5c, 0xa4, 0xf6, 0x1e, 0xa5, 0xd0, 0xcb, 0xab, - 0x49, 0xae, 0xe8, 0xb7, 0xd0, 0xaf, 0xe0, 0xe2, 0x57, 0x71, 0xbc, 0xd1, 0x51, 0xda, 0x2f, 0x22, - 0x69, 0x54, 0x7a, 0x52, 0xe1, 0xc0, 0xed, 0xe5, 0xbd, 0xdf, 0xbf, 0x24, 0x8f, 0x9e, 0x63, 0x09, - 0xd2, 0x40, 0x01, 0x73, 0x30, 0xea, 0x51, 0x94, 0x0a, 0x0d, 0x8a, 0x14, 0x8b, 0x02, 0x52, 0x83, - 0x4a, 0x18, 0x95, 0xa4, 0x20, 0xaa, 0x91, 0x2b, 0x6e, 0x35, 0xa8, 0x2a, 0x4f, 0x81, 0xb7, 0x30, - 0xff, 0x78, 0x85, 0xeb, 0x9a, 0xfc, 0x87, 0xcb, 0x5b, 0x0a, 0xaf, 0x46, 0xc1, 0x5e, 0x86, 0x19, - 0x3a, 0x65, 0x5b, 0x39, 0x60, 0x30, 0xec, 0x73, 0x5e, 0xf5, 0x73, 0xc8, 0x10, 0xe9, 0xc1, 0xe5, - 0x43, 0x89, 0xca, 0x5c, 0xdb, 0xe6, 0xd4, 0x65, 0x88, 0xe1, 0x7e, 0x01, 0xda, 0xf8, 0x31, 0xdd, - 0x51, 0xa0, 0x71, 0xa1, 0x6c, 0xbc, 0x32, 0x91, 0x7a, 0x9f, 0x1c, 0x6d, 0x0c, 0x37, 0xc7, 0xa7, - 0xbc, 0x2f, 0xdd, 0x77, 0x26, 0x1e, 0x7f, 0x71, 0xa6, 0x96, 0x12, 0x6f, 0xab, 0xee, 0x31, 0x3c, - 0xa4, 0x41, 0x9f, 0xa1, 0x2e, 0x51, 0x6a, 0x18, 0xbf, 0x10, 0xba, 0xd5, 0x1d, 0xf8, 0xcf, 0x84, - 0x0e, 0x1c, 0xde, 0xbf, 0xe0, 0xeb, 0xbd, 0x09, 0xff, 0xf3, 0x42, 0x41, 0xf4, 0x1f, 0x09, 0x17, - 0x31, 0xf4, 0xa2, 0x57, 0xf2, 0x56, 0x33, 0xb2, 0xac, 0x19, 0xf9, 0xa8, 0x19, 0x79, 0x6a, 0x98, - 0xb7, 0x6c, 0x98, 0xf7, 0xde, 0x30, 0x8f, 0x9e, 0xe4, 0xb8, 0xa6, 0x45, 0xb4, 0xdb, 0x55, 0x9f, - 0x58, 0xd4, 0x84, 0xdc, 0x5c, 0x65, 0xbf, 0xf9, 0x79, 0x77, 0x65, 0xe6, 0x38, 0x83, 0x42, 0xe4, - 0xd2, 0x80, 0x92, 0x49, 0x21, 0x66, 0x89, 0x49, 0xdc, 0xe7, 0x66, 0x20, 0x7b, 0x36, 0xeb, 0x6e, - 0xd0, 0x0e, 0xcf, 0x3e, 0x03, 0x00, 0x00, 0xff, 0xff, 0x93, 0x1a, 0xfb, 0x04, 0x8a, 0x02, 0x00, - 0x00, + // 302 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0xbf, 0x4a, 0xc4, 0x30, + 0x18, 0x6f, 0x10, 0x6e, 0x88, 0x7f, 0xc0, 0xe2, 0xa0, 0x45, 0x82, 0xdc, 0x20, 0x27, 0x42, 0xc2, + 0x9d, 0x9b, 0x9b, 0x05, 0x47, 0xe1, 0xe8, 0x39, 0xb9, 0x48, 0xad, 0x1f, 0xa5, 0x50, 0xf3, 0xc5, + 0x24, 0x57, 0xf4, 0x2d, 0xf4, 0x15, 0x5c, 0x7c, 0x15, 0xc7, 0x1b, 0x1d, 0xa5, 0x7d, 0x11, 0x69, + 0xa2, 0xd2, 0x93, 0x0a, 0x07, 0x6e, 0xdf, 0x9f, 0xdf, 0xbf, 0x84, 0x8f, 0x9e, 0xa2, 0x02, 0x69, + 0xa1, 0x84, 0x3b, 0xb0, 0xfa, 0x51, 0x28, 0x8d, 0x16, 0x45, 0x86, 0x65, 0x09, 0x99, 0x45, 0x2d, + 0xac, 0x4e, 0x33, 0x10, 0xd5, 0xd8, 0x17, 0xd7, 0x06, 0x74, 0x55, 0x64, 0xc0, 0x1d, 0x2c, 0x3c, + 0x5c, 0xe2, 0xfa, 0x21, 0xff, 0xe1, 0x72, 0x47, 0xe1, 0xd5, 0x38, 0xda, 0xc9, 0x31, 0x47, 0xaf, + 0xdc, 0x56, 0x1e, 0x18, 0x8d, 0xfa, 0x9c, 0x97, 0xfd, 0x3c, 0x72, 0x88, 0x74, 0xef, 0xfc, 0x41, + 0xa1, 0xb6, 0x97, 0xed, 0x70, 0xe6, 0x33, 0x24, 0x70, 0x3f, 0x07, 0x63, 0xc3, 0x84, 0x6e, 0x69, + 0x30, 0x38, 0xd7, 0x6d, 0x3c, 0x95, 0x4a, 0xb3, 0x4b, 0x0e, 0xd6, 0x46, 0xeb, 0x93, 0x63, 0xde, + 0x97, 0xee, 0x3b, 0x13, 0x4f, 0xbe, 0x38, 0xb3, 0x96, 0x92, 0x6c, 0xea, 0x6e, 0x3b, 0xdc, 0xa7, + 0x51, 0x9f, 0xa1, 0x51, 0x28, 0x0d, 0x4c, 0x5e, 0x08, 0xdd, 0xe8, 0x2e, 0xc2, 0x67, 0x42, 0x07, + 0x1e, 0x1f, 0x9e, 0xf1, 0xd5, 0xfe, 0x84, 0xff, 0xf9, 0xa0, 0x28, 0xfe, 0x8f, 0x84, 0x8f, 0x38, + 0x0c, 0xe2, 0x57, 0xf2, 0x56, 0x33, 0xb2, 0xa8, 0x19, 0xf9, 0xa8, 0x19, 0x79, 0x6a, 0x58, 0xb0, + 0x68, 0x58, 0xf0, 0xde, 0xb0, 0x80, 0x1e, 0x15, 0xb8, 0xa2, 0x45, 0xbc, 0xdd, 0x55, 0x9f, 0xb6, + 0xa8, 0x29, 0xb9, 0xba, 0xc8, 0x7f, 0xf3, 0x8b, 0xee, 0xc9, 0xa8, 0xdb, 0xd4, 0xa6, 0xa2, 0x90, + 0x16, 0xb4, 0x4c, 0x4b, 0xe1, 0x3a, 0x67, 0x90, 0x83, 0xec, 0xb9, 0xac, 0x9b, 0x81, 0x5b, 0x9e, + 0x7c, 0x06, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x91, 0xe9, 0x89, 0x8a, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/model/internal/data/protogen/common/v1/common.pb.go b/pdata/internal/data/protogen/common/v1/common.pb.go similarity index 93% rename from model/internal/data/protogen/common/v1/common.pb.go rename to pdata/internal/data/protogen/common/v1/common.pb.go index 1745440ca94..c15aff30d5e 100644 --- a/model/internal/data/protogen/common/v1/common.pb.go +++ b/pdata/internal/data/protogen/common/v1/common.pb.go @@ -464,38 +464,38 @@ func init() { } var fileDescriptor_62ba46dcb97aa817 = []byte{ - // 486 bytes of a gzipped FileDescriptorProto + // 484 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0xf5, 0x26, 0x69, 0x3e, 0xc6, 0x39, 0x20, 0xab, 0x42, 0x11, 0x52, 0x5d, 0x13, 0x0e, 0x18, - 0x90, 0x62, 0xb5, 0xdc, 0xb8, 0x35, 0x2d, 0x52, 0x80, 0x1c, 0x22, 0x57, 0x70, 0xe0, 0x82, 0xd6, - 0xc9, 0xca, 0x5a, 0x75, 0xbd, 0x1b, 0xad, 0x37, 0x96, 0xfc, 0x2b, 0xe0, 0x67, 0xf5, 0xd8, 0x23, - 0x27, 0x54, 0x25, 0x7f, 0x04, 0xed, 0x47, 0x5a, 0xc8, 0xa1, 0x51, 0x6e, 0x33, 0x6f, 0xde, 0x7b, - 0x33, 0x63, 0xef, 0xc0, 0x5b, 0xb1, 0x24, 0x5c, 0x11, 0x46, 0x0a, 0xa2, 0x64, 0x9d, 0x2c, 0xa5, - 0x50, 0x22, 0x99, 0x8b, 0xa2, 0x10, 0x3c, 0xa9, 0xce, 0x5c, 0x34, 0x32, 0x70, 0x70, 0xf2, 0x1f, - 0xd7, 0x82, 0x23, 0xc7, 0xa8, 0xce, 0x5e, 0x1c, 0xe7, 0x22, 0x17, 0xd6, 0x40, 0x47, 0xb6, 0x3e, - 0xbc, 0x6f, 0x40, 0xf7, 0x82, 0xd7, 0xdf, 0x30, 0x5b, 0x91, 0xe0, 0x15, 0xf4, 0x4b, 0x25, 0x29, - 0xcf, 0x7f, 0x54, 0x3a, 0x1f, 0xa0, 0x08, 0xc5, 0xbd, 0x89, 0x97, 0xfa, 0x16, 0xb5, 0xa4, 0x53, - 0x80, 0x4c, 0x08, 0xe6, 0x28, 0x8d, 0x08, 0xc5, 0xdd, 0x89, 0x97, 0xf6, 0x34, 0x66, 0x09, 0x27, - 0xd0, 0xa3, 0x5c, 0xb9, 0x7a, 0x33, 0x42, 0x71, 0x73, 0xe2, 0xa5, 0x5d, 0xca, 0xd5, 0x43, 0x93, - 0x85, 0x58, 0x65, 0x8c, 0x38, 0x46, 0x2b, 0x42, 0x31, 0xd2, 0x4d, 0x2c, 0x6a, 0x49, 0x53, 0xf0, - 0xb1, 0x94, 0xb8, 0x76, 0x9c, 0xa3, 0x08, 0xc5, 0xfe, 0xf9, 0x9b, 0xd1, 0x93, 0x1b, 0x8e, 0x2e, - 0xb4, 0xc2, 0xe8, 0x27, 0x5e, 0x0a, 0xf8, 0x21, 0x0b, 0x66, 0xd0, 0xbf, 0xa9, 0x18, 0x2d, 0xb7, - 0x43, 0xb5, 0x8d, 0xdd, 0xbb, 0x3d, 0x76, 0x5f, 0x88, 0x95, 0x4f, 0x69, 0xa9, 0xf4, 0x7c, 0xd6, - 0xc2, 0x3a, 0xbe, 0x04, 0x3f, 0xab, 0x15, 0x29, 0x9d, 0x61, 0x27, 0x42, 0x71, 0x5f, 0x37, 0x35, - 0xa0, 0xa1, 0x8c, 0x3b, 0x70, 0x64, 0x8a, 0xc3, 0x6b, 0x80, 0xc7, 0xc9, 0x82, 0x8f, 0xd0, 0x36, - 0x70, 0x39, 0x40, 0x51, 0x33, 0xf6, 0xcf, 0x5f, 0xef, 0x5b, 0xca, 0xfd, 0x9c, 0x71, 0xeb, 0xf6, - 0xcf, 0xa9, 0x97, 0x3a, 0xf1, 0xf0, 0x2b, 0xf4, 0xff, 0x9d, 0xef, 0x60, 0xdb, 0xad, 0x78, 0xc7, - 0x16, 0x43, 0x77, 0x5b, 0x09, 0x9e, 0x41, 0xf3, 0x86, 0xd4, 0xf6, 0x11, 0xa4, 0x3a, 0x0c, 0x2e, - 0xdd, 0x4a, 0xe6, 0xaf, 0x1f, 0x3c, 0xba, 0xfb, 0x1c, 0x9f, 0xe1, 0xf9, 0x27, 0x5e, 0x2a, 0xb9, - 0x2a, 0x08, 0x57, 0x58, 0x51, 0xc1, 0xa7, 0x34, 0x93, 0x58, 0xd6, 0x41, 0x00, 0x2d, 0x8e, 0x0b, - 0xf7, 0xec, 0x52, 0x13, 0x07, 0x03, 0xe8, 0x54, 0x44, 0x96, 0x54, 0x70, 0xd3, 0xb4, 0x97, 0x6e, - 0xd3, 0x0f, 0x8d, 0x01, 0x1a, 0x5e, 0xc1, 0xf1, 0x8e, 0xd7, 0xf5, 0x5c, 0x2c, 0xc9, 0x61, 0x4e, - 0xe3, 0x9f, 0xe8, 0x76, 0x1d, 0xa2, 0xbb, 0x75, 0x88, 0xee, 0xd7, 0x21, 0xfa, 0xb5, 0x09, 0xbd, - 0xbb, 0x4d, 0xe8, 0xfd, 0xde, 0x84, 0x1e, 0x44, 0x54, 0x3c, 0xbd, 0xe4, 0xd8, 0xbf, 0x34, 0xe1, - 0x4c, 0xc3, 0x33, 0xf4, 0xfd, 0x2a, 0xdf, 0x15, 0x50, 0x7d, 0xb0, 0x8c, 0x91, 0xb9, 0x12, 0x32, - 0x29, 0xc4, 0x82, 0xb0, 0x84, 0x72, 0x45, 0x24, 0xc7, 0x2c, 0x59, 0x60, 0x85, 0xed, 0x51, 0xe7, - 0x84, 0x3f, 0xde, 0x75, 0xd6, 0x36, 0xd8, 0xfb, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd5, 0xac, - 0xb3, 0xd7, 0xff, 0x03, 0x00, 0x00, + 0x10, 0xf5, 0x26, 0x69, 0x3e, 0xc6, 0x39, 0xa0, 0x55, 0x85, 0x22, 0xa4, 0xba, 0x26, 0x1c, 0x30, + 0x20, 0xc5, 0x6a, 0xb9, 0x71, 0x6b, 0x5a, 0xa4, 0x00, 0x39, 0x44, 0xae, 0xe0, 0xc0, 0x05, 0xad, + 0xd3, 0x95, 0xb5, 0xaa, 0xbd, 0x1b, 0xad, 0x37, 0x96, 0xfc, 0x2b, 0xe0, 0x67, 0xf5, 0xd8, 0x23, + 0x27, 0x54, 0x25, 0x7f, 0x04, 0xed, 0x87, 0x5b, 0xc8, 0xa1, 0x55, 0x6e, 0x33, 0x6f, 0xde, 0x7b, + 0x33, 0xb3, 0x1f, 0xf0, 0x56, 0xac, 0x28, 0x57, 0x34, 0xa7, 0x05, 0x55, 0xb2, 0x8e, 0x57, 0x52, + 0x28, 0x11, 0x2f, 0x45, 0x51, 0x08, 0x1e, 0x57, 0x27, 0x2e, 0x9a, 0x18, 0x18, 0x1f, 0xfd, 0xc7, + 0xb5, 0xe0, 0xc4, 0x31, 0xaa, 0x93, 0x17, 0x87, 0x99, 0xc8, 0x84, 0x35, 0xd0, 0x91, 0xad, 0x8f, + 0xef, 0x5a, 0xd0, 0x3f, 0xe3, 0xf5, 0x37, 0x92, 0xaf, 0x29, 0x7e, 0x05, 0xc3, 0x52, 0x49, 0xc6, + 0xb3, 0x1f, 0x95, 0xce, 0x47, 0x28, 0x44, 0xd1, 0x60, 0xe6, 0x25, 0xbe, 0x45, 0x2d, 0xe9, 0x18, + 0x20, 0x15, 0x22, 0x77, 0x94, 0x56, 0x88, 0xa2, 0xfe, 0xcc, 0x4b, 0x06, 0x1a, 0xb3, 0x84, 0x23, + 0x18, 0x30, 0xae, 0x5c, 0xbd, 0x1d, 0xa2, 0xa8, 0x3d, 0xf3, 0x92, 0x3e, 0xe3, 0xea, 0xbe, 0xc9, + 0x95, 0x58, 0xa7, 0x39, 0x75, 0x8c, 0x4e, 0x88, 0x22, 0xa4, 0x9b, 0x58, 0xd4, 0x92, 0xe6, 0xe0, + 0x13, 0x29, 0x49, 0xed, 0x38, 0x07, 0x21, 0x8a, 0xfc, 0xd3, 0x37, 0x93, 0x47, 0x37, 0x9c, 0x9c, + 0x69, 0x85, 0xd1, 0xcf, 0xbc, 0x04, 0xc8, 0x7d, 0x86, 0x17, 0x30, 0xbc, 0xae, 0x72, 0x56, 0x36, + 0x43, 0x75, 0x8d, 0xdd, 0xbb, 0x27, 0xec, 0xbe, 0x50, 0x2b, 0x9f, 0xb3, 0x52, 0xe9, 0xf9, 0xac, + 0x85, 0x75, 0x7c, 0x09, 0x7e, 0x5a, 0x2b, 0x5a, 0x3a, 0xc3, 0x5e, 0x88, 0xa2, 0xa1, 0x6e, 0x6a, + 0x40, 0x43, 0x99, 0xf6, 0xe0, 0xc0, 0x14, 0xc7, 0x97, 0x00, 0x0f, 0x93, 0xe1, 0x8f, 0xd0, 0x35, + 0x70, 0x39, 0x42, 0x61, 0x3b, 0xf2, 0x4f, 0x5f, 0x3f, 0xb5, 0x94, 0xbb, 0x9c, 0x69, 0xe7, 0xe6, + 0xcf, 0xb1, 0x97, 0x38, 0xf1, 0xf8, 0x2b, 0x0c, 0xff, 0x9d, 0x6f, 0x6f, 0xdb, 0x46, 0xbc, 0x63, + 0x4b, 0xa0, 0xdf, 0x54, 0xf0, 0x33, 0x68, 0x5f, 0xd3, 0xda, 0x3e, 0x82, 0x44, 0x87, 0xf8, 0xdc, + 0xad, 0x64, 0x6e, 0x7d, 0xef, 0xd1, 0xdd, 0x71, 0x7c, 0x86, 0xe7, 0x9f, 0x78, 0xa9, 0xe4, 0xba, + 0xa0, 0x5c, 0x11, 0xc5, 0x04, 0x9f, 0xb3, 0x54, 0x12, 0x59, 0x63, 0x0c, 0x1d, 0x4e, 0x0a, 0xf7, + 0xec, 0x12, 0x13, 0xe3, 0x11, 0xf4, 0x2a, 0x2a, 0x4b, 0x26, 0xb8, 0x69, 0x3a, 0x48, 0x9a, 0xf4, + 0x43, 0x6b, 0x84, 0xc6, 0x17, 0x70, 0xb8, 0xe3, 0x75, 0xb9, 0x14, 0x2b, 0xba, 0x9f, 0xd3, 0xf4, + 0x27, 0xba, 0xd9, 0x04, 0xe8, 0x76, 0x13, 0xa0, 0xbb, 0x4d, 0x80, 0x7e, 0x6d, 0x03, 0xef, 0x76, + 0x1b, 0x78, 0xbf, 0xb7, 0x81, 0x07, 0x21, 0x13, 0x8f, 0x2f, 0x39, 0xf5, 0xcf, 0x4d, 0xb8, 0xd0, + 0xf0, 0x02, 0x7d, 0xbf, 0xc8, 0x76, 0x05, 0x4c, 0x7f, 0xd8, 0x3c, 0xa7, 0x4b, 0x25, 0x64, 0xbc, + 0xba, 0x22, 0x8a, 0xc4, 0x8c, 0x2b, 0x2a, 0x39, 0xc9, 0x63, 0x93, 0x19, 0xc7, 0x8c, 0xf2, 0x87, + 0x7f, 0x9d, 0x76, 0x0d, 0xf6, 0xfe, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x52, 0xfc, 0xa6, 0x58, + 0xff, 0x03, 0x00, 0x00, } func (m *AnyValue) Marshal() (dAtA []byte, err error) { diff --git a/model/internal/data/protogen/logs/v1/logs.pb.go b/pdata/internal/data/protogen/logs/v1/logs.pb.go similarity index 89% rename from model/internal/data/protogen/logs/v1/logs.pb.go rename to pdata/internal/data/protogen/logs/v1/logs.pb.go index 955fd9f6a66..9c41b0cd27c 100644 --- a/model/internal/data/protogen/logs/v1/logs.pb.go +++ b/pdata/internal/data/protogen/logs/v1/logs.pb.go @@ -13,9 +13,9 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - go_opentelemetry_io_collector_model_internal_data "go.opentelemetry.io/collector/model/internal/data" - v11 "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" - v1 "go.opentelemetry.io/collector/model/internal/data/protogen/resource/v1" + go_opentelemetry_io_collector_pdata_internal_data "go.opentelemetry.io/collector/pdata/internal/data" + v11 "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" + v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" ) // Reference imports to suppress errors if they are not otherwise used. @@ -503,12 +503,12 @@ type LogRecord struct { // the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes // is considered invalid. Can be set for logs that are part of request processing // and have an assigned trace id. [Optional]. - TraceId go_opentelemetry_io_collector_model_internal_data.TraceID `protobuf:"bytes,9,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/model/internal/data.TraceID" json:"trace_id"` + TraceId go_opentelemetry_io_collector_pdata_internal_data.TraceID `protobuf:"bytes,9,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.TraceID" json:"trace_id"` // A unique identifier for a span within a trace, assigned when the span // is created. The ID is an 8-byte array. An ID with all zeroes is considered // invalid. Can be set for logs that are part of a particular processing span. // If span_id is present trace_id SHOULD be also present. [Optional]. - SpanId go_opentelemetry_io_collector_model_internal_data.SpanID `protobuf:"bytes,10,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/model/internal/data.SpanID" json:"span_id"` + SpanId go_opentelemetry_io_collector_pdata_internal_data.SpanID `protobuf:"bytes,10,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.SpanID" json:"span_id"` } func (m *LogRecord) Reset() { *m = LogRecord{} } @@ -623,69 +623,69 @@ func init() { } var fileDescriptor_d1c030a3ec7e961e = []byte{ - // 980 bytes of a gzipped FileDescriptorProto + // 978 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x96, 0x41, 0x6f, 0x22, 0x37, - 0x14, 0xc7, 0x33, 0x6c, 0x08, 0xc1, 0x21, 0xac, 0xeb, 0x66, 0x93, 0x29, 0x69, 0x09, 0x4a, 0xdb, - 0x2d, 0x4d, 0x25, 0xd0, 0x02, 0xab, 0x6e, 0x7b, 0xea, 0x10, 0x86, 0x08, 0x85, 0x40, 0x64, 0x60, - 0xdb, 0x5d, 0x55, 0x1a, 0x0d, 0x8c, 0x4b, 0x47, 0x1a, 0xc6, 0xc8, 0x63, 0xa2, 0x70, 0xe9, 0xbd, - 0xb7, 0x9e, 0xfa, 0x7d, 0xaa, 0xf6, 0xb0, 0xc7, 0x3d, 0x56, 0x3d, 0xac, 0xaa, 0xe4, 0xd2, 0x4f, - 0xd1, 0x56, 0xf6, 0x0c, 0x14, 0xe8, 0x0c, 0x69, 0x2e, 0x3d, 0x61, 0xbf, 0xdf, 0x7b, 0x7f, 0xff, - 0x9f, 0xed, 0xb1, 0x00, 0x8f, 0xe9, 0x98, 0xb8, 0x9c, 0x38, 0x64, 0x44, 0x38, 0x9b, 0x16, 0xc7, - 0x8c, 0x72, 0x5a, 0x74, 0xe8, 0xd0, 0x2b, 0x5e, 0x3d, 0x91, 0xbf, 0x05, 0x19, 0x42, 0x87, 0x4b, - 0x79, 0x7e, 0xb0, 0x20, 0xf9, 0xd5, 0x93, 0xcc, 0xde, 0x90, 0x0e, 0xa9, 0x5f, 0x2a, 0x46, 0x3e, - 0xcd, 0x9c, 0x84, 0x49, 0x0f, 0xe8, 0x68, 0x44, 0x5d, 0x21, 0xee, 0x8f, 0x82, 0xdc, 0x42, 0x58, - 0x2e, 0x23, 0x1e, 0x9d, 0xb0, 0x01, 0x11, 0xd9, 0xb3, 0xb1, 0x9f, 0x7f, 0xfc, 0x12, 0x6c, 0x37, - 0xe9, 0xd0, 0xab, 0x99, 0xdc, 0x44, 0x2d, 0xb0, 0x3b, 0xa3, 0x86, 0x70, 0xa4, 0x2a, 0xb9, 0x07, - 0xf9, 0x9d, 0xd2, 0xc7, 0x85, 0x35, 0x96, 0x0b, 0x38, 0xa8, 0x10, 0x2a, 0x38, 0xc5, 0x16, 0x66, - 0xc7, 0x3f, 0xc5, 0x40, 0x6a, 0x11, 0xa3, 0x73, 0xb0, 0x3d, 0x4b, 0x50, 0x95, 0x9c, 0x12, 0xa9, - 0x3d, 0xf7, 0xb8, 0xa0, 0x5f, 0xdd, 0x7c, 0xf5, 0xe6, 0x68, 0x03, 0xcf, 0x05, 0x90, 0x0e, 0x80, - 0x37, 0xa0, 0xe3, 0xc0, 0x6a, 0x4c, 0x5a, 0x7d, 0xbc, 0xd6, 0x6a, 0x47, 0xa4, 0x4b, 0x9f, 0x49, - 0x6f, 0x36, 0x44, 0xdf, 0x81, 0x77, 0x6d, 0xd7, 0xe3, 0x6c, 0x32, 0x22, 0x2e, 0x37, 0xb9, 0x4d, - 0x5d, 0xc3, 0xb1, 0xfb, 0xcc, 0x64, 0x53, 0x5f, 0xf8, 0x8f, 0x84, 0x54, 0xfe, 0x74, 0xad, 0x72, - 0x63, 0x59, 0xa1, 0xe9, 0x0b, 0x08, 0xfd, 0x6a, 0x4c, 0x55, 0x70, 0xc6, 0x8e, 0xe4, 0xe8, 0x3d, - 0xd1, 0xc6, 0xb7, 0x64, 0x64, 0x1a, 0x13, 0xe6, 0xa8, 0x0f, 0x72, 0x4a, 0x3e, 0x29, 0xec, 0x89, - 0x48, 0x8f, 0x39, 0xc7, 0xbf, 0x28, 0x20, 0x39, 0xf7, 0x8d, 0xda, 0x20, 0x2e, 0x9d, 0x07, 0xbb, - 0x57, 0x0e, 0x35, 0x15, 0xdc, 0x87, 0x7f, 0xdb, 0x92, 0x3a, 0xc1, 0x3e, 0xfa, 0x3a, 0xe8, 0x0c, - 0xec, 0x38, 0x74, 0x68, 0x30, 0x32, 0xa0, 0xcc, 0xfa, 0x6f, 0xbb, 0xd8, 0xa4, 0x43, 0x2c, 0xd3, - 0x31, 0x70, 0x66, 0xc3, 0x3b, 0xdb, 0xf8, 0x53, 0x01, 0x99, 0xe8, 0x4d, 0x42, 0x1c, 0x1c, 0x44, - 0x1c, 0x42, 0xd0, 0xe9, 0xd3, 0xfb, 0x75, 0x1a, 0x68, 0x07, 0xbd, 0xee, 0x87, 0x6f, 0xff, 0xff, - 0xd5, 0xfc, 0xe7, 0x31, 0x55, 0x39, 0xfe, 0x31, 0x0e, 0x92, 0xf3, 0x62, 0xf4, 0x01, 0x48, 0x73, - 0x7b, 0x44, 0x8c, 0x89, 0x6b, 0x5f, 0x1b, 0xae, 0xe9, 0x52, 0xd9, 0xe6, 0x16, 0x4e, 0x89, 0x68, - 0xcf, 0xb5, 0xaf, 0x5b, 0xa6, 0x4b, 0xd1, 0x53, 0x70, 0x40, 0xfb, 0x1e, 0x61, 0x57, 0xc4, 0x32, - 0x56, 0xd2, 0x77, 0x64, 0xfa, 0xde, 0x0c, 0x77, 0x17, 0xcb, 0xba, 0xe0, 0xa1, 0x47, 0xae, 0x08, - 0xb3, 0xf9, 0xd4, 0x70, 0x27, 0xa3, 0x3e, 0x61, 0x6a, 0x2c, 0xa7, 0xe4, 0xd3, 0xa5, 0x4f, 0xd6, - 0x7f, 0x1d, 0x41, 0x4d, 0x4b, 0x96, 0xe0, 0xb4, 0xb7, 0x34, 0x47, 0xef, 0x83, 0xdd, 0xb9, 0x2a, - 0x27, 0xd7, 0x3c, 0x68, 0x33, 0x35, 0x0b, 0x76, 0xc9, 0x35, 0x47, 0xfb, 0x60, 0xd3, 0x35, 0x47, - 0x44, 0xdd, 0x14, 0x4c, 0x5e, 0x7d, 0x39, 0x47, 0x1a, 0xd8, 0xec, 0x53, 0x6b, 0xaa, 0xc6, 0xe5, - 0x61, 0x7e, 0x74, 0xc7, 0x61, 0x6a, 0xee, 0xf4, 0xb9, 0xe9, 0x4c, 0x66, 0x57, 0x55, 0x96, 0xa2, - 0x0b, 0x00, 0x4c, 0xce, 0x99, 0xdd, 0x9f, 0x70, 0xe2, 0xa9, 0x5b, 0xf2, 0xac, 0xee, 0x12, 0x3a, - 0x27, 0x4b, 0x42, 0x0b, 0x02, 0xe8, 0x19, 0x50, 0x2d, 0x46, 0xc7, 0x63, 0x62, 0x19, 0xff, 0x44, - 0x8d, 0x01, 0x9d, 0xb8, 0x5c, 0x4d, 0xe4, 0x94, 0xfc, 0x2e, 0xde, 0x0f, 0xb8, 0x36, 0xc7, 0xa7, - 0x82, 0xa2, 0x3d, 0x10, 0xff, 0xc6, 0x31, 0x87, 0x9e, 0xba, 0x9d, 0x53, 0xf2, 0x09, 0xec, 0x4f, - 0xd0, 0xd7, 0x60, 0x9b, 0x33, 0x73, 0x40, 0x0c, 0xdb, 0x52, 0x93, 0x39, 0x25, 0x9f, 0xaa, 0x6a, - 0x62, 0xcd, 0xdf, 0xde, 0x1c, 0x7d, 0x36, 0xa4, 0x2b, 0x36, 0x6d, 0xf1, 0x7a, 0x3b, 0x0e, 0x19, - 0x70, 0xca, 0x8a, 0x23, 0x6a, 0x11, 0xa7, 0x68, 0xbb, 0x9c, 0x30, 0xd7, 0x74, 0x8a, 0x96, 0xc9, - 0xcd, 0x42, 0x57, 0x28, 0x35, 0x6a, 0x38, 0x21, 0x25, 0x1b, 0x16, 0x7a, 0x01, 0x12, 0xde, 0xd8, - 0x74, 0x85, 0x38, 0x90, 0xe2, 0x5f, 0x04, 0xe2, 0xcf, 0xee, 0x2f, 0xde, 0x19, 0x9b, 0x6e, 0xa3, - 0x86, 0xb7, 0x84, 0x60, 0xc3, 0x3a, 0xf9, 0x39, 0x0e, 0xd2, 0xcb, 0x47, 0x8f, 0x8e, 0xc0, 0x61, - 0x47, 0x7f, 0xae, 0xe3, 0x46, 0xf7, 0x85, 0xd1, 0xea, 0x5d, 0x54, 0x75, 0x6c, 0xf4, 0x5a, 0x9d, - 0x4b, 0xfd, 0xb4, 0x51, 0x6f, 0xe8, 0x35, 0xb8, 0x81, 0xde, 0x01, 0x8f, 0x56, 0x13, 0xba, 0x58, - 0x3b, 0xd5, 0xa1, 0x82, 0x32, 0x60, 0x3f, 0x14, 0x95, 0x60, 0x2c, 0x92, 0x95, 0xe1, 0x83, 0x48, - 0x56, 0x81, 0x9b, 0x61, 0xcb, 0xd5, 0xf4, 0x6a, 0xef, 0x0c, 0xc6, 0xc3, 0xca, 0x24, 0x2a, 0xc1, - 0xad, 0x48, 0x56, 0x86, 0x89, 0x48, 0x56, 0x81, 0xdb, 0x48, 0x05, 0x7b, 0xab, 0xac, 0xd1, 0xaa, - 0xb7, 0x61, 0x32, 0xcc, 0x88, 0x20, 0x25, 0x08, 0xa2, 0x50, 0x19, 0xee, 0x44, 0xa1, 0x0a, 0x4c, - 0x85, 0x2d, 0xf5, 0xa5, 0x86, 0x5b, 0x70, 0x37, 0xac, 0x48, 0x90, 0x12, 0x4c, 0x47, 0xa1, 0x32, - 0x7c, 0x18, 0x85, 0x2a, 0x10, 0x86, 0x21, 0x1d, 0xe3, 0x36, 0x86, 0x6f, 0x85, 0x6d, 0x86, 0x44, - 0x25, 0x88, 0x22, 0x59, 0x19, 0xbe, 0x1d, 0xc9, 0x2a, 0x70, 0x2f, 0x6c, 0xb9, 0xba, 0xd6, 0xd5, - 0x9a, 0xf0, 0x51, 0x58, 0x99, 0x44, 0x25, 0xb8, 0x1f, 0xc9, 0xca, 0xf0, 0x20, 0x92, 0x55, 0xa0, - 0x7a, 0xf2, 0x15, 0x48, 0xcf, 0x5f, 0xd7, 0xba, 0xfc, 0x20, 0x8f, 0xc0, 0x61, 0xb3, 0x7d, 0x66, - 0x60, 0xfd, 0xb4, 0x8d, 0x6b, 0x46, 0xbd, 0xa9, 0x9d, 0xad, 0x5c, 0xe2, 0x0f, 0x41, 0x6e, 0x35, - 0x41, 0xde, 0x38, 0x39, 0xec, 0x18, 0x17, 0x5a, 0xe7, 0x1c, 0xfe, 0xa5, 0x54, 0xbf, 0x57, 0x5e, - 0xdd, 0x64, 0x95, 0xd7, 0x37, 0x59, 0xe5, 0xf7, 0x9b, 0xac, 0xf2, 0xc3, 0x6d, 0x76, 0xe3, 0xf5, - 0x6d, 0x76, 0xe3, 0xd7, 0xdb, 0xec, 0x06, 0xc8, 0xda, 0x74, 0xdd, 0x8b, 0x5a, 0x15, 0x0f, 0xbe, - 0x77, 0x29, 0x42, 0x97, 0xca, 0xcb, 0xea, 0xbd, 0xbf, 0x54, 0xff, 0xcf, 0xdb, 0x90, 0xb8, 0xb3, - 0xbf, 0x91, 0xfd, 0x2d, 0x19, 0x29, 0xff, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x19, 0xd4, 0xb0, - 0x6c, 0x0a, 0x00, 0x00, + 0x14, 0xc7, 0x33, 0x6c, 0x08, 0xc1, 0x21, 0xac, 0xeb, 0xb2, 0x64, 0x4a, 0x5a, 0x82, 0xd2, 0x76, + 0x4b, 0x53, 0x09, 0xb4, 0xc0, 0xaa, 0xdb, 0x9e, 0x3a, 0x84, 0x21, 0x42, 0x21, 0x10, 0x19, 0xd8, + 0x76, 0x57, 0x95, 0x46, 0x03, 0xb8, 0x74, 0xa4, 0x61, 0x8c, 0x3c, 0x26, 0x0a, 0x97, 0xde, 0x7b, + 0xeb, 0xa9, 0xdf, 0xa7, 0x6a, 0x0f, 0x7b, 0xdc, 0x63, 0xd5, 0xc3, 0xaa, 0x4a, 0x2e, 0xfd, 0x14, + 0x6d, 0x65, 0xcf, 0x40, 0x81, 0xce, 0x90, 0xe6, 0xd2, 0x13, 0xf6, 0xfb, 0xbd, 0xf7, 0xf7, 0xff, + 0xd9, 0x1e, 0x0b, 0xf0, 0x98, 0x4e, 0x88, 0xc3, 0x89, 0x4d, 0xc6, 0x84, 0xb3, 0x59, 0x71, 0xc2, + 0x28, 0xa7, 0x45, 0x9b, 0x8e, 0xdc, 0xe2, 0xd5, 0x13, 0xf9, 0x5b, 0x90, 0x21, 0x74, 0xb8, 0x92, + 0xe7, 0x05, 0x0b, 0x92, 0x5f, 0x3d, 0xc9, 0xa4, 0x46, 0x74, 0x44, 0xbd, 0x52, 0x31, 0xf2, 0x68, + 0xe6, 0x24, 0x48, 0x7a, 0x40, 0xc7, 0x63, 0xea, 0x08, 0x71, 0x6f, 0xe4, 0xe7, 0x16, 0x82, 0x72, + 0x19, 0x71, 0xe9, 0x94, 0x0d, 0x88, 0xc8, 0x9e, 0x8f, 0xbd, 0xfc, 0xe3, 0x97, 0x60, 0xb7, 0x49, + 0x47, 0x6e, 0xcd, 0xe4, 0x26, 0x6a, 0x81, 0xfd, 0x39, 0x35, 0x84, 0x23, 0x55, 0xc9, 0x3d, 0xc8, + 0xef, 0x95, 0x3e, 0x2e, 0x6c, 0xb0, 0x5c, 0xc0, 0x7e, 0x85, 0x50, 0xc1, 0x09, 0xb6, 0x34, 0x3b, + 0xfe, 0x29, 0x02, 0x12, 0xcb, 0x18, 0x9d, 0x83, 0xdd, 0x79, 0x82, 0xaa, 0xe4, 0x94, 0x50, 0xed, + 0x85, 0xc7, 0x25, 0xfd, 0xea, 0xf6, 0xab, 0x37, 0x47, 0x5b, 0x78, 0x21, 0x80, 0x74, 0x00, 0xdc, + 0x01, 0x9d, 0xf8, 0x56, 0x23, 0xd2, 0xea, 0xe3, 0x8d, 0x56, 0x3b, 0x22, 0x5d, 0xfa, 0x8c, 0xbb, + 0xf3, 0x21, 0xfa, 0x0e, 0xbc, 0x6b, 0x39, 0x2e, 0x67, 0xd3, 0x31, 0x71, 0xb8, 0xc9, 0x2d, 0xea, + 0x18, 0xb6, 0xd5, 0x67, 0x26, 0x9b, 0x79, 0xc2, 0x7f, 0xc4, 0xa4, 0xf2, 0xa7, 0x1b, 0x95, 0x1b, + 0xab, 0x0a, 0x4d, 0x4f, 0x40, 0xe8, 0x57, 0x23, 0xaa, 0x82, 0x33, 0x56, 0x28, 0x47, 0xef, 0x89, + 0x36, 0xbe, 0x25, 0x63, 0xd3, 0x98, 0x32, 0x5b, 0x7d, 0x90, 0x53, 0xf2, 0x71, 0x61, 0x4f, 0x44, + 0x7a, 0xcc, 0x3e, 0xfe, 0x45, 0x01, 0xf1, 0x85, 0x6f, 0xd4, 0x06, 0x51, 0xe9, 0xdc, 0xdf, 0xbd, + 0x72, 0xa0, 0x29, 0xff, 0x3e, 0xfc, 0xdb, 0x96, 0xd4, 0xf1, 0xf7, 0xd1, 0xd3, 0x41, 0x67, 0x60, + 0xcf, 0xa6, 0x23, 0x83, 0x91, 0x01, 0x65, 0xc3, 0xff, 0xb6, 0x8b, 0x4d, 0x3a, 0xc2, 0x32, 0x1d, + 0x03, 0x7b, 0x3e, 0xbc, 0xb3, 0x8d, 0x3f, 0x15, 0x90, 0x09, 0xdf, 0x24, 0xc4, 0xc1, 0x41, 0xc8, + 0x21, 0xf8, 0x9d, 0x3e, 0xbd, 0x5f, 0xa7, 0xbe, 0xb6, 0xdf, 0x6b, 0x3a, 0x78, 0xfb, 0xff, 0xaf, + 0xe6, 0x3f, 0x8f, 0xa8, 0xca, 0xf1, 0x8f, 0x51, 0x10, 0x5f, 0x14, 0xa3, 0x0f, 0x40, 0x92, 0x5b, + 0x63, 0x62, 0x4c, 0x1d, 0xeb, 0xda, 0x70, 0x4c, 0x87, 0xca, 0x36, 0x77, 0x70, 0x42, 0x44, 0x7b, + 0x8e, 0x75, 0xdd, 0x32, 0x1d, 0x8a, 0x9e, 0x82, 0x03, 0xda, 0x77, 0x09, 0xbb, 0x22, 0x43, 0x63, + 0x2d, 0x7d, 0x4f, 0xa6, 0xa7, 0xe6, 0xb8, 0xbb, 0x5c, 0xd6, 0x05, 0x0f, 0x5d, 0x72, 0x45, 0x98, + 0xc5, 0x67, 0x86, 0x33, 0x1d, 0xf7, 0x09, 0x53, 0x23, 0x39, 0x25, 0x9f, 0x2c, 0x7d, 0xb2, 0xf9, + 0xeb, 0xf0, 0x6b, 0x5a, 0xb2, 0x04, 0x27, 0xdd, 0x95, 0x39, 0x7a, 0x1f, 0xec, 0x2f, 0x54, 0x39, + 0xb9, 0xe6, 0x7e, 0x9b, 0x89, 0x79, 0xb0, 0x4b, 0xae, 0x39, 0x4a, 0x83, 0x6d, 0xc7, 0x1c, 0x13, + 0x75, 0x5b, 0x30, 0x79, 0xf5, 0xe5, 0x1c, 0x69, 0x60, 0xbb, 0x4f, 0x87, 0x33, 0x35, 0x2a, 0x0f, + 0xf3, 0xa3, 0x3b, 0x0e, 0x53, 0x73, 0x66, 0xcf, 0x4d, 0x7b, 0x3a, 0xbf, 0xaa, 0xb2, 0x14, 0x5d, + 0x00, 0x60, 0x72, 0xce, 0xac, 0xfe, 0x94, 0x13, 0x57, 0xdd, 0x91, 0x67, 0x75, 0x97, 0xd0, 0x39, + 0x59, 0x11, 0x5a, 0x12, 0x40, 0xcf, 0x80, 0x3a, 0x64, 0x74, 0x32, 0x21, 0x43, 0xe3, 0x9f, 0xa8, + 0x31, 0xa0, 0x53, 0x87, 0xab, 0xb1, 0x9c, 0x92, 0xdf, 0xc7, 0x69, 0x9f, 0x6b, 0x0b, 0x7c, 0x2a, + 0x28, 0x4a, 0x81, 0xe8, 0x37, 0xb6, 0x39, 0x72, 0xd5, 0xdd, 0x9c, 0x92, 0x8f, 0x61, 0x6f, 0x82, + 0xbe, 0x06, 0xbb, 0x9c, 0x99, 0x03, 0x62, 0x58, 0x43, 0x35, 0x9e, 0x53, 0xf2, 0x89, 0xaa, 0x26, + 0xd6, 0xfc, 0xed, 0xcd, 0xd1, 0x67, 0x23, 0xba, 0x66, 0xd3, 0x12, 0xaf, 0xb7, 0x6d, 0x93, 0x01, + 0xa7, 0xac, 0x38, 0x19, 0x9a, 0xdc, 0x2c, 0x5a, 0x0e, 0x27, 0xcc, 0x31, 0xed, 0xa2, 0x98, 0x15, + 0xba, 0x42, 0xa9, 0x51, 0xc3, 0x31, 0x29, 0xd9, 0x18, 0xa2, 0x17, 0x20, 0xe6, 0x4e, 0x4c, 0x47, + 0x88, 0x03, 0x29, 0xfe, 0x85, 0x2f, 0xfe, 0xec, 0xfe, 0xe2, 0x9d, 0x89, 0xe9, 0x34, 0x6a, 0x78, + 0x47, 0x08, 0x36, 0x86, 0x27, 0x3f, 0x47, 0x41, 0x72, 0xf5, 0xe8, 0xd1, 0x11, 0x38, 0xec, 0xe8, + 0xcf, 0x75, 0xdc, 0xe8, 0xbe, 0x30, 0x5a, 0xbd, 0x8b, 0xaa, 0x8e, 0x8d, 0x5e, 0xab, 0x73, 0xa9, + 0x9f, 0x36, 0xea, 0x0d, 0xbd, 0x06, 0xb7, 0xd0, 0x3b, 0xe0, 0xd1, 0x7a, 0x42, 0x17, 0x6b, 0xa7, + 0x3a, 0x54, 0x50, 0x06, 0xa4, 0x03, 0x51, 0x09, 0x46, 0x42, 0x59, 0x19, 0x3e, 0x08, 0x65, 0x15, + 0xb8, 0x1d, 0xb4, 0x5c, 0x4d, 0xaf, 0xf6, 0xce, 0x60, 0x34, 0xa8, 0x4c, 0xa2, 0x12, 0xdc, 0x09, + 0x65, 0x65, 0x18, 0x0b, 0x65, 0x15, 0xb8, 0x8b, 0x54, 0x90, 0x5a, 0x67, 0x8d, 0x56, 0xbd, 0x0d, + 0xe3, 0x41, 0x46, 0x04, 0x29, 0x41, 0x10, 0x86, 0xca, 0x70, 0x2f, 0x0c, 0x55, 0x60, 0x22, 0x68, + 0xa9, 0x2f, 0x35, 0xdc, 0x82, 0xfb, 0x41, 0x45, 0x82, 0x94, 0x60, 0x32, 0x0c, 0x95, 0xe1, 0xc3, + 0x30, 0x54, 0x81, 0x30, 0x08, 0xe9, 0x18, 0xb7, 0x31, 0x7c, 0x2b, 0x68, 0x33, 0x24, 0x2a, 0x41, + 0x14, 0xca, 0xca, 0xf0, 0xed, 0x50, 0x56, 0x81, 0xa9, 0xa0, 0xe5, 0xea, 0x5a, 0x57, 0x6b, 0xc2, + 0x47, 0x41, 0x65, 0x12, 0x95, 0x60, 0x3a, 0x94, 0x95, 0xe1, 0x41, 0x28, 0xab, 0x40, 0xf5, 0xe4, + 0x2b, 0x90, 0x5c, 0xbc, 0xae, 0x75, 0xf9, 0x41, 0x1e, 0x81, 0xc3, 0x66, 0xfb, 0xcc, 0xc0, 0xfa, + 0x69, 0x1b, 0xd7, 0x8c, 0x7a, 0x53, 0x3b, 0x5b, 0xbb, 0xc4, 0x1f, 0x82, 0xdc, 0x7a, 0x82, 0xbc, + 0x71, 0x72, 0xd8, 0x31, 0x2e, 0xb4, 0xce, 0x39, 0xfc, 0x4b, 0xa9, 0x7e, 0xaf, 0xbc, 0xba, 0xc9, + 0x2a, 0xaf, 0x6f, 0xb2, 0xca, 0xef, 0x37, 0x59, 0xe5, 0x87, 0xdb, 0xec, 0xd6, 0xeb, 0xdb, 0xec, + 0xd6, 0xaf, 0xb7, 0xd9, 0x2d, 0x90, 0xb5, 0xe8, 0xa6, 0x17, 0xb5, 0x2a, 0x1e, 0x7c, 0xf7, 0x52, + 0x84, 0x2e, 0x95, 0x97, 0xd5, 0x7b, 0x7f, 0xa9, 0xde, 0x9f, 0xb7, 0x11, 0x71, 0xe6, 0x7f, 0x23, + 0xfb, 0x3b, 0x32, 0x52, 0xfe, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xac, 0x0d, 0x5c, 0x58, 0x6c, 0x0a, + 0x00, 0x00, } func (m *LogsData) Marshal() (dAtA []byte, err error) { diff --git a/model/internal/data/protogen/metrics/v1/metrics.pb.go b/pdata/internal/data/protogen/metrics/v1/metrics.pb.go similarity index 98% rename from model/internal/data/protogen/metrics/v1/metrics.pb.go rename to pdata/internal/data/protogen/metrics/v1/metrics.pb.go index 75c4c762d1a..a71050963bf 100644 --- a/model/internal/data/protogen/metrics/v1/metrics.pb.go +++ b/pdata/internal/data/protogen/metrics/v1/metrics.pb.go @@ -13,9 +13,9 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - go_opentelemetry_io_collector_model_internal_data "go.opentelemetry.io/collector/model/internal/data" - v11 "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" - v1 "go.opentelemetry.io/collector/model/internal/data/protogen/resource/v1" + go_opentelemetry_io_collector_pdata_internal_data "go.opentelemetry.io/collector/pdata/internal/data" + v11 "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" + v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" ) // Reference imports to suppress errors if they are not otherwise used. @@ -1774,11 +1774,11 @@ type Exemplar struct { // (Optional) Span ID of the exemplar trace. // span_id may be missing if the measurement is not recorded inside a trace // or if the trace is not sampled. - SpanId go_opentelemetry_io_collector_model_internal_data.SpanID `protobuf:"bytes,4,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/model/internal/data.SpanID" json:"span_id"` + SpanId go_opentelemetry_io_collector_pdata_internal_data.SpanID `protobuf:"bytes,4,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.SpanID" json:"span_id"` // (Optional) Trace ID of the exemplar trace. // trace_id may be missing if the measurement is not recorded inside a trace // or if the trace is not sampled. - TraceId go_opentelemetry_io_collector_model_internal_data.TraceID `protobuf:"bytes,5,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/model/internal/data.TraceID" json:"trace_id"` + TraceId go_opentelemetry_io_collector_pdata_internal_data.TraceID `protobuf:"bytes,5,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.TraceID" json:"trace_id"` } func (m *Exemplar) Reset() { *m = Exemplar{} } @@ -1900,7 +1900,7 @@ func init() { } var fileDescriptor_3c3112f9fa006917 = []byte{ - // 1491 bytes of a gzipped FileDescriptorProto + // 1490 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x5b, 0x6f, 0x1b, 0x45, 0x14, 0xf6, 0xfa, 0xee, 0xe3, 0x5c, 0xdc, 0x21, 0xa4, 0x56, 0xa4, 0xa4, 0xae, 0x0b, 0x4d, 0xa8, 0x2a, 0x9b, 0xa6, 0xdc, 0x51, 0xa5, 0xda, 0xb1, 0x93, 0x38, 0xcd, 0xad, 0x13, 0xa7, 0x52, 0xab, @@ -1979,22 +1979,22 @@ var fileDescriptor_3c3112f9fa006917 = []byte{ 0xeb, 0x85, 0x02, 0xa6, 0x52, 0xa7, 0x6e, 0xc7, 0xcb, 0x10, 0x1e, 0x76, 0x6d, 0x46, 0xce, 0x7e, 0x6d, 0xde, 0x87, 0x84, 0xd3, 0x26, 0x96, 0xce, 0x9a, 0xaa, 0x80, 0x23, 0xe5, 0xdb, 0xd2, 0x91, 0x5f, 0x5f, 0x5c, 0xfa, 0xac, 0xc5, 0xfb, 0x7c, 0x67, 0xbc, 0xd8, 0xe0, 0x86, 0x41, 0x1b, 0x82, - 0xdb, 0x45, 0x93, 0x37, 0xa9, 0x51, 0x64, 0x96, 0xa0, 0xb6, 0x45, 0x8c, 0xa2, 0x7c, 0x7a, 0x14, - 0xb6, 0xda, 0xc4, 0xaa, 0x55, 0x70, 0x5c, 0x12, 0xd6, 0x9a, 0xe8, 0x21, 0x24, 0x85, 0x4d, 0x1a, - 0x54, 0x72, 0xc7, 0x14, 0x77, 0xc9, 0xe7, 0xfe, 0xfc, 0xfc, 0xdc, 0x75, 0xc9, 0x54, 0xab, 0xe0, - 0x84, 0xa2, 0xac, 0x35, 0xfb, 0xee, 0xe2, 0x6b, 0xdf, 0x6a, 0x30, 0x39, 0xf8, 0x05, 0x86, 0x66, - 0xe1, 0x4a, 0x69, 0x69, 0x09, 0x57, 0x97, 0x4a, 0xf5, 0xda, 0xc6, 0xba, 0x5e, 0xaf, 0xae, 0x6d, - 0x6e, 0xe0, 0xd2, 0x6a, 0xad, 0x7e, 0x5f, 0xdf, 0x5e, 0xdf, 0xda, 0xac, 0x2e, 0xd4, 0x16, 0x6b, - 0xd5, 0x4a, 0x26, 0x84, 0x2e, 0xc3, 0xf4, 0x49, 0xc0, 0x4a, 0x75, 0xb5, 0x5e, 0xca, 0x68, 0xe8, - 0x2a, 0xe4, 0x4f, 0x82, 0x2c, 0x6c, 0xaf, 0x6d, 0xaf, 0x96, 0xea, 0xb5, 0x7b, 0xd5, 0x4c, 0xf8, - 0xda, 0x97, 0x30, 0x76, 0xd4, 0xaf, 0x8b, 0x6a, 0xf0, 0x8c, 0x42, 0x6a, 0x71, 0xb5, 0xb4, 0xa4, - 0xaf, 0x6f, 0xac, 0x57, 0x33, 0x21, 0x34, 0x05, 0x93, 0xfe, 0x56, 0xc7, 0xd5, 0x85, 0x0d, 0x5c, - 0xa9, 0x56, 0xf4, 0x7b, 0xa5, 0xd5, 0xed, 0x6a, 0x46, 0x2b, 0x7f, 0xa7, 0x3d, 0x3b, 0x9c, 0xd1, - 0x9e, 0x1f, 0xce, 0x68, 0xbf, 0x1f, 0xce, 0x68, 0x4f, 0x5f, 0xce, 0x84, 0x9e, 0xbf, 0x9c, 0x09, - 0xfd, 0xf2, 0x72, 0x26, 0x04, 0x97, 0x19, 0x1f, 0x72, 0x5c, 0xca, 0x23, 0xfe, 0xff, 0x04, 0x9b, - 0xf2, 0xc3, 0xa6, 0xf6, 0xa0, 0x7a, 0xee, 0x64, 0x7b, 0x7f, 0x99, 0xb5, 0xa8, 0xd5, 0xf5, 0x2f, - 0xde, 0x4e, 0x5c, 0x09, 0x6f, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x53, 0xf8, 0x9e, 0x5b, 0xee, - 0x13, 0x00, 0x00, + 0xdb, 0xc5, 0xb6, 0x7c, 0x6c, 0x14, 0x99, 0x25, 0xa8, 0x6d, 0x11, 0xa3, 0x28, 0x77, 0x85, 0xad, + 0x36, 0xb1, 0x6a, 0x15, 0x1c, 0x97, 0x84, 0xb5, 0x26, 0x7a, 0x08, 0x49, 0x61, 0x93, 0x06, 0x95, + 0xdc, 0x31, 0xc5, 0x5d, 0xf2, 0xb9, 0x3f, 0x3f, 0x3f, 0x77, 0x5d, 0x32, 0xd5, 0x2a, 0x38, 0xa1, + 0x28, 0x6b, 0xcd, 0xbe, 0xbb, 0xf8, 0xda, 0xb7, 0x1a, 0x4c, 0x0e, 0x7e, 0x81, 0xa1, 0x59, 0xb8, + 0x52, 0x5a, 0x5a, 0xc2, 0xd5, 0xa5, 0x52, 0xbd, 0xb6, 0xb1, 0xae, 0xd7, 0xab, 0x6b, 0x9b, 0x1b, + 0xb8, 0xb4, 0x5a, 0xab, 0xdf, 0xd7, 0xb7, 0xd7, 0xb7, 0x36, 0xab, 0x0b, 0xb5, 0xc5, 0x5a, 0xb5, + 0x92, 0x09, 0xa1, 0xcb, 0x30, 0x7d, 0x12, 0xb0, 0x52, 0x5d, 0xad, 0x97, 0x32, 0x1a, 0xba, 0x0a, + 0xf9, 0x93, 0x20, 0x0b, 0xdb, 0x6b, 0xdb, 0xab, 0xa5, 0x7a, 0xed, 0x5e, 0x35, 0x13, 0xbe, 0xf6, + 0x25, 0x8c, 0x1d, 0xf5, 0xeb, 0xa2, 0x1a, 0x3c, 0xa3, 0x90, 0x5a, 0x5c, 0x2d, 0x2d, 0xe9, 0xeb, + 0x1b, 0xeb, 0xd5, 0x4c, 0x08, 0x4d, 0xc1, 0xa4, 0xbf, 0xd5, 0x71, 0x75, 0x61, 0x03, 0x57, 0xaa, + 0x15, 0xfd, 0x5e, 0x69, 0x75, 0xbb, 0x9a, 0xd1, 0xca, 0xdf, 0x69, 0xcf, 0x0e, 0x67, 0xb4, 0xe7, + 0x87, 0x33, 0xda, 0xef, 0x87, 0x33, 0xda, 0xd3, 0x97, 0x33, 0xa1, 0xe7, 0x2f, 0x67, 0x42, 0xbf, + 0xbc, 0x9c, 0x09, 0xc1, 0x65, 0xc6, 0x87, 0x1c, 0x97, 0xf2, 0x88, 0xff, 0x3f, 0xc1, 0xa6, 0xfc, + 0xb0, 0xa9, 0x3d, 0xa8, 0x9e, 0x3b, 0xd9, 0xde, 0x5f, 0x66, 0x2d, 0x6a, 0x75, 0xfd, 0x8b, 0xb7, + 0x13, 0x57, 0xc2, 0x9b, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xed, 0xa7, 0xdb, 0xbe, 0xee, 0x13, + 0x00, 0x00, } func (m *MetricsData) Marshal() (dAtA []byte, err error) { diff --git a/model/internal/data/protogen/resource/v1/resource.pb.go b/pdata/internal/data/protogen/resource/v1/resource.pb.go similarity index 96% rename from model/internal/data/protogen/resource/v1/resource.pb.go rename to pdata/internal/data/protogen/resource/v1/resource.pb.go index ab79e514c39..7463b483e4d 100644 --- a/model/internal/data/protogen/resource/v1/resource.pb.go +++ b/pdata/internal/data/protogen/resource/v1/resource.pb.go @@ -12,7 +12,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - v1 "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" + v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) // Reference imports to suppress errors if they are not otherwise used. @@ -93,7 +93,7 @@ func init() { } var fileDescriptor_446f73eacf88f3f5 = []byte{ - // 286 bytes of a gzipped FileDescriptorProto + // 284 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xcb, 0x2f, 0x48, 0xcd, 0x2b, 0x49, 0xcd, 0x49, 0xcd, 0x4d, 0x2d, 0x29, 0xaa, 0xd4, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x2f, 0x4a, 0x2d, 0xce, 0x2f, 0x2d, 0x4a, 0x4e, 0xd5, 0x2f, 0x33, 0x84, 0xb3, 0xf5, 0xc0, 0x52, @@ -109,9 +109,9 @@ var fileDescriptor_446f73eacf88f3f5 = []byte{ 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x81, 0x4b, 0x29, 0x33, 0x5f, 0x8f, 0x40, 0xb0, 0x38, 0xf1, 0xc2, 0x7c, 0x14, 0x00, 0x92, 0x0a, 0x60, 0x8c, 0x72, 0x4b, 0x47, 0xd7, 0x94, 0x09, 0x0a, 0x91, 0x9c, 0x9c, 0xd4, 0xe4, 0x92, 0xfc, 0x22, - 0xfd, 0xdc, 0xfc, 0x94, 0xd4, 0x1c, 0xfd, 0xcc, 0xbc, 0x92, 0xd4, 0xa2, 0xbc, 0xc4, 0x1c, 0xfd, - 0x94, 0xc4, 0x92, 0x44, 0x48, 0xa8, 0xa5, 0xa7, 0xe6, 0x21, 0xc7, 0x4f, 0x12, 0x1b, 0x58, 0xd4, - 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xf3, 0xe1, 0x10, 0x43, 0xc9, 0x01, 0x00, 0x00, + 0xfd, 0x82, 0x94, 0xc4, 0x92, 0x44, 0xfd, 0xcc, 0xbc, 0x92, 0xd4, 0xa2, 0xbc, 0xc4, 0x1c, 0x7d, + 0x30, 0x0f, 0x6c, 0x6a, 0x7a, 0x6a, 0x1e, 0x72, 0xfc, 0x24, 0xb1, 0x81, 0x45, 0x8d, 0x01, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x9e, 0x31, 0xb9, 0x5c, 0xc9, 0x01, 0x00, 0x00, } func (m *Resource) Marshal() (dAtA []byte, err error) { diff --git a/model/internal/data/protogen/trace/v1/trace.pb.go b/pdata/internal/data/protogen/trace/v1/trace.pb.go similarity index 94% rename from model/internal/data/protogen/trace/v1/trace.pb.go rename to pdata/internal/data/protogen/trace/v1/trace.pb.go index 1f6b61cbbc5..8f41776db5a 100644 --- a/model/internal/data/protogen/trace/v1/trace.pb.go +++ b/pdata/internal/data/protogen/trace/v1/trace.pb.go @@ -13,9 +13,9 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - go_opentelemetry_io_collector_model_internal_data "go.opentelemetry.io/collector/model/internal/data" - v11 "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" - v1 "go.opentelemetry.io/collector/model/internal/data/protogen/resource/v1" + go_opentelemetry_io_collector_pdata_internal_data "go.opentelemetry.io/collector/pdata/internal/data" + v11 "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" + v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" ) // Reference imports to suppress errors if they are not otherwise used. @@ -432,7 +432,7 @@ type Span struct { // random trace_id if empty or invalid trace_id was received. // // This field is required. - TraceId go_opentelemetry_io_collector_model_internal_data.TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/model/internal/data.TraceID" json:"trace_id"` + TraceId go_opentelemetry_io_collector_pdata_internal_data.TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.TraceID" json:"trace_id"` // A unique identifier for a span within a trace, assigned when the span // is created. The ID is an 8-byte array. An ID with all zeroes is considered // invalid. @@ -441,14 +441,14 @@ type Span struct { // random span_id if empty or invalid span_id was received. // // This field is required. - SpanId go_opentelemetry_io_collector_model_internal_data.SpanID `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/model/internal/data.SpanID" json:"span_id"` + SpanId go_opentelemetry_io_collector_pdata_internal_data.SpanID `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.SpanID" json:"span_id"` // trace_state conveys information about request position in multiple distributed tracing graphs. // It is a trace_state in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header // See also https://github.com/w3c/distributed-tracing for more details about this field. TraceState string `protobuf:"bytes,3,opt,name=trace_state,json=traceState,proto3" json:"trace_state,omitempty"` // The `span_id` of this span's parent span. If this is a root span, then this // field must be empty. The ID is an 8-byte array. - ParentSpanId go_opentelemetry_io_collector_model_internal_data.SpanID `protobuf:"bytes,4,opt,name=parent_span_id,json=parentSpanId,proto3,customtype=go.opentelemetry.io/collector/model/internal/data.SpanID" json:"parent_span_id"` + ParentSpanId go_opentelemetry_io_collector_pdata_internal_data.SpanID `protobuf:"bytes,4,opt,name=parent_span_id,json=parentSpanId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.SpanID" json:"parent_span_id"` // A description of the span's operation. // // For example, the name can be a qualified method name or a file name @@ -714,9 +714,9 @@ func (m *Span_Event) GetDroppedAttributesCount() uint32 { type Span_Link struct { // A unique identifier of a trace that this linked span is part of. The ID is a // 16-byte array. - TraceId go_opentelemetry_io_collector_model_internal_data.TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/model/internal/data.TraceID" json:"trace_id"` + TraceId go_opentelemetry_io_collector_pdata_internal_data.TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.TraceID" json:"trace_id"` // A unique identifier for the linked span. The ID is an 8-byte array. - SpanId go_opentelemetry_io_collector_model_internal_data.SpanID `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/model/internal/data.SpanID" json:"span_id"` + SpanId go_opentelemetry_io_collector_pdata_internal_data.SpanID `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.SpanID" json:"span_id"` // The trace_state associated with the link. TraceState string `protobuf:"bytes,3,opt,name=trace_state,json=traceState,proto3" json:"trace_state,omitempty"` // attributes is a collection of attribute key/value pairs on the link. @@ -856,7 +856,7 @@ func init() { } var fileDescriptor_5c407ac9c675a601 = []byte{ - // 1041 bytes of a gzipped FileDescriptorProto + // 1040 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0xcf, 0x6f, 0x1b, 0x45, 0x14, 0xf6, 0x38, 0x6b, 0x27, 0x79, 0x49, 0xdc, 0xcd, 0x90, 0x86, 0x25, 0xa5, 0x8e, 0x65, 0x55, 0xc2, 0x50, 0xc9, 0xa6, 0xa9, 0x90, 0x52, 0x24, 0x44, 0x63, 0x7b, 0x91, 0x96, 0xa4, 0x76, 0x34, @@ -884,45 +884,44 @@ var fileDescriptor_5c407ac9c675a601 = []byte{ 0x0c, 0xe6, 0xf0, 0xf6, 0x2b, 0xb4, 0xd7, 0xbd, 0x7d, 0x74, 0xbd, 0xde, 0x34, 0xb8, 0xee, 0x6e, 0xfd, 0x6a, 0xc9, 0x6f, 0xac, 0xdd, 0x8f, 0xb3, 0x16, 0x2a, 0x7f, 0xb7, 0x02, 0x86, 0x48, 0xc1, 0x5f, 0xc1, 0x82, 0xc4, 0x70, 0x03, 0x5f, 0x36, 0xb3, 0x5c, 0xdf, 0x11, 0xac, 0xfe, 0x78, 0xb9, - 0xf9, 0xe8, 0x30, 0xbc, 0x54, 0x32, 0x10, 0x47, 0x7b, 0x30, 0xa0, 0x7d, 0x1e, 0x46, 0xb5, 0x61, - 0xe8, 0xd3, 0x41, 0x2d, 0x60, 0x9c, 0x46, 0xcc, 0x1b, 0xd4, 0x7c, 0x8f, 0x7b, 0x55, 0x79, 0x5c, - 0x9d, 0x26, 0x99, 0x97, 0x90, 0x8e, 0x8f, 0xbf, 0x80, 0x79, 0x41, 0x49, 0x80, 0x67, 0x25, 0xf8, - 0x63, 0x0d, 0xbe, 0x7d, 0x7d, 0x70, 0x41, 0xd7, 0x69, 0x92, 0xbc, 0x00, 0x74, 0x7c, 0xbc, 0x09, - 0x4b, 0x8a, 0x78, 0xcc, 0x3d, 0x4e, 0x75, 0x97, 0x20, 0x4d, 0x1d, 0x61, 0xc1, 0xdf, 0x40, 0x61, - 0xe4, 0x45, 0x94, 0x71, 0x37, 0xa1, 0x60, 0xfc, 0x4f, 0x14, 0x96, 0x15, 0x6e, 0x47, 0x11, 0xc1, - 0x60, 0x30, 0x6f, 0x48, 0xad, 0x9c, 0x64, 0x20, 0xd7, 0xf8, 0x53, 0x30, 0x8e, 0x02, 0xe6, 0x5b, - 0xf9, 0x12, 0xaa, 0x14, 0x66, 0x5d, 0x51, 0x02, 0x47, 0xfe, 0xec, 0x06, 0xcc, 0x27, 0x32, 0x11, - 0xd7, 0x60, 0x2d, 0xe6, 0x5e, 0xc4, 0x5d, 0x1e, 0x0c, 0xa9, 0x3b, 0x66, 0xc1, 0x33, 0x97, 0x79, - 0x2c, 0xb4, 0xe6, 0x4b, 0xa8, 0x92, 0x27, 0xab, 0xd2, 0xd7, 0x0d, 0x86, 0xb4, 0xc7, 0x82, 0x67, - 0x2d, 0x8f, 0x85, 0xf8, 0x3e, 0x60, 0xca, 0xfc, 0xcb, 0xe1, 0x0b, 0x32, 0xfc, 0x16, 0x65, 0x7e, - 0x2a, 0xf8, 0x09, 0x80, 0xc7, 0x79, 0x14, 0x1c, 0x8c, 0x39, 0x8d, 0xad, 0x45, 0x39, 0x5f, 0xef, - 0xcd, 0x98, 0xe1, 0x5d, 0x7a, 0xf2, 0xd4, 0x1b, 0x8c, 0x93, 0x33, 0x39, 0x01, 0x80, 0xb7, 0xc1, - 0xf2, 0xa3, 0x70, 0x34, 0xa2, 0xbe, 0x7b, 0x61, 0x75, 0xfb, 0xe1, 0x98, 0x71, 0x0b, 0x4a, 0xa8, - 0xb2, 0x42, 0xd6, 0xb5, 0x7f, 0xe7, 0xdc, 0xdd, 0x10, 0x5e, 0xfc, 0x18, 0xf2, 0xf4, 0x98, 0x32, - 0x1e, 0x5b, 0x4b, 0xaf, 0x75, 0x39, 0x0a, 0xa5, 0x6c, 0x91, 0x40, 0x74, 0x1e, 0xfe, 0x10, 0xd6, - 0x92, 0xda, 0xca, 0xa2, 0xeb, 0x2e, 0xcb, 0xba, 0x58, 0xfb, 0x64, 0x8e, 0xae, 0xf9, 0x09, 0xe4, - 0x06, 0x01, 0x3b, 0x8a, 0xad, 0x95, 0x29, 0x7d, 0xa7, 0x4b, 0xee, 0x05, 0xec, 0x88, 0xa8, 0x2c, - 0x5c, 0x85, 0xb7, 0x92, 0x82, 0xd2, 0xa0, 0xeb, 0x15, 0x64, 0xbd, 0x55, 0xed, 0x12, 0x09, 0xba, - 0x5c, 0x1d, 0xf2, 0x62, 0x42, 0xc7, 0xb1, 0x75, 0x4b, 0xde, 0x15, 0xf7, 0x66, 0xd4, 0x93, 0xb1, - 0x5a, 0x64, 0x9d, 0xb9, 0xf1, 0x2b, 0x82, 0x9c, 0x6c, 0x01, 0xdf, 0x83, 0xc2, 0xa5, 0x2d, 0x46, - 0x72, 0x8b, 0x97, 0xf9, 0xe4, 0xfe, 0x26, 0x23, 0x99, 0x9d, 0x18, 0xc9, 0xf4, 0x9e, 0xcf, 0xdd, - 0xe4, 0x9e, 0x1b, 0xd3, 0xf6, 0x7c, 0xe3, 0xef, 0x2c, 0x18, 0x42, 0x9f, 0x37, 0xf8, 0xea, 0x49, - 0x6b, 0x6d, 0xdc, 0xa4, 0xd6, 0xb9, 0x69, 0x5a, 0x97, 0x7f, 0x42, 0xb0, 0x90, 0xdc, 0x2c, 0xf8, - 0x1d, 0xb8, 0xdd, 0xd9, 0xdf, 0x69, 0xb9, 0xbb, 0x4e, 0xab, 0xe9, 0xf6, 0x5a, 0x9d, 0x7d, 0xbb, - 0xe1, 0x7c, 0xe6, 0xd8, 0x4d, 0x33, 0x83, 0xd7, 0x01, 0x5f, 0xb8, 0x9c, 0x56, 0xd7, 0x26, 0xad, - 0x9d, 0x3d, 0x13, 0xe1, 0x35, 0x30, 0x2f, 0xec, 0x1d, 0x9b, 0x3c, 0xb5, 0x89, 0x99, 0x4d, 0x5b, - 0x1b, 0x7b, 0x8e, 0xdd, 0xea, 0x9a, 0x73, 0x69, 0x8c, 0x7d, 0xd2, 0x6e, 0xf6, 0x1a, 0x36, 0x31, - 0x8d, 0xb4, 0xbd, 0xd1, 0x6e, 0x75, 0x7a, 0x4f, 0x6c, 0x62, 0xe6, 0xca, 0xbf, 0x20, 0xc8, 0xab, - 0x69, 0xc7, 0x16, 0xcc, 0x0f, 0x69, 0x1c, 0x7b, 0x87, 0xc9, 0xc8, 0x26, 0x9f, 0xb8, 0x01, 0x46, - 0x3f, 0xf4, 0x95, 0xc6, 0x85, 0xad, 0xda, 0xeb, 0x9c, 0x1d, 0xfd, 0xd7, 0x08, 0x7d, 0x4a, 0x64, - 0x72, 0xb9, 0x05, 0x70, 0x61, 0xc3, 0xb7, 0x61, 0xb5, 0xd3, 0xdd, 0xe9, 0xf6, 0x3a, 0x6e, 0xa3, - 0xdd, 0xb4, 0x85, 0x10, 0x76, 0xd7, 0xcc, 0x60, 0x0c, 0x85, 0x49, 0x73, 0x7b, 0xd7, 0x44, 0x97, - 0x43, 0x6d, 0x42, 0xda, 0xc4, 0xcc, 0x7e, 0x6e, 0x2c, 0x20, 0x33, 0x5b, 0xff, 0x01, 0x3d, 0x3f, - 0x2d, 0xa2, 0x17, 0xa7, 0x45, 0xf4, 0xe7, 0x69, 0x11, 0xfd, 0x78, 0x56, 0xcc, 0xbc, 0x38, 0x2b, - 0x66, 0x7e, 0x3f, 0x2b, 0x66, 0x60, 0x33, 0x08, 0xa7, 0x32, 0xad, 0xab, 0x87, 0xed, 0xbe, 0x30, - 0xee, 0xa3, 0x2f, 0x1b, 0xd7, 0x9e, 0x48, 0xf5, 0x78, 0x3e, 0xa4, 0xec, 0xfc, 0x25, 0x7f, 0x90, - 0x97, 0xa6, 0x87, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x8c, 0xfa, 0x97, 0x07, 0xf0, 0x0b, 0x00, - 0x00, + 0xf9, 0xe8, 0x30, 0xbc, 0x54, 0x32, 0x10, 0x47, 0x7b, 0x30, 0xa0, 0x7d, 0x1e, 0x46, 0xb5, 0x91, + 0xef, 0x71, 0xaf, 0x16, 0x30, 0x4e, 0x23, 0xe6, 0x0d, 0x6a, 0xe2, 0xab, 0x2a, 0x8f, 0xab, 0xd3, + 0x24, 0xf3, 0x12, 0xd2, 0xf1, 0xf1, 0x17, 0x30, 0x2f, 0x28, 0x09, 0xf0, 0xac, 0x04, 0x7f, 0xac, + 0xc1, 0xb7, 0xaf, 0x0f, 0x2e, 0xe8, 0x3a, 0x4d, 0x92, 0x17, 0x80, 0x8e, 0x8f, 0x37, 0x61, 0x49, + 0x11, 0x8f, 0xb9, 0xc7, 0xa9, 0xee, 0x12, 0xa4, 0xa9, 0x23, 0x2c, 0xf8, 0x1b, 0x28, 0x8c, 0xbc, + 0x88, 0x32, 0xee, 0x26, 0x14, 0x8c, 0xff, 0x89, 0xc2, 0xb2, 0xc2, 0xed, 0x28, 0x22, 0x18, 0x0c, + 0xe6, 0x0d, 0xa9, 0x95, 0x93, 0x0c, 0xe4, 0x1a, 0x7f, 0x0a, 0xc6, 0x51, 0xc0, 0x7c, 0x2b, 0x5f, + 0x42, 0x95, 0xc2, 0xac, 0x2b, 0x4a, 0xe0, 0xc8, 0x9f, 0xdd, 0x80, 0xf9, 0x44, 0x26, 0xe2, 0x1a, + 0xac, 0xc5, 0xdc, 0x8b, 0xb8, 0xcb, 0x83, 0x21, 0x75, 0xc7, 0x2c, 0x78, 0xe6, 0x32, 0x8f, 0x85, + 0xd6, 0x7c, 0x09, 0x55, 0xf2, 0x64, 0x55, 0xfa, 0xba, 0xc1, 0x90, 0xf6, 0x58, 0xf0, 0xac, 0xe5, + 0xb1, 0x10, 0xdf, 0x07, 0x4c, 0x99, 0x7f, 0x39, 0x7c, 0x41, 0x86, 0xdf, 0xa2, 0xcc, 0x4f, 0x05, + 0x3f, 0x01, 0xf0, 0x38, 0x8f, 0x82, 0x83, 0x31, 0xa7, 0xb1, 0xb5, 0x28, 0xe7, 0xeb, 0xbd, 0x19, + 0x33, 0xbc, 0x4b, 0x4f, 0x9e, 0x7a, 0x83, 0x71, 0x72, 0x26, 0x27, 0x00, 0xf0, 0x36, 0x58, 0x7e, + 0x14, 0x8e, 0x46, 0xd4, 0x77, 0x2f, 0xac, 0x6e, 0x3f, 0x1c, 0x33, 0x6e, 0x41, 0x09, 0x55, 0x56, + 0xc8, 0xba, 0xf6, 0xef, 0x9c, 0xbb, 0x1b, 0xc2, 0x8b, 0x1f, 0x43, 0x9e, 0x1e, 0x53, 0xc6, 0x63, + 0x6b, 0xe9, 0xb5, 0x2e, 0x47, 0xa1, 0x94, 0x2d, 0x12, 0x88, 0xce, 0xc3, 0x1f, 0xc2, 0x5a, 0x52, + 0x5b, 0x59, 0x74, 0xdd, 0x65, 0x59, 0x17, 0x6b, 0x9f, 0xcc, 0xd1, 0x35, 0x3f, 0x81, 0xdc, 0x20, + 0x60, 0x47, 0xb1, 0xb5, 0x32, 0xa5, 0xef, 0x74, 0xc9, 0xbd, 0x80, 0x1d, 0x11, 0x95, 0x85, 0xab, + 0xf0, 0x56, 0x52, 0x50, 0x1a, 0x74, 0xbd, 0x82, 0xac, 0xb7, 0xaa, 0x5d, 0x22, 0x41, 0x97, 0xab, + 0x43, 0x5e, 0x4c, 0xe8, 0x38, 0xb6, 0x6e, 0xc9, 0xbb, 0xe2, 0xde, 0x8c, 0x7a, 0x32, 0x56, 0x8b, + 0xac, 0x33, 0x37, 0x7e, 0x45, 0x90, 0x93, 0x2d, 0xe0, 0x7b, 0x50, 0xb8, 0xb4, 0xc5, 0x48, 0x6e, + 0xf1, 0x32, 0x9f, 0xdc, 0xdf, 0x64, 0x24, 0xb3, 0x13, 0x23, 0x99, 0xde, 0xf3, 0xb9, 0x9b, 0xdc, + 0x73, 0x63, 0xda, 0x9e, 0x6f, 0xfc, 0x9d, 0x05, 0x43, 0xe8, 0xf3, 0x06, 0x5f, 0x3d, 0x69, 0xad, + 0x8d, 0x9b, 0xd4, 0x3a, 0x37, 0x4d, 0xeb, 0xf2, 0x4f, 0x08, 0x16, 0x92, 0x9b, 0x05, 0xbf, 0x03, + 0xb7, 0x3b, 0xfb, 0x3b, 0x2d, 0x77, 0xd7, 0x69, 0x35, 0xdd, 0x5e, 0xab, 0xb3, 0x6f, 0x37, 0x9c, + 0xcf, 0x1c, 0xbb, 0x69, 0x66, 0xf0, 0x3a, 0xe0, 0x0b, 0x97, 0xd3, 0xea, 0xda, 0xa4, 0xb5, 0xb3, + 0x67, 0x22, 0xbc, 0x06, 0xe6, 0x85, 0xbd, 0x63, 0x93, 0xa7, 0x36, 0x31, 0xb3, 0x69, 0x6b, 0x63, + 0xcf, 0xb1, 0x5b, 0x5d, 0x73, 0x2e, 0x8d, 0xb1, 0x4f, 0xda, 0xcd, 0x5e, 0xc3, 0x26, 0xa6, 0x91, + 0xb6, 0x37, 0xda, 0xad, 0x4e, 0xef, 0x89, 0x4d, 0xcc, 0x5c, 0xf9, 0x17, 0x04, 0x79, 0x35, 0xed, + 0xd8, 0x82, 0xf9, 0x21, 0x8d, 0x63, 0xef, 0x30, 0x19, 0xd9, 0xe4, 0x13, 0x37, 0xc0, 0xe8, 0x87, + 0xbe, 0xd2, 0xb8, 0xb0, 0x55, 0x7b, 0x9d, 0xb3, 0xa3, 0xff, 0x1a, 0xa1, 0x4f, 0x89, 0x4c, 0x2e, + 0xb7, 0x00, 0x2e, 0x6c, 0xf8, 0x36, 0xac, 0x76, 0xba, 0x3b, 0xdd, 0x5e, 0xc7, 0x6d, 0xb4, 0x9b, + 0xb6, 0x10, 0xc2, 0xee, 0x9a, 0x19, 0x8c, 0xa1, 0x30, 0x69, 0x6e, 0xef, 0x9a, 0xe8, 0x72, 0xa8, + 0x4d, 0x48, 0x9b, 0x98, 0xd9, 0xcf, 0x8d, 0x05, 0x64, 0x66, 0xeb, 0x3f, 0xa0, 0xe7, 0xa7, 0x45, + 0xf4, 0xe2, 0xb4, 0x88, 0xfe, 0x3c, 0x2d, 0xa2, 0x1f, 0xcf, 0x8a, 0x99, 0x17, 0x67, 0xc5, 0xcc, + 0xef, 0x67, 0xc5, 0x0c, 0x6c, 0x06, 0xe1, 0x54, 0xa6, 0x75, 0xf5, 0xb0, 0xdd, 0x17, 0xc6, 0x7d, + 0xf4, 0x65, 0xe3, 0xda, 0x13, 0xa9, 0x1e, 0xcf, 0x87, 0x94, 0x9d, 0xbf, 0xe4, 0x0f, 0xf2, 0xd2, + 0xf4, 0xf0, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x56, 0xa5, 0xef, 0x0c, 0xf0, 0x0b, 0x00, 0x00, } func (m *TracesData) Marshal() (dAtA []byte, err error) { diff --git a/model/internal/data/spanid.go b/pdata/internal/data/spanid.go similarity index 97% rename from model/internal/data/spanid.go rename to pdata/internal/data/spanid.go index 9d28664b677..09063199c7a 100644 --- a/model/internal/data/spanid.go +++ b/pdata/internal/data/spanid.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package data // import "go.opentelemetry.io/collector/model/internal/data" +package data // import "go.opentelemetry.io/collector/pdata/internal/data" import ( "encoding/hex" diff --git a/model/internal/data/spanid_test.go b/pdata/internal/data/spanid_test.go similarity index 100% rename from model/internal/data/spanid_test.go rename to pdata/internal/data/spanid_test.go diff --git a/model/internal/data/traceid.go b/pdata/internal/data/traceid.go similarity index 97% rename from model/internal/data/traceid.go rename to pdata/internal/data/traceid.go index bd6e79f592e..b0730a0c4a4 100644 --- a/model/internal/data/traceid.go +++ b/pdata/internal/data/traceid.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package data // import "go.opentelemetry.io/collector/model/internal/data" +package data // import "go.opentelemetry.io/collector/pdata/internal/data" import ( "encoding/hex" diff --git a/model/internal/data/traceid_test.go b/pdata/internal/data/traceid_test.go similarity index 100% rename from model/internal/data/traceid_test.go rename to pdata/internal/data/traceid_test.go diff --git a/model/internal/generated_common.go b/pdata/internal/generated_common.go similarity index 98% rename from model/internal/generated_common.go rename to pdata/internal/generated_common.go index 2dbc2c9c61c..7b194835130 100644 --- a/model/internal/generated_common.go +++ b/pdata/internal/generated_common.go @@ -18,7 +18,7 @@ package internal import ( - otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" + otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) // Scope is a message representing the instrumentation library information. diff --git a/model/internal/generated_common_test.go b/pdata/internal/generated_common_test.go similarity index 98% rename from model/internal/generated_common_test.go rename to pdata/internal/generated_common_test.go index 806443d2f2d..4e2879d0592 100644 --- a/model/internal/generated_common_test.go +++ b/pdata/internal/generated_common_test.go @@ -22,7 +22,7 @@ import ( "github.com/stretchr/testify/assert" - otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" + otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) func TestInstrumentationScope_MoveTo(t *testing.T) { diff --git a/model/internal/generated_log.go b/pdata/internal/generated_plog.go similarity index 99% rename from model/internal/generated_log.go rename to pdata/internal/generated_plog.go index 927a9d6484f..982eb0a6b11 100644 --- a/model/internal/generated_log.go +++ b/pdata/internal/generated_plog.go @@ -20,7 +20,7 @@ package internal import ( "sort" - otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" + otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) // ResourceLogsSlice logically represents a slice of ResourceLogs. diff --git a/model/internal/generated_log_test.go b/pdata/internal/generated_plog_test.go similarity index 99% rename from model/internal/generated_log_test.go rename to pdata/internal/generated_plog_test.go index 51acc8930ad..e3c3dd90e46 100644 --- a/model/internal/generated_log_test.go +++ b/pdata/internal/generated_plog_test.go @@ -22,7 +22,7 @@ import ( "github.com/stretchr/testify/assert" - otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" + otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) func TestResourceLogsSlice(t *testing.T) { diff --git a/model/internal/generated_metrics.go b/pdata/internal/generated_pmetric.go similarity index 99% rename from model/internal/generated_metrics.go rename to pdata/internal/generated_pmetric.go index 80b3240e313..fc29fd28b93 100644 --- a/model/internal/generated_metrics.go +++ b/pdata/internal/generated_pmetric.go @@ -20,7 +20,7 @@ package internal import ( "sort" - otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" + otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // ResourceMetricsSlice logically represents a slice of ResourceMetrics. diff --git a/model/internal/generated_metrics_test.go b/pdata/internal/generated_pmetric_test.go similarity index 99% rename from model/internal/generated_metrics_test.go rename to pdata/internal/generated_pmetric_test.go index 4779cb9e64f..2ec18f93e63 100644 --- a/model/internal/generated_metrics_test.go +++ b/pdata/internal/generated_pmetric_test.go @@ -22,7 +22,7 @@ import ( "github.com/stretchr/testify/assert" - otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" + otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestResourceMetricsSlice(t *testing.T) { diff --git a/model/internal/generated_trace.go b/pdata/internal/generated_ptrace.go similarity index 99% rename from model/internal/generated_trace.go rename to pdata/internal/generated_ptrace.go index 1320c6ba696..dc40b5e131a 100644 --- a/model/internal/generated_trace.go +++ b/pdata/internal/generated_ptrace.go @@ -20,7 +20,7 @@ package internal import ( "sort" - otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" + otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) // ResourceSpansSlice logically represents a slice of ResourceSpans. diff --git a/model/internal/generated_trace_test.go b/pdata/internal/generated_ptrace_test.go similarity index 99% rename from model/internal/generated_trace_test.go rename to pdata/internal/generated_ptrace_test.go index 13e5d6da822..8b38491308e 100644 --- a/model/internal/generated_trace_test.go +++ b/pdata/internal/generated_ptrace_test.go @@ -22,7 +22,7 @@ import ( "github.com/stretchr/testify/assert" - otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" + otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) func TestResourceSpansSlice(t *testing.T) { diff --git a/model/internal/generated_resource.go b/pdata/internal/generated_resource.go similarity index 97% rename from model/internal/generated_resource.go rename to pdata/internal/generated_resource.go index 3d01e730221..cc4bb64f058 100644 --- a/model/internal/generated_resource.go +++ b/pdata/internal/generated_resource.go @@ -18,7 +18,7 @@ package internal import ( - otlpresource "go.opentelemetry.io/collector/model/internal/data/protogen/resource/v1" + otlpresource "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" ) // Resource is a message representing the resource information. diff --git a/model/internal/generated_resource_test.go b/pdata/internal/generated_resource_test.go similarity index 100% rename from model/internal/generated_resource_test.go rename to pdata/internal/generated_resource_test.go diff --git a/model/internal/logs.go b/pdata/internal/logs.go similarity index 97% rename from model/internal/logs.go rename to pdata/internal/logs.go index 6539afb0437..dda886d3c1f 100644 --- a/model/internal/logs.go +++ b/pdata/internal/logs.go @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal" import ( - otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" + otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) // LogsMarshaler marshals pdata.Logs into bytes. diff --git a/model/internal/logs_test.go b/pdata/internal/logs_test.go similarity index 98% rename from model/internal/logs_test.go rename to pdata/internal/logs_test.go index 13ecf530b4c..d4b9ed3ea06 100644 --- a/model/internal/logs_test.go +++ b/pdata/internal/logs_test.go @@ -22,7 +22,7 @@ import ( goproto "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/emptypb" - otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" + otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) func TestLogRecordCount(t *testing.T) { diff --git a/model/internal/metrics.go b/pdata/internal/metrics.go similarity index 95% rename from model/internal/metrics.go rename to pdata/internal/metrics.go index 6d6d53f177e..e8c728131ed 100644 --- a/model/internal/metrics.go +++ b/pdata/internal/metrics.go @@ -12,23 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal" import ( - otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" + otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) -// MetricsMarshaler marshals pdata.Metrics into bytes. +// MetricsMarshaler marshals pmetric.Metrics into bytes. type MetricsMarshaler interface { - // MarshalMetrics the given pdata.Metrics into bytes. + // MarshalMetrics the given pmetric.Metrics into bytes. // If the error is not nil, the returned bytes slice cannot be used. MarshalMetrics(md Metrics) ([]byte, error) } -// MetricsUnmarshaler unmarshalls bytes into pdata.Metrics. +// MetricsUnmarshaler unmarshalls bytes into pmetric.Metrics. type MetricsUnmarshaler interface { - // UnmarshalMetrics the given bytes into pdata.Metrics. - // If the error is not nil, the returned pdata.Metrics cannot be used. + // UnmarshalMetrics the given bytes into pmetric.Metrics. + // If the error is not nil, the returned pmetric.Metrics cannot be used. UnmarshalMetrics(buf []byte) (Metrics, error) } diff --git a/model/internal/metrics_test.go b/pdata/internal/metrics_test.go similarity index 99% rename from model/internal/metrics_test.go rename to pdata/internal/metrics_test.go index 50e12d99d7f..e657079f24e 100644 --- a/model/internal/metrics_test.go +++ b/pdata/internal/metrics_test.go @@ -22,9 +22,9 @@ import ( goproto "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/emptypb" - otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" - otlpresource "go.opentelemetry.io/collector/model/internal/data/protogen/resource/v1" + otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" + otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" + otlpresource "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" ) const ( diff --git a/model/internal/otlp/logs.go b/pdata/internal/otlp/logs.go similarity index 90% rename from model/internal/otlp/logs.go rename to pdata/internal/otlp/logs.go index 57d0ca3a8dc..68c76f839f1 100644 --- a/model/internal/otlp/logs.go +++ b/pdata/internal/otlp/logs.go @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -package otlp // import "go.opentelemetry.io/collector/model/internal/otlp" +package otlp // import "go.opentelemetry.io/collector/pdata/internal/otlp" import ( - otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" - otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" + otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" + otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) // InstrumentationLibraryLogsToScope implements the translation of resource logs data diff --git a/model/internal/otlp/metrics.go b/pdata/internal/otlp/metrics.go similarity index 90% rename from model/internal/otlp/metrics.go rename to pdata/internal/otlp/metrics.go index 56fa21ea206..4ce73350b9b 100644 --- a/model/internal/otlp/metrics.go +++ b/pdata/internal/otlp/metrics.go @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -package otlp // import "go.opentelemetry.io/collector/model/internal/otlp" +package otlp // import "go.opentelemetry.io/collector/pdata/internal/otlp" import ( - otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" + otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" + otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // InstrumentationLibraryMetricsToScope implements the translation of resource metrics data diff --git a/model/internal/otlp/traces.go b/pdata/internal/otlp/traces.go similarity index 90% rename from model/internal/otlp/traces.go rename to pdata/internal/otlp/traces.go index 3ffb2db38c8..1a364b57793 100644 --- a/model/internal/otlp/traces.go +++ b/pdata/internal/otlp/traces.go @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -package otlp // import "go.opentelemetry.io/collector/model/internal/otlp" +package otlp // import "go.opentelemetry.io/collector/pdata/internal/otlp" import ( - otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" - otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" + otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" + otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) // InstrumentationLibraryToScope implements the translation of resource span data diff --git a/model/internal/otlp_wrapper.go b/pdata/internal/otlp_wrapper.go similarity index 86% rename from model/internal/otlp_wrapper.go rename to pdata/internal/otlp_wrapper.go index 90df208981c..151acabad93 100644 --- a/model/internal/otlp_wrapper.go +++ b/pdata/internal/otlp_wrapper.go @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal" import ( - otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" - otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" - otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" + otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" + otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" + otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) // MetricsToOtlp internal helper to convert Metrics to protobuf representation. diff --git a/model/internal/spanid.go b/pdata/internal/spanid.go similarity index 92% rename from model/internal/spanid.go rename to pdata/internal/spanid.go index c651a921092..91eda5767e6 100644 --- a/model/internal/spanid.go +++ b/pdata/internal/spanid.go @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal" import ( - "go.opentelemetry.io/collector/model/internal/data" + "go.opentelemetry.io/collector/pdata/internal/data" ) // SpanID is an alias of OTLP SpanID data type. diff --git a/model/internal/spanid_test.go b/pdata/internal/spanid_test.go similarity index 100% rename from model/internal/spanid_test.go rename to pdata/internal/spanid_test.go diff --git a/model/internal/timestamp.go b/pdata/internal/timestamp.go similarity index 94% rename from model/internal/timestamp.go rename to pdata/internal/timestamp.go index fd5c91a91ae..01597c3649c 100644 --- a/model/internal/timestamp.go +++ b/pdata/internal/timestamp.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal" import ( "time" diff --git a/model/internal/timestamp_test.go b/pdata/internal/timestamp_test.go similarity index 100% rename from model/internal/timestamp_test.go rename to pdata/internal/timestamp_test.go diff --git a/model/internal/traceid.go b/pdata/internal/traceid.go similarity index 92% rename from model/internal/traceid.go rename to pdata/internal/traceid.go index ae5b10e2024..4736f979b1b 100644 --- a/model/internal/traceid.go +++ b/pdata/internal/traceid.go @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal" import ( - "go.opentelemetry.io/collector/model/internal/data" + "go.opentelemetry.io/collector/pdata/internal/data" ) // TraceID is an alias of OTLP TraceID data type. diff --git a/model/internal/traceid_test.go b/pdata/internal/traceid_test.go similarity index 100% rename from model/internal/traceid_test.go rename to pdata/internal/traceid_test.go diff --git a/model/internal/traces.go b/pdata/internal/traces.go similarity index 97% rename from model/internal/traces.go rename to pdata/internal/traces.go index a5e682548f1..3ed69e3581a 100644 --- a/model/internal/traces.go +++ b/pdata/internal/traces.go @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -package internal // import "go.opentelemetry.io/collector/model/internal" +package internal // import "go.opentelemetry.io/collector/pdata/internal" import ( - otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" + otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) // TracesMarshaler marshals pdata.Traces into bytes. diff --git a/model/internal/traces_test.go b/pdata/internal/traces_test.go similarity index 98% rename from model/internal/traces_test.go rename to pdata/internal/traces_test.go index a3495b186ac..53fc515c685 100644 --- a/model/internal/traces_test.go +++ b/pdata/internal/traces_test.go @@ -22,7 +22,7 @@ import ( goproto "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/emptypb" - otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" + otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) func TestSpanCount(t *testing.T) { diff --git a/pdata/pcommon/alias.go b/pdata/pcommon/alias.go new file mode 100644 index 00000000000..9a7259b29b0 --- /dev/null +++ b/pdata/pcommon/alias.go @@ -0,0 +1,58 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pcommon // import "go.opentelemetry.io/collector/pdata/pcommon" + +// This file contains aliases to data structures that are common for all +// signal types, such as timestamps, attributes, etc. + +import "go.opentelemetry.io/collector/pdata/internal" + +// ValueType is an alias for internal.ValueType type. +type ValueType = internal.ValueType + +const ( + ValueTypeEmpty = internal.ValueTypeEmpty + ValueTypeString = internal.ValueTypeString + ValueTypeInt = internal.ValueTypeInt + ValueTypeDouble = internal.ValueTypeDouble + ValueTypeBool = internal.ValueTypeBool + ValueTypeMap = internal.ValueTypeMap + ValueTypeSlice = internal.ValueTypeSlice + ValueTypeBytes = internal.ValueTypeBytes +) + +// Value is an alias for internal.Value struct. +type Value = internal.Value + +// Aliases for functions to create internal.Value. +var ( + NewValueEmpty = internal.NewValueEmpty + NewValueString = internal.NewValueString + NewValueInt = internal.NewValueInt + NewValueDouble = internal.NewValueDouble + NewValueBool = internal.NewValueBool + NewValueMap = internal.NewValueMap + NewValueSlice = internal.NewValueSlice + NewValueBytes = internal.NewValueBytes +) + +// Map is an alias for internal.Map struct. +type Map = internal.Map + +// Aliases for functions to create internal.Map. +var ( + NewMap = internal.NewMap + NewMapFromRaw = internal.NewMapFromRaw +) diff --git a/pdata/pcommon/generated_common_alias.go b/pdata/pcommon/generated_common_alias.go new file mode 100644 index 00000000000..7ede4c76408 --- /dev/null +++ b/pdata/pcommon/generated_common_alias.go @@ -0,0 +1,32 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package pcommon + +import "go.opentelemetry.io/collector/pdata/internal" + +// InstrumentationScope is an alias for internal.InstrumentationScope struct. +type InstrumentationScope = internal.InstrumentationScope + +// NewInstrumentationScope is an alias for a function to create a new empty InstrumentationScope. +var NewInstrumentationScope = internal.NewInstrumentationScope + +// Slice is an alias for internal.Slice struct. +type Slice = internal.Slice + +// NewSlice is an alias for a function to create Slice. +var NewSlice = internal.NewSlice diff --git a/pdata/pcommon/generated_resource_alias.go b/pdata/pcommon/generated_resource_alias.go new file mode 100644 index 00000000000..c061ee8b9f0 --- /dev/null +++ b/pdata/pcommon/generated_resource_alias.go @@ -0,0 +1,26 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package pcommon + +import "go.opentelemetry.io/collector/pdata/internal" + +// Resource is an alias for internal.Resource struct. +type Resource = internal.Resource + +// NewResource is an alias for a function to create a new empty Resource. +var NewResource = internal.NewResource diff --git a/pdata/pcommon/spanid_alias.go b/pdata/pcommon/spanid_alias.go new file mode 100644 index 00000000000..b71d21e8183 --- /dev/null +++ b/pdata/pcommon/spanid_alias.go @@ -0,0 +1,26 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pcommon // import "go.opentelemetry.io/collector/pdata/pcommon" + +import "go.opentelemetry.io/collector/pdata/internal" + +// SpanID is an alias for internal.SpanID struct. +type SpanID = internal.SpanID + +// InvalidSpanID is an alias for internal.InvalidSpanID function. +var InvalidSpanID = internal.InvalidSpanID + +// NewSpanID is an alias for a function to create new SpanID. +var NewSpanID = internal.NewSpanID diff --git a/pdata/pcommon/timestamp_alias.go b/pdata/pcommon/timestamp_alias.go new file mode 100644 index 00000000000..00540f546c7 --- /dev/null +++ b/pdata/pcommon/timestamp_alias.go @@ -0,0 +1,23 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pcommon // import "go.opentelemetry.io/collector/pdata/pcommon" + +import "go.opentelemetry.io/collector/pdata/internal" + +// Timestamp is a an alias for internal.Timestamp. +type Timestamp = internal.Timestamp + +// NewTimestampFromTime is an alias for internal.NewTimestampFromTime function. +var NewTimestampFromTime = internal.NewTimestampFromTime diff --git a/pdata/pcommon/traceid_alias.go b/pdata/pcommon/traceid_alias.go new file mode 100644 index 00000000000..43862477ad8 --- /dev/null +++ b/pdata/pcommon/traceid_alias.go @@ -0,0 +1,26 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pcommon // import "go.opentelemetry.io/collector/pdata/pcommon" + +import "go.opentelemetry.io/collector/pdata/internal" + +// TraceID is an alias for internal.TraceID struct. +type TraceID = internal.TraceID + +// InvalidTraceID is an alias for internal.InvalidTraceID function. +var InvalidTraceID = internal.InvalidTraceID + +// NewTraceID is an alias for a function to create new TraceID. +var NewTraceID = internal.NewTraceID diff --git a/pdata/plog/alias.go b/pdata/plog/alias.go new file mode 100644 index 00000000000..9e69c72ae7e --- /dev/null +++ b/pdata/plog/alias.go @@ -0,0 +1,65 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package plog // import "go.opentelemetry.io/collector/pdata/plog" + +// This file contains aliases for logs data structures. + +import "go.opentelemetry.io/collector/pdata/internal" + +// Marshaler is an alias for internal.LogsMarshaler interface. +type Marshaler = internal.LogsMarshaler + +// Unmarshaler is an alias for internal.LogsUnmarshaler interface. +type Unmarshaler = internal.LogsUnmarshaler + +// Sizer is an alias for internal.LogsSizer interface. +type Sizer = internal.LogsSizer + +// Logs is an alias for internal.Logs struct. +type Logs = internal.Logs + +// New is an alias for a function to create new Logs. +var NewLogs = internal.NewLogs + +// SeverityNumber is an alias for internal.SeverityNumber type. +type SeverityNumber = internal.SeverityNumber + +const ( + SeverityNumberUNDEFINED = internal.SeverityNumberUNDEFINED + SeverityNumberTRACE = internal.SeverityNumberTRACE + SeverityNumberTRACE2 = internal.SeverityNumberTRACE2 + SeverityNumberTRACE3 = internal.SeverityNumberTRACE3 + SeverityNumberTRACE4 = internal.SeverityNumberTRACE4 + SeverityNumberDEBUG = internal.SeverityNumberDEBUG + SeverityNumberDEBUG2 = internal.SeverityNumberDEBUG2 + SeverityNumberDEBUG3 = internal.SeverityNumberDEBUG3 + SeverityNumberDEBUG4 = internal.SeverityNumberDEBUG4 + SeverityNumberINFO = internal.SeverityNumberINFO + SeverityNumberINFO2 = internal.SeverityNumberINFO2 + SeverityNumberINFO3 = internal.SeverityNumberINFO3 + SeverityNumberINFO4 = internal.SeverityNumberINFO4 + SeverityNumberWARN = internal.SeverityNumberWARN + SeverityNumberWARN2 = internal.SeverityNumberWARN2 + SeverityNumberWARN3 = internal.SeverityNumberWARN3 + SeverityNumberWARN4 = internal.SeverityNumberWARN4 + SeverityNumberERROR = internal.SeverityNumberERROR + SeverityNumberERROR2 = internal.SeverityNumberERROR2 + SeverityNumberERROR3 = internal.SeverityNumberERROR3 + SeverityNumberERROR4 = internal.SeverityNumberERROR4 + SeverityNumberFATAL = internal.SeverityNumberFATAL + SeverityNumberFATAL2 = internal.SeverityNumberFATAL2 + SeverityNumberFATAL3 = internal.SeverityNumberFATAL3 + SeverityNumberFATAL4 = internal.SeverityNumberFATAL4 +) diff --git a/model/pdata/generated_log_alias.go b/pdata/plog/generated_alias.go similarity index 96% rename from model/pdata/generated_log_alias.go rename to pdata/plog/generated_alias.go index 1952ae3068c..ed3a336a71c 100644 --- a/model/pdata/generated_log_alias.go +++ b/pdata/plog/generated_alias.go @@ -15,9 +15,9 @@ // Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. // To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". -package pdata +package plog -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/internal" // ResourceLogsSlice is an alias for internal.ResourceLogsSlice struct. type ResourceLogsSlice = internal.ResourceLogsSlice diff --git a/pdata/plog/json.go b/pdata/plog/json.go new file mode 100644 index 00000000000..e4f63fc45b4 --- /dev/null +++ b/pdata/plog/json.go @@ -0,0 +1,66 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package plog // import "go.opentelemetry.io/collector/pdata/plog" + +import ( + "bytes" + + "github.com/gogo/protobuf/jsonpb" + + "go.opentelemetry.io/collector/pdata/internal" + otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" + "go.opentelemetry.io/collector/pdata/internal/otlp" +) + +// NewJSONMarshaler returns a Marshaler. Marshals to OTLP json bytes. +func NewJSONMarshaler() Marshaler { + return newJSONMarshaler() +} + +type jsonMarshaler struct { + delegate jsonpb.Marshaler +} + +func newJSONMarshaler() *jsonMarshaler { + return &jsonMarshaler{delegate: jsonpb.Marshaler{}} +} + +func (e *jsonMarshaler) MarshalLogs(ld Logs) ([]byte, error) { + buf := bytes.Buffer{} + err := e.delegate.Marshal(&buf, internal.LogsToOtlp(ld)) + return buf.Bytes(), err +} + +type jsonUnmarshaler struct { + delegate jsonpb.Unmarshaler +} + +// NewJSONUnmarshaler returns a model.Unmarshaler. Unmarshals from OTLP json bytes. +func NewJSONUnmarshaler() Unmarshaler { + return newJSONUnmarshaler() +} + +func newJSONUnmarshaler() *jsonUnmarshaler { + return &jsonUnmarshaler{delegate: jsonpb.Unmarshaler{}} +} + +func (d *jsonUnmarshaler) UnmarshalLogs(buf []byte) (Logs, error) { + ld := &otlplogs.LogsData{} + if err := d.delegate.Unmarshal(bytes.NewReader(buf), ld); err != nil { + return Logs{}, err + } + otlp.InstrumentationLibraryLogsToScope(ld.ResourceLogs) + return internal.LogsFromOtlp(ld), nil +} diff --git a/pdata/plog/json_test.go b/pdata/plog/json_test.go new file mode 100644 index 00000000000..a3f53d427d5 --- /dev/null +++ b/pdata/plog/json_test.go @@ -0,0 +1,54 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package plog + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +var logsOTLP = func() Logs { + ld := NewLogs() + rl := ld.ResourceLogs().AppendEmpty() + rl.Resource().Attributes().UpsertString("host.name", "testHost") + il := rl.ScopeLogs().AppendEmpty() + il.Scope().SetName("name") + il.Scope().SetVersion("version") + il.LogRecords().AppendEmpty().SetSeverityText("Error") + return ld +}() + +var logsJSON = `{"resourceLogs":[{"resource":{"attributes":[{"key":"host.name","value":{"stringValue":"testHost"}}]},"scopeLogs":[{"scope":{"name":"name","version":"version"},"logRecords":[{"severityText":"Error","body":{},"traceId":"","spanId":""}]}]}]}` + +func TestLogsJSON(t *testing.T) { + encoder := NewJSONMarshaler() + jsonBuf, err := encoder.MarshalLogs(logsOTLP) + assert.NoError(t, err) + + decoder := NewJSONUnmarshaler() + var got interface{} + got, err = decoder.UnmarshalLogs(jsonBuf) + assert.NoError(t, err) + + assert.EqualValues(t, logsOTLP, got) +} + +func TestLogsJSON_Marshal(t *testing.T) { + encoder := NewJSONMarshaler() + jsonBuf, err := encoder.MarshalLogs(logsOTLP) + assert.NoError(t, err) + assert.Equal(t, logsJSON, string(jsonBuf)) +} diff --git a/pdata/plog/pb.go b/pdata/plog/pb.go new file mode 100644 index 00000000000..01adfa350e2 --- /dev/null +++ b/pdata/plog/pb.go @@ -0,0 +1,59 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package plog // import "go.opentelemetry.io/collector/pdata/plog" + +import ( + "go.opentelemetry.io/collector/pdata/internal" + otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" +) + +// NewProtoMarshaler returns a Marshaler. Marshals to OTLP binary protobuf bytes. +func NewProtoMarshaler() Marshaler { + return newPbMarshaler() +} + +// TODO(#3842): Figure out how we want to represent/return *Sizers. +type pbMarshaler struct{} + +func newPbMarshaler() *pbMarshaler { + return &pbMarshaler{} +} + +var _ Sizer = (*pbMarshaler)(nil) + +func (e *pbMarshaler) MarshalLogs(ld Logs) ([]byte, error) { + return internal.LogsToOtlp(ld).Marshal() +} + +func (e *pbMarshaler) LogsSize(ld Logs) int { + return internal.LogsToOtlp(ld).Size() +} + +type pbUnmarshaler struct{} + +// NewProtoUnmarshaler returns a model.Unmarshaler. Unmarshals from OTLP binary protobuf bytes. +func NewProtoUnmarshaler() Unmarshaler { + return newPbUnmarshaler() +} + +func newPbUnmarshaler() *pbUnmarshaler { + return &pbUnmarshaler{} +} + +func (d *pbUnmarshaler) UnmarshalLogs(buf []byte) (Logs, error) { + ld := &otlplogs.LogsData{} + err := ld.Unmarshal(buf) + return internal.LogsFromOtlp(ld), err +} diff --git a/pdata/plog/pb_test.go b/pdata/plog/pb_test.go new file mode 100644 index 00000000000..c650b7506f5 --- /dev/null +++ b/pdata/plog/pb_test.go @@ -0,0 +1,91 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package plog + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "go.opentelemetry.io/collector/pdata/pcommon" +) + +func TestProtoLogsUnmarshaler_error(t *testing.T) { + p := NewProtoUnmarshaler() + _, err := p.UnmarshalLogs([]byte("+$%")) + assert.Error(t, err) +} + +func TestProtoSizer(t *testing.T) { + sizer := NewProtoMarshaler().(Sizer) + marshaler := NewProtoMarshaler() + ld := NewLogs() + ld.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty().SetSeverityText("error") + + size := sizer.LogsSize(ld) + + bytes, err := marshaler.MarshalLogs(ld) + require.NoError(t, err) + assert.Equal(t, len(bytes), size) + +} + +func TestProtoSizer_withNil(t *testing.T) { + sizer := NewProtoMarshaler().(Sizer) + + assert.Equal(t, 0, sizer.LogsSize(NewLogs())) +} + +func BenchmarkLogsToProto(b *testing.B) { + marshaler := NewProtoMarshaler() + logs := generateBenchmarkLogs(128) + b.ResetTimer() + for n := 0; n < b.N; n++ { + buf, err := marshaler.MarshalLogs(logs) + require.NoError(b, err) + assert.NotEqual(b, 0, len(buf)) + } +} + +func BenchmarkLogsFromProto(b *testing.B) { + marshaler := NewProtoMarshaler() + unmarshaler := NewProtoUnmarshaler() + baseLogs := generateBenchmarkLogs(128) + buf, err := marshaler.MarshalLogs(baseLogs) + require.NoError(b, err) + assert.NotEqual(b, 0, len(buf)) + b.ResetTimer() + b.ReportAllocs() + for n := 0; n < b.N; n++ { + logs, err := unmarshaler.UnmarshalLogs(buf) + require.NoError(b, err) + assert.Equal(b, baseLogs.ResourceLogs().Len(), logs.ResourceLogs().Len()) + } +} + +func generateBenchmarkLogs(logsCount int) Logs { + endTime := pcommon.NewTimestampFromTime(time.Now()) + + md := NewLogs() + ilm := md.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty() + ilm.LogRecords().EnsureCapacity(logsCount) + for i := 0; i < logsCount; i++ { + im := ilm.LogRecords().AppendEmpty() + im.SetTimestamp(endTime) + } + return md +} diff --git a/pdata/plog/plogotlp/logs.go b/pdata/plog/plogotlp/logs.go new file mode 100644 index 00000000000..5e380cc4973 --- /dev/null +++ b/pdata/plog/plogotlp/logs.go @@ -0,0 +1,164 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package plogotlp // import "go.opentelemetry.io/collector/pdata/plog/plogotlp" + +import ( + "bytes" + "context" + + "github.com/gogo/protobuf/jsonpb" + "google.golang.org/grpc" + + "go.opentelemetry.io/collector/pdata/internal" + otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" + otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" + "go.opentelemetry.io/collector/pdata/internal/otlp" + "go.opentelemetry.io/collector/pdata/plog" +) + +var jsonMarshaler = &jsonpb.Marshaler{} +var jsonUnmarshaler = &jsonpb.Unmarshaler{} + +// Response represents the response for gRPC client/server. +type Response struct { + orig *otlpcollectorlog.ExportLogsServiceResponse +} + +// NewResponse returns an empty Response. +func NewResponse() Response { + return Response{orig: &otlpcollectorlog.ExportLogsServiceResponse{}} +} + +// MarshalProto marshals Response into proto bytes. +func (lr Response) MarshalProto() ([]byte, error) { + return lr.orig.Marshal() +} + +// UnmarshalProto unmarshalls Response from proto bytes. +func (lr Response) UnmarshalProto(data []byte) error { + return lr.orig.Unmarshal(data) +} + +// MarshalJSON marshals Response into JSON bytes. +func (lr Response) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + if err := jsonMarshaler.Marshal(&buf, lr.orig); err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +// UnmarshalJSON unmarshalls Response from JSON bytes. +func (lr Response) UnmarshalJSON(data []byte) error { + return jsonUnmarshaler.Unmarshal(bytes.NewReader(data), lr.orig) +} + +// Request represents the response for gRPC client/server. +type Request struct { + orig *otlpcollectorlog.ExportLogsServiceRequest +} + +// NewRequest returns an empty Request. +func NewRequest() Request { + return Request{orig: &otlpcollectorlog.ExportLogsServiceRequest{}} +} + +// MarshalProto marshals Request into proto bytes. +func (lr Request) MarshalProto() ([]byte, error) { + return lr.orig.Marshal() +} + +// UnmarshalProto unmarshalls Request from proto bytes. +func (lr Request) UnmarshalProto(data []byte) error { + if err := lr.orig.Unmarshal(data); err != nil { + return err + } + otlp.InstrumentationLibraryLogsToScope(lr.orig.ResourceLogs) + return nil +} + +// MarshalJSON marshals Request into JSON bytes. +func (lr Request) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + if err := jsonMarshaler.Marshal(&buf, lr.orig); err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +// UnmarshalJSON unmarshalls Request from JSON bytes. +func (lr Request) UnmarshalJSON(data []byte) error { + if err := jsonUnmarshaler.Unmarshal(bytes.NewReader(data), lr.orig); err != nil { + return err + } + otlp.InstrumentationLibraryLogsToScope(lr.orig.ResourceLogs) + return nil +} + +func (lr Request) SetLogs(ld plog.Logs) { + lr.orig.ResourceLogs = internal.LogsToOtlp(ld).ResourceLogs +} + +func (lr Request) Logs() plog.Logs { + return internal.LogsFromOtlp(&otlplogs.LogsData{ResourceLogs: lr.orig.ResourceLogs}) +} + +// Client is the client API for OTLP-GRPC Logs service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type Client interface { + // Export plog.Logs to the server. + // + // For performance reasons, it is recommended to keep this RPC + // alive for the entire life of the application. + Export(ctx context.Context, request Request, opts ...grpc.CallOption) (Response, error) +} + +type logsClient struct { + rawClient otlpcollectorlog.LogsServiceClient +} + +// NewClient returns a new Client connected using the given connection. +func NewClient(cc *grpc.ClientConn) Client { + return &logsClient{rawClient: otlpcollectorlog.NewLogsServiceClient(cc)} +} + +func (c *logsClient) Export(ctx context.Context, request Request, opts ...grpc.CallOption) (Response, error) { + rsp, err := c.rawClient.Export(ctx, request.orig, opts...) + return Response{orig: rsp}, err +} + +// Server is the server API for OTLP gRPC LogsService service. +type Server interface { + // Export is called every time a new request is received. + // + // For performance reasons, it is recommended to keep this RPC + // alive for the entire life of the application. + Export(context.Context, Request) (Response, error) +} + +// RegisterServer registers the Server to the grpc.Server. +func RegisterServer(s *grpc.Server, srv Server) { + otlpcollectorlog.RegisterLogsServiceServer(s, &rawLogsServer{srv: srv}) +} + +type rawLogsServer struct { + srv Server +} + +func (s rawLogsServer) Export(ctx context.Context, request *otlpcollectorlog.ExportLogsServiceRequest) (*otlpcollectorlog.ExportLogsServiceResponse, error) { + rsp, err := s.srv.Export(ctx, Request{orig: request}) + return rsp.orig, err +} diff --git a/model/otlpgrpc/logs_test.go b/pdata/plog/plogotlp/logs_test.go similarity index 81% rename from model/otlpgrpc/logs_test.go rename to pdata/plog/plogotlp/logs_test.go index 735deb706b3..9e29309f5f0 100644 --- a/model/otlpgrpc/logs_test.go +++ b/pdata/plog/plogotlp/logs_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package otlpgrpc +package plogotlp import ( "context" @@ -31,16 +31,16 @@ import ( "google.golang.org/grpc/status" "google.golang.org/grpc/test/bufconn" - v1 "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" - "go.opentelemetry.io/collector/model/internal/otlp" - "go.opentelemetry.io/collector/model/pdata" + v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" + "go.opentelemetry.io/collector/pdata/internal/otlp" + "go.opentelemetry.io/collector/pdata/plog" ) -var _ json.Unmarshaler = LogsResponse{} -var _ json.Marshaler = LogsResponse{} +var _ json.Unmarshaler = Response{} +var _ json.Marshaler = Response{} -var _ json.Unmarshaler = LogsRequest{} -var _ json.Marshaler = LogsRequest{} +var _ json.Unmarshaler = Request{} +var _ json.Marshaler = Request{} var logsRequestJSON = []byte(` { @@ -126,8 +126,8 @@ var logsTransitionData = [][]byte{ }`), } -func TestLogsRequestJSON(t *testing.T) { - lr := NewLogsRequest() +func TestRequestJSON(t *testing.T) { + lr := NewRequest() assert.NoError(t, lr.UnmarshalJSON(logsRequestJSON)) assert.Equal(t, "test_log_record", lr.Logs().ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Body().AsString()) @@ -136,9 +136,9 @@ func TestLogsRequestJSON(t *testing.T) { assert.Equal(t, strings.Join(strings.Fields(string(logsRequestJSON)), ""), string(got)) } -func TestLogsRequestJSONTransition(t *testing.T) { +func TestRequestJSONTransition(t *testing.T) { for _, data := range logsTransitionData { - lr := NewLogsRequest() + lr := NewRequest() assert.NoError(t, lr.UnmarshalJSON(data)) assert.Equal(t, "test_log_record", lr.Logs().ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Body().AsString()) @@ -148,10 +148,10 @@ func TestLogsRequestJSONTransition(t *testing.T) { } } -func TestLogsGrpc(t *testing.T) { +func TestGrpc(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterLogsServer(s, &fakeLogsServer{t: t}) + RegisterServer(s, &fakeLogsServer{t: t}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -174,17 +174,17 @@ func TestLogsGrpc(t *testing.T) { assert.NoError(t, cc.Close()) }) - logClient := NewLogsClient(cc) + logClient := NewClient(cc) resp, err := logClient.Export(context.Background(), generateLogsRequest()) assert.NoError(t, err) - assert.Equal(t, NewLogsResponse(), resp) + assert.Equal(t, NewResponse(), resp) } -func TestLogsGrpcTransition(t *testing.T) { +func TestGrpcTransition(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterLogsServer(s, &fakeLogsServer{t: t}) + RegisterServer(s, &fakeLogsServer{t: t}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -207,19 +207,19 @@ func TestLogsGrpcTransition(t *testing.T) { assert.NoError(t, cc.Close()) }) - logClient := NewLogsClient(cc) + logClient := NewClient(cc) req := generateLogsRequestWithInstrumentationLibrary() otlp.InstrumentationLibraryLogsToScope(req.orig.ResourceLogs) resp, err := logClient.Export(context.Background(), req) assert.NoError(t, err) - assert.Equal(t, NewLogsResponse(), resp) + assert.Equal(t, NewResponse(), resp) } -func TestLogsGrpcError(t *testing.T) { +func TestGrpcError(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterLogsServer(s, &fakeLogsServer{t: t, err: errors.New("my error")}) + RegisterServer(s, &fakeLogsServer{t: t, err: errors.New("my error")}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -242,14 +242,14 @@ func TestLogsGrpcError(t *testing.T) { assert.NoError(t, cc.Close()) }) - logClient := NewLogsClient(cc) + logClient := NewClient(cc) resp, err := logClient.Export(context.Background(), generateLogsRequest()) require.Error(t, err) st, okSt := status.FromError(err) require.True(t, okSt) assert.Equal(t, "my error", st.Message()) assert.Equal(t, codes.Unknown, st.Code()) - assert.Equal(t, LogsResponse{}, resp) + assert.Equal(t, Response{}, resp) } type fakeLogsServer struct { @@ -257,21 +257,21 @@ type fakeLogsServer struct { err error } -func (f fakeLogsServer) Export(_ context.Context, request LogsRequest) (LogsResponse, error) { +func (f fakeLogsServer) Export(_ context.Context, request Request) (Response, error) { assert.Equal(f.t, generateLogsRequest(), request) - return NewLogsResponse(), f.err + return NewResponse(), f.err } -func generateLogsRequest() LogsRequest { - ld := pdata.NewLogs() +func generateLogsRequest() Request { + ld := plog.NewLogs() ld.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty().Body().SetStringVal("test_log_record") - lr := NewLogsRequest() + lr := NewRequest() lr.SetLogs(ld) return lr } -func generateLogsRequestWithInstrumentationLibrary() LogsRequest { +func generateLogsRequestWithInstrumentationLibrary() Request { lr := generateLogsRequest() lr.orig.ResourceLogs[0].InstrumentationLibraryLogs = []*v1.InstrumentationLibraryLogs{ //nolint:staticcheck // SA1019 ignore this! { diff --git a/pdata/pmetric/alias.go b/pdata/pmetric/alias.go new file mode 100644 index 00000000000..7c7f301a88e --- /dev/null +++ b/pdata/pmetric/alias.go @@ -0,0 +1,79 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pmetric // import "go.opentelemetry.io/collector/pdata/pmetric" + +import "go.opentelemetry.io/collector/pdata/internal" // This file contains aliases for metric data structures. + +// Marshaler is an alias for internal.MetricsMarshaler interface. +type Marshaler = internal.MetricsMarshaler + +// Unmarshaler is an alias for internal.MetricsUnmarshaler interface. +type Unmarshaler = internal.MetricsUnmarshaler + +// Sizer is an alias for internal.MetricsSizer interface. +type Sizer = internal.MetricsSizer + +// Metrics is an alias for internal.Metrics structure. +type Metrics = internal.Metrics + +// NewMetrics is an alias for a function to create new Metrics. +var NewMetrics = internal.NewMetrics + +// MetricDataType is an alias for internal.MetricDataType type. +type MetricDataType = internal.MetricDataType + +const ( + MetricDataTypeNone = internal.MetricDataTypeNone + MetricDataTypeGauge = internal.MetricDataTypeGauge + MetricDataTypeSum = internal.MetricDataTypeSum + MetricDataTypeHistogram = internal.MetricDataTypeHistogram + MetricDataTypeExponentialHistogram = internal.MetricDataTypeExponentialHistogram + MetricDataTypeSummary = internal.MetricDataTypeSummary +) + +// MetricAggregationTemporality is an alias for internal.MetricAggregationTemporality type. +type MetricAggregationTemporality = internal.MetricAggregationTemporality + +const ( + MetricAggregationTemporalityUnspecified = internal.MetricAggregationTemporalityUnspecified + MetricAggregationTemporalityDelta = internal.MetricAggregationTemporalityDelta + MetricAggregationTemporalityCumulative = internal.MetricAggregationTemporalityCumulative +) + +// MetricDataPointFlags is an alias for internal.MetricDataPointFlags type. +type MetricDataPointFlags = internal.MetricDataPointFlags + +const ( + MetricDataPointFlagsNone = internal.MetricDataPointFlagsNone +) + +// NewMetricDataPointFlags is an alias for a function to create new MetricDataPointFlags. +var NewMetricDataPointFlags = internal.NewMetricDataPointFlags + +// MetricDataPointFlag is an alias for internal.MetricDataPointFlag type. +type MetricDataPointFlag = internal.MetricDataPointFlag + +const ( + MetricDataPointFlagNoRecordedValue = internal.MetricDataPointFlagNoRecordedValue +) + +// MetricValueType is an alias for internal.MetricValueType type. +type MetricValueType = internal.MetricValueType + +const ( + MetricValueTypeNone = internal.MetricValueTypeNone + MetricValueTypeInt = internal.MetricValueTypeInt + MetricValueTypeDouble = internal.MetricValueTypeDouble +) diff --git a/model/pdata/generated_metrics_alias.go b/pdata/pmetric/generated_alias.go similarity index 98% rename from model/pdata/generated_metrics_alias.go rename to pdata/pmetric/generated_alias.go index b4b866637d2..1d4876f6006 100644 --- a/model/pdata/generated_metrics_alias.go +++ b/pdata/pmetric/generated_alias.go @@ -15,9 +15,9 @@ // Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. // To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". -package pdata +package pmetric -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/internal" // ResourceMetricsSlice is an alias for internal.ResourceMetricsSlice struct. type ResourceMetricsSlice = internal.ResourceMetricsSlice diff --git a/pdata/pmetric/json.go b/pdata/pmetric/json.go new file mode 100644 index 00000000000..e72d7d572f0 --- /dev/null +++ b/pdata/pmetric/json.go @@ -0,0 +1,66 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pmetric // import "go.opentelemetry.io/collector/pdata/pmetric" + +import ( + "bytes" + + "github.com/gogo/protobuf/jsonpb" + + "go.opentelemetry.io/collector/pdata/internal" + otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" + "go.opentelemetry.io/collector/pdata/internal/otlp" +) + +// NewJSONMarshaler returns a model.Marshaler. Marshals to OTLP json bytes. +func NewJSONMarshaler() Marshaler { + return newJSONMarshaler() +} + +type jsonMarshaler struct { + delegate jsonpb.Marshaler +} + +func newJSONMarshaler() *jsonMarshaler { + return &jsonMarshaler{delegate: jsonpb.Marshaler{}} +} + +func (e *jsonMarshaler) MarshalMetrics(md Metrics) ([]byte, error) { + buf := bytes.Buffer{} + err := e.delegate.Marshal(&buf, internal.MetricsToOtlp(md)) + return buf.Bytes(), err +} + +type jsonUnmarshaler struct { + delegate jsonpb.Unmarshaler +} + +// NewJSONUnmarshaler returns a model.Unmarshaler. Unmarshals from OTLP json bytes. +func NewJSONUnmarshaler() Unmarshaler { + return newJSONUnmarshaler() +} + +func newJSONUnmarshaler() *jsonUnmarshaler { + return &jsonUnmarshaler{delegate: jsonpb.Unmarshaler{}} +} + +func (d *jsonUnmarshaler) UnmarshalMetrics(buf []byte) (Metrics, error) { + md := &otlpmetrics.MetricsData{} + if err := d.delegate.Unmarshal(bytes.NewReader(buf), md); err != nil { + return Metrics{}, err + } + otlp.InstrumentationLibraryMetricsToScope(md.ResourceMetrics) + return internal.MetricsFromOtlp(md), nil +} diff --git a/model/otlp/json_test.go b/pdata/pmetric/json_test.go similarity index 57% rename from model/otlp/json_test.go rename to pdata/pmetric/json_test.go index 20438ab3443..6e2e0697618 100644 --- a/model/otlp/json_test.go +++ b/pdata/pmetric/json_test.go @@ -12,31 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -package otlp +package pmetric import ( "testing" "github.com/stretchr/testify/assert" - - "go.opentelemetry.io/collector/model/pdata" ) -var tracesOTLP = func() pdata.Traces { - td := pdata.NewTraces() - rs := td.ResourceSpans().AppendEmpty() - rs.Resource().Attributes().UpsertString("host.name", "testHost") - il := rs.ScopeSpans().AppendEmpty() - il.Scope().SetName("name") - il.Scope().SetVersion("version") - il.Spans().AppendEmpty().SetName("testSpan") - return td -}() - -var tracesJSON = `{"resourceSpans":[{"resource":{"attributes":[{"key":"host.name","value":{"stringValue":"testHost"}}]},"scopeSpans":[{"scope":{"name":"name","version":"version"},"spans":[{"traceId":"","spanId":"","parentSpanId":"","name":"testSpan","status":{}}]}]}]}` - -var metricsOTLP = func() pdata.Metrics { - md := pdata.NewMetrics() +var metricsOTLP = func() Metrics { + md := NewMetrics() rm := md.ResourceMetrics().AppendEmpty() rm.Resource().Attributes().UpsertString("host.name", "testHost") il := rm.ScopeMetrics().AppendEmpty() @@ -48,38 +33,12 @@ var metricsOTLP = func() pdata.Metrics { var metricsJSON = `{"resourceMetrics":[{"resource":{"attributes":[{"key":"host.name","value":{"stringValue":"testHost"}}]},"scopeMetrics":[{"scope":{"name":"name","version":"version"},"metrics":[{"name":"testMetric"}]}]}]}` -var logsOTLP = func() pdata.Logs { - ld := pdata.NewLogs() - rl := ld.ResourceLogs().AppendEmpty() - rl.Resource().Attributes().UpsertString("host.name", "testHost") - il := rl.ScopeLogs().AppendEmpty() - il.Scope().SetName("name") - il.Scope().SetVersion("version") - il.LogRecords().AppendEmpty().SetSeverityText("Error") - return ld -}() - -var logsJSON = `{"resourceLogs":[{"resource":{"attributes":[{"key":"host.name","value":{"stringValue":"testHost"}}]},"scopeLogs":[{"scope":{"name":"name","version":"version"},"logRecords":[{"severityText":"Error","body":{},"traceId":"","spanId":""}]}]}]}` - -func TestTracesJSON(t *testing.T) { - encoder := NewJSONTracesMarshaler() - jsonBuf, err := encoder.MarshalTraces(tracesOTLP) - assert.NoError(t, err) - - decoder := NewJSONTracesUnmarshaler() - var got interface{} - got, err = decoder.UnmarshalTraces(jsonBuf) - assert.NoError(t, err) - - assert.EqualValues(t, tracesOTLP, got) -} - func TestMetricsJSON(t *testing.T) { - encoder := NewJSONMetricsMarshaler() + encoder := NewJSONMarshaler() jsonBuf, err := encoder.MarshalMetrics(metricsOTLP) assert.NoError(t, err) - decoder := NewJSONMetricsUnmarshaler() + decoder := NewJSONUnmarshaler() var got interface{} got, err = decoder.UnmarshalMetrics(jsonBuf) assert.NoError(t, err) @@ -87,40 +46,13 @@ func TestMetricsJSON(t *testing.T) { assert.EqualValues(t, metricsOTLP, got) } -func TestLogsJSON(t *testing.T) { - encoder := NewJSONLogsMarshaler() - jsonBuf, err := encoder.MarshalLogs(logsOTLP) - assert.NoError(t, err) - - decoder := NewJSONLogsUnmarshaler() - var got interface{} - got, err = decoder.UnmarshalLogs(jsonBuf) - assert.NoError(t, err) - - assert.EqualValues(t, logsOTLP, got) -} - -func TestTracesJSON_Marshal(t *testing.T) { - encoder := NewJSONTracesMarshaler() - jsonBuf, err := encoder.MarshalTraces(tracesOTLP) - assert.NoError(t, err) - assert.Equal(t, tracesJSON, string(jsonBuf)) -} - func TestMetricsJSON_Marshal(t *testing.T) { - encoder := NewJSONMetricsMarshaler() + encoder := NewJSONMarshaler() jsonBuf, err := encoder.MarshalMetrics(metricsOTLP) assert.NoError(t, err) assert.Equal(t, metricsJSON, string(jsonBuf)) } -func TestLogsJSON_Marshal(t *testing.T) { - encoder := NewJSONLogsMarshaler() - jsonBuf, err := encoder.MarshalLogs(logsOTLP) - assert.NoError(t, err) - assert.Equal(t, logsJSON, string(jsonBuf)) -} - func TestMetricsNil(t *testing.T) { jsonBuf := `{ "resourceMetrics": [ @@ -228,10 +160,10 @@ func TestMetricsNil(t *testing.T) { } ] }` - decoder := NewJSONMetricsUnmarshaler() + decoder := NewJSONUnmarshaler() var got interface{} got, err := decoder.UnmarshalMetrics([]byte(jsonBuf)) assert.Error(t, err) - assert.EqualValues(t, pdata.Metrics{}, got) + assert.EqualValues(t, Metrics{}, got) } diff --git a/pdata/pmetric/pb.go b/pdata/pmetric/pb.go new file mode 100644 index 00000000000..2054a5b75ac --- /dev/null +++ b/pdata/pmetric/pb.go @@ -0,0 +1,59 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pmetric // import "go.opentelemetry.io/collector/pdata/pmetric" + +import ( + "go.opentelemetry.io/collector/pdata/internal" + otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" +) + +// NewProtoMarshaler returns a Marshaler. Marshals to OTLP binary protobuf bytes. +func NewProtoMarshaler() Marshaler { + return newPbMarshaler() +} + +// TODO(#3842): Figure out how we want to represent/return *Sizers. +type pbMarshaler struct{} + +func newPbMarshaler() *pbMarshaler { + return &pbMarshaler{} +} + +var _ Sizer = (*pbMarshaler)(nil) + +func (e *pbMarshaler) MarshalMetrics(md Metrics) ([]byte, error) { + return internal.MetricsToOtlp(md).Marshal() +} + +func (e *pbMarshaler) MetricsSize(md Metrics) int { + return internal.MetricsToOtlp(md).Size() +} + +type pbUnmarshaler struct{} + +// NewProtoUnmarshaler returns a model.Unmarshaler. Unmarshals from OTLP binary protobuf bytes. +func NewProtoUnmarshaler() Unmarshaler { + return newPbUnmarshaler() +} + +func newPbUnmarshaler() *pbUnmarshaler { + return &pbUnmarshaler{} +} + +func (d *pbUnmarshaler) UnmarshalMetrics(buf []byte) (Metrics, error) { + md := &otlpmetrics.MetricsData{} + err := md.Unmarshal(buf) + return internal.MetricsFromOtlp(md), err +} diff --git a/pdata/pmetric/pb_test.go b/pdata/pmetric/pb_test.go new file mode 100644 index 00000000000..b50041e17ce --- /dev/null +++ b/pdata/pmetric/pb_test.go @@ -0,0 +1,97 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pmetric + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "go.opentelemetry.io/collector/pdata/pcommon" +) + +func TestProtoMetricsUnmarshaler_error(t *testing.T) { + p := NewProtoUnmarshaler() + _, err := p.UnmarshalMetrics([]byte("+$%")) + assert.Error(t, err) +} + +func TestProtoSizer(t *testing.T) { + sizer := NewProtoMarshaler().(Sizer) + marshaler := NewProtoMarshaler() + md := NewMetrics() + md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty().SetName("foo") + + size := sizer.MetricsSize(md) + + bytes, err := marshaler.MarshalMetrics(md) + require.NoError(t, err) + assert.Equal(t, len(bytes), size) +} + +func TestProtoSizer_withNil(t *testing.T) { + sizer := NewProtoMarshaler().(Sizer) + + assert.Equal(t, 0, sizer.MetricsSize(NewMetrics())) +} + +func BenchmarkMetricsToProto(b *testing.B) { + marshaler := NewProtoMarshaler() + metrics := generateBenchmarkMetrics(128) + b.ResetTimer() + for n := 0; n < b.N; n++ { + buf, err := marshaler.MarshalMetrics(metrics) + require.NoError(b, err) + assert.NotEqual(b, 0, len(buf)) + } +} + +func BenchmarkMetricsFromProto(b *testing.B) { + marshaler := NewProtoMarshaler() + unmarshaler := NewProtoUnmarshaler() + baseMetrics := generateBenchmarkMetrics(128) + buf, err := marshaler.MarshalMetrics(baseMetrics) + require.NoError(b, err) + assert.NotEqual(b, 0, len(buf)) + b.ResetTimer() + b.ReportAllocs() + for n := 0; n < b.N; n++ { + metrics, err := unmarshaler.UnmarshalMetrics(buf) + require.NoError(b, err) + assert.Equal(b, baseMetrics.ResourceMetrics().Len(), metrics.ResourceMetrics().Len()) + } +} + +func generateBenchmarkMetrics(metricsCount int) Metrics { + now := time.Now() + startTime := pcommon.NewTimestampFromTime(now.Add(-10 * time.Second)) + endTime := pcommon.NewTimestampFromTime(now) + + md := NewMetrics() + ilm := md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty() + ilm.Metrics().EnsureCapacity(metricsCount) + for i := 0; i < metricsCount; i++ { + im := ilm.Metrics().AppendEmpty() + im.SetName("test_name") + im.SetDataType(MetricDataTypeSum) + idp := im.Sum().DataPoints().AppendEmpty() + idp.SetStartTimestamp(startTime) + idp.SetTimestamp(endTime) + idp.SetIntVal(123) + } + return md +} diff --git a/pdata/pmetric/pmetricotlp/metrics.go b/pdata/pmetric/pmetricotlp/metrics.go new file mode 100644 index 00000000000..5d9b3021dbd --- /dev/null +++ b/pdata/pmetric/pmetricotlp/metrics.go @@ -0,0 +1,160 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pmetricotlp // import "go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp" + +import ( + "bytes" + "context" + + "github.com/gogo/protobuf/jsonpb" + "google.golang.org/grpc" + + "go.opentelemetry.io/collector/pdata/internal" + otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" + otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" + "go.opentelemetry.io/collector/pdata/internal/otlp" + "go.opentelemetry.io/collector/pdata/pmetric" +) + +var jsonMarshaler = &jsonpb.Marshaler{} +var jsonUnmarshaler = &jsonpb.Unmarshaler{} + +// Response represents the response for gRPC client/server. +type Response struct { + orig *otlpcollectormetrics.ExportMetricsServiceResponse +} + +// NewResponse returns an empty Response. +func NewResponse() Response { + return Response{orig: &otlpcollectormetrics.ExportMetricsServiceResponse{}} +} + +// MarshalProto marshals Response into proto bytes. +func (mr Response) MarshalProto() ([]byte, error) { + return mr.orig.Marshal() +} + +// UnmarshalProto unmarshalls Response from proto bytes. +func (mr Response) UnmarshalProto(data []byte) error { + return mr.orig.Unmarshal(data) +} + +// MarshalJSON marshals Response into JSON bytes. +func (mr Response) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + if err := jsonMarshaler.Marshal(&buf, mr.orig); err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +// UnmarshalJSON unmarshalls Response from JSON bytes. +func (mr Response) UnmarshalJSON(data []byte) error { + return jsonUnmarshaler.Unmarshal(bytes.NewReader(data), mr.orig) +} + +// Request represents the response for gRPC client/server. +type Request struct { + orig *otlpcollectormetrics.ExportMetricsServiceRequest +} + +// NewRequest returns an empty Request. +func NewRequest() Request { + return Request{orig: &otlpcollectormetrics.ExportMetricsServiceRequest{}} +} + +// MarshalProto marshals Request into proto bytes. +func (mr Request) MarshalProto() ([]byte, error) { + return mr.orig.Marshal() +} + +// UnmarshalProto unmarshalls Request from proto bytes. +func (mr Request) UnmarshalProto(data []byte) error { + return mr.orig.Unmarshal(data) +} + +// MarshalJSON marshals Request into JSON bytes. +func (mr Request) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + if err := jsonMarshaler.Marshal(&buf, mr.orig); err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +// UnmarshalJSON unmarshalls Request from JSON bytes. +func (mr Request) UnmarshalJSON(data []byte) error { + if err := jsonUnmarshaler.Unmarshal(bytes.NewReader(data), mr.orig); err != nil { + return err + } + otlp.InstrumentationLibraryMetricsToScope(mr.orig.ResourceMetrics) + return nil +} + +func (mr Request) SetMetrics(ld pmetric.Metrics) { + mr.orig.ResourceMetrics = internal.MetricsToOtlp(ld).ResourceMetrics +} + +func (mr Request) Metrics() pmetric.Metrics { + return internal.MetricsFromOtlp(&otlpmetrics.MetricsData{ResourceMetrics: mr.orig.ResourceMetrics}) +} + +// Client is the client API for OTLP-GRPC Metrics service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type Client interface { + // Export pmetric.Metrics to the server. + // + // For performance reasons, it is recommended to keep this RPC + // alive for the entire life of the application. + Export(ctx context.Context, request Request, opts ...grpc.CallOption) (Response, error) +} + +type metricsClient struct { + rawClient otlpcollectormetrics.MetricsServiceClient +} + +// NewClient returns a new Client connected using the given connection. +func NewClient(cc *grpc.ClientConn) Client { + return &metricsClient{rawClient: otlpcollectormetrics.NewMetricsServiceClient(cc)} +} + +func (c *metricsClient) Export(ctx context.Context, request Request, opts ...grpc.CallOption) (Response, error) { + rsp, err := c.rawClient.Export(ctx, request.orig, opts...) + return Response{orig: rsp}, err +} + +// Server is the server API for OTLP gRPC MetricsService service. +type Server interface { + // Export is called every time a new request is received. + // + // For performance reasons, it is recommended to keep this RPC + // alive for the entire life of the application. + Export(context.Context, Request) (Response, error) +} + +// RegisterServer registers the Server to the grpc.Server. +func RegisterServer(s *grpc.Server, srv Server) { + otlpcollectormetrics.RegisterMetricsServiceServer(s, &rawMetricsServer{srv: srv}) +} + +type rawMetricsServer struct { + srv Server +} + +func (s rawMetricsServer) Export(ctx context.Context, request *otlpcollectormetrics.ExportMetricsServiceRequest) (*otlpcollectormetrics.ExportMetricsServiceResponse, error) { + rsp, err := s.srv.Export(ctx, Request{orig: request}) + return rsp.orig, err +} diff --git a/model/otlpgrpc/metrics_test.go b/pdata/pmetric/pmetricotlp/metrics_test.go similarity index 79% rename from model/otlpgrpc/metrics_test.go rename to pdata/pmetric/pmetricotlp/metrics_test.go index a09ad300632..976efca357a 100644 --- a/model/otlpgrpc/metrics_test.go +++ b/pdata/pmetric/pmetricotlp/metrics_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package otlpgrpc +package pmetricotlp import ( "context" @@ -31,16 +31,16 @@ import ( "google.golang.org/grpc/status" "google.golang.org/grpc/test/bufconn" - v1 "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/model/internal/otlp" - "go.opentelemetry.io/collector/model/pdata" + v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" + "go.opentelemetry.io/collector/pdata/internal/otlp" + "go.opentelemetry.io/collector/pdata/pmetric" ) -var _ json.Unmarshaler = MetricsResponse{} -var _ json.Marshaler = MetricsResponse{} +var _ json.Unmarshaler = Response{} +var _ json.Marshaler = Response{} -var _ json.Unmarshaler = MetricsRequest{} -var _ json.Marshaler = MetricsRequest{} +var _ json.Unmarshaler = Request{} +var _ json.Marshaler = Request{} var metricsRequestJSON = []byte(` { @@ -110,8 +110,8 @@ var metricsTransitionData = [][]byte{ }`), } -func TestMetricsRequestJSON(t *testing.T) { - mr := NewMetricsRequest() +func TestRequestJSON(t *testing.T) { + mr := NewRequest() assert.NoError(t, mr.UnmarshalJSON(metricsRequestJSON)) assert.Equal(t, "test_metric", mr.Metrics().ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) @@ -120,9 +120,9 @@ func TestMetricsRequestJSON(t *testing.T) { assert.Equal(t, strings.Join(strings.Fields(string(metricsRequestJSON)), ""), string(got)) } -func TestMetricsRequestJSONTransition(t *testing.T) { +func TestRequestJSONTransition(t *testing.T) { for _, data := range metricsTransitionData { - mr := NewMetricsRequest() + mr := NewRequest() assert.NoError(t, mr.UnmarshalJSON(data)) assert.Equal(t, "test_metric", mr.Metrics().ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) @@ -132,10 +132,10 @@ func TestMetricsRequestJSONTransition(t *testing.T) { } } -func TestMetricsGrpc(t *testing.T) { +func TestGrpc(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterMetricsServer(s, &fakeMetricsServer{t: t}) + RegisterServer(s, &fakeMetricsServer{t: t}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -158,17 +158,17 @@ func TestMetricsGrpc(t *testing.T) { assert.NoError(t, cc.Close()) }) - logClient := NewMetricsClient(cc) + logClient := NewClient(cc) resp, err := logClient.Export(context.Background(), generateMetricsRequest()) assert.NoError(t, err) - assert.Equal(t, NewMetricsResponse(), resp) + assert.Equal(t, NewResponse(), resp) } -func TestMetricsGrpcTransition(t *testing.T) { +func TestGrpcTransition(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterMetricsServer(s, &fakeMetricsServer{t: t}) + RegisterServer(s, &fakeMetricsServer{t: t}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -191,19 +191,19 @@ func TestMetricsGrpcTransition(t *testing.T) { assert.NoError(t, cc.Close()) }) - logClient := NewMetricsClient(cc) + logClient := NewClient(cc) req := generateMetricsRequestWithInstrumentationLibrary() otlp.InstrumentationLibraryMetricsToScope(req.orig.ResourceMetrics) resp, err := logClient.Export(context.Background(), req) assert.NoError(t, err) - assert.Equal(t, NewMetricsResponse(), resp) + assert.Equal(t, NewResponse(), resp) } -func TestMetricsGrpcError(t *testing.T) { +func TestGrpcError(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterMetricsServer(s, &fakeMetricsServer{t: t, err: errors.New("my error")}) + RegisterServer(s, &fakeMetricsServer{t: t, err: errors.New("my error")}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -226,14 +226,14 @@ func TestMetricsGrpcError(t *testing.T) { assert.NoError(t, cc.Close()) }) - logClient := NewMetricsClient(cc) + logClient := NewClient(cc) resp, err := logClient.Export(context.Background(), generateMetricsRequest()) require.Error(t, err) st, okSt := status.FromError(err) require.True(t, okSt) assert.Equal(t, "my error", st.Message()) assert.Equal(t, codes.Unknown, st.Code()) - assert.Equal(t, MetricsResponse{}, resp) + assert.Equal(t, Response{}, resp) } type fakeMetricsServer struct { @@ -241,21 +241,21 @@ type fakeMetricsServer struct { err error } -func (f fakeMetricsServer) Export(_ context.Context, request MetricsRequest) (MetricsResponse, error) { +func (f fakeMetricsServer) Export(_ context.Context, request Request) (Response, error) { assert.Equal(f.t, generateMetricsRequest(), request) - return NewMetricsResponse(), f.err + return NewResponse(), f.err } -func generateMetricsRequest() MetricsRequest { - md := pdata.NewMetrics() +func generateMetricsRequest() Request { + md := pmetric.NewMetrics() md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty().SetName("test_metric") - mr := NewMetricsRequest() + mr := NewRequest() mr.SetMetrics(md) return mr } -func generateMetricsRequestWithInstrumentationLibrary() MetricsRequest { +func generateMetricsRequestWithInstrumentationLibrary() Request { mr := generateMetricsRequest() mr.orig.ResourceMetrics[0].InstrumentationLibraryMetrics = []*v1.InstrumentationLibraryMetrics{ //nolint:staticcheck // SA1019 ignore this! { diff --git a/pdata/ptrace/alias.go b/pdata/ptrace/alias.go new file mode 100644 index 00000000000..2d68ca088de --- /dev/null +++ b/pdata/ptrace/alias.go @@ -0,0 +1,62 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ptrace // import "go.opentelemetry.io/collector/pdata/ptrace" + +import "go.opentelemetry.io/collector/pdata/internal" + +// This file contains aliases for trace data structures. + +// Marshaler is an alias for internal.TracesMarshaler interface. +type Marshaler = internal.TracesMarshaler + +// Unmarshaler is an alias for internal.TracesUnmarshaler interface. +type Unmarshaler = internal.TracesUnmarshaler + +// Sizer is an alias for internal.TracesSizer interface. +type Sizer = internal.TracesSizer + +// Traces is an alias for internal.Traces struct. +type Traces = internal.Traces + +// NewTraces is an alias for a function to create new Traces. +var NewTraces = internal.NewTraces + +// TraceState is an alias for internal.TraceState type. +type TraceState = internal.TraceState + +const ( + TraceStateEmpty = internal.TraceStateEmpty +) + +// SpanKind is an alias for internal.SpanKind type. +type SpanKind = internal.SpanKind + +const ( + SpanKindUnspecified = internal.SpanKindUnspecified + SpanKindInternal = internal.SpanKindInternal + SpanKindServer = internal.SpanKindServer + SpanKindClient = internal.SpanKindClient + SpanKindProducer = internal.SpanKindProducer + SpanKindConsumer = internal.SpanKindConsumer +) + +// StatusCode is an alias for internal.StatusCode type. +type StatusCode = internal.StatusCode + +const ( + StatusCodeUnset = internal.StatusCodeUnset + StatusCodeOk = internal.StatusCodeOk + StatusCodeError = internal.StatusCodeError +) diff --git a/model/pdata/generated_trace_alias.go b/pdata/ptrace/generated_alias.go similarity index 97% rename from model/pdata/generated_trace_alias.go rename to pdata/ptrace/generated_alias.go index d504ea66969..68313a528c6 100644 --- a/model/pdata/generated_trace_alias.go +++ b/pdata/ptrace/generated_alias.go @@ -15,9 +15,9 @@ // Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. // To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". -package pdata +package ptrace -import "go.opentelemetry.io/collector/model/internal" +import "go.opentelemetry.io/collector/pdata/internal" // ResourceSpansSlice is an alias for internal.ResourceSpansSlice struct. type ResourceSpansSlice = internal.ResourceSpansSlice diff --git a/pdata/ptrace/json.go b/pdata/ptrace/json.go new file mode 100644 index 00000000000..a6b026ae6c9 --- /dev/null +++ b/pdata/ptrace/json.go @@ -0,0 +1,66 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ptrace // import "go.opentelemetry.io/collector/pdata/ptrace" + +import ( + "bytes" + + "github.com/gogo/protobuf/jsonpb" + + "go.opentelemetry.io/collector/pdata/internal" + otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" + "go.opentelemetry.io/collector/pdata/internal/otlp" +) + +// NewJSONMarshaler returns a model.Marshaler. Marshals to OTLP json bytes. +func NewJSONMarshaler() Marshaler { + return newJSONMarshaler() +} + +type jsonMarshaler struct { + delegate jsonpb.Marshaler +} + +func newJSONMarshaler() *jsonMarshaler { + return &jsonMarshaler{delegate: jsonpb.Marshaler{}} +} + +func (e *jsonMarshaler) MarshalTraces(td Traces) ([]byte, error) { + buf := bytes.Buffer{} + err := e.delegate.Marshal(&buf, internal.TracesToOtlp(td)) + return buf.Bytes(), err +} + +type jsonUnmarshaler struct { + delegate jsonpb.Unmarshaler +} + +// NewJSONUnmarshaler returns a model.Unmarshaler. Unmarshals from OTLP json bytes. +func NewJSONUnmarshaler() Unmarshaler { + return newJSONUnmarshaler() +} + +func newJSONUnmarshaler() *jsonUnmarshaler { + return &jsonUnmarshaler{delegate: jsonpb.Unmarshaler{}} +} + +func (d *jsonUnmarshaler) UnmarshalTraces(buf []byte) (Traces, error) { + td := &otlptrace.TracesData{} + if err := d.delegate.Unmarshal(bytes.NewReader(buf), td); err != nil { + return Traces{}, err + } + otlp.InstrumentationLibrarySpansToScope(td.ResourceSpans) + return internal.TracesFromOtlp(td), nil +} diff --git a/pdata/ptrace/json_test.go b/pdata/ptrace/json_test.go new file mode 100644 index 00000000000..78a6eaf1fc1 --- /dev/null +++ b/pdata/ptrace/json_test.go @@ -0,0 +1,54 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ptrace + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +var tracesOTLP = func() Traces { + td := NewTraces() + rs := td.ResourceSpans().AppendEmpty() + rs.Resource().Attributes().UpsertString("host.name", "testHost") + il := rs.ScopeSpans().AppendEmpty() + il.Scope().SetName("name") + il.Scope().SetVersion("version") + il.Spans().AppendEmpty().SetName("testSpan") + return td +}() + +var tracesJSON = `{"resourceSpans":[{"resource":{"attributes":[{"key":"host.name","value":{"stringValue":"testHost"}}]},"scopeSpans":[{"scope":{"name":"name","version":"version"},"spans":[{"traceId":"","spanId":"","parentSpanId":"","name":"testSpan","status":{}}]}]}]}` + +func TestTracesJSON(t *testing.T) { + encoder := NewJSONMarshaler() + jsonBuf, err := encoder.MarshalTraces(tracesOTLP) + assert.NoError(t, err) + + decoder := NewJSONUnmarshaler() + var got interface{} + got, err = decoder.UnmarshalTraces(jsonBuf) + assert.NoError(t, err) + + assert.EqualValues(t, tracesOTLP, got) +} + +func TestTracesJSON_Marshal(t *testing.T) { + encoder := NewJSONMarshaler() + jsonBuf, err := encoder.MarshalTraces(tracesOTLP) + assert.NoError(t, err) + assert.Equal(t, tracesJSON, string(jsonBuf)) +} diff --git a/pdata/ptrace/pb.go b/pdata/ptrace/pb.go new file mode 100644 index 00000000000..b512989afbf --- /dev/null +++ b/pdata/ptrace/pb.go @@ -0,0 +1,59 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ptrace // import "go.opentelemetry.io/collector/pdata/ptrace" + +import ( + "go.opentelemetry.io/collector/pdata/internal" + otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" +) + +// NewProtoMarshaler returns a Marshaler. Marshals to OTLP binary protobuf bytes. +func NewProtoMarshaler() Marshaler { + return newPbMarshaler() +} + +// TODO(#3842): Figure out how we want to represent/return *Sizers. +type pbMarshaler struct{} + +func newPbMarshaler() *pbMarshaler { + return &pbMarshaler{} +} + +var _ Sizer = (*pbMarshaler)(nil) + +func (e *pbMarshaler) MarshalTraces(td Traces) ([]byte, error) { + return internal.TracesToOtlp(td).Marshal() +} + +func (e *pbMarshaler) TracesSize(td Traces) int { + return internal.TracesToOtlp(td).Size() +} + +type pbUnmarshaler struct{} + +// NewProtoUnmarshaler returns a model.Unmarshaler. Unmarshals from OTLP binary protobuf bytes. +func NewProtoUnmarshaler() Unmarshaler { + return newPbUnmarshaler() +} + +func newPbUnmarshaler() *pbUnmarshaler { + return &pbUnmarshaler{} +} + +func (d *pbUnmarshaler) UnmarshalTraces(buf []byte) (Traces, error) { + td := &otlptrace.TracesData{} + err := td.Unmarshal(buf) + return internal.TracesFromOtlp(td), err +} diff --git a/pdata/ptrace/pb_test.go b/pdata/ptrace/pb_test.go new file mode 100644 index 00000000000..19d85643fca --- /dev/null +++ b/pdata/ptrace/pb_test.go @@ -0,0 +1,95 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ptrace + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "go.opentelemetry.io/collector/pdata/pcommon" +) + +func TestProtoTracesUnmarshaler_error(t *testing.T) { + p := NewProtoUnmarshaler() + _, err := p.UnmarshalTraces([]byte("+$%")) + assert.Error(t, err) +} + +func TestProtoSizer(t *testing.T) { + sizer := NewProtoMarshaler().(Sizer) + marshaler := NewProtoMarshaler() + td := NewTraces() + rms := td.ResourceSpans() + rms.AppendEmpty().ScopeSpans().AppendEmpty().Spans().AppendEmpty().SetName("foo") + + size := sizer.TracesSize(td) + + bytes, err := marshaler.MarshalTraces(td) + require.NoError(t, err) + assert.Equal(t, len(bytes), size) +} + +func TestProtoSizer_withNil(t *testing.T) { + sizer := NewProtoMarshaler().(Sizer) + + assert.Equal(t, 0, sizer.TracesSize(NewTraces())) +} + +func BenchmarkTracesToProto(b *testing.B) { + marshaler := NewProtoMarshaler() + traces := generateBenchmarkTraces(128) + b.ResetTimer() + for n := 0; n < b.N; n++ { + buf, err := marshaler.MarshalTraces(traces) + require.NoError(b, err) + assert.NotEqual(b, 0, len(buf)) + } +} + +func BenchmarkTracesFromProto(b *testing.B) { + marshaler := NewProtoMarshaler() + unmarshaler := NewProtoUnmarshaler() + baseTraces := generateBenchmarkTraces(128) + buf, err := marshaler.MarshalTraces(baseTraces) + require.NoError(b, err) + assert.NotEqual(b, 0, len(buf)) + b.ResetTimer() + b.ReportAllocs() + for n := 0; n < b.N; n++ { + traces, err := unmarshaler.UnmarshalTraces(buf) + require.NoError(b, err) + assert.Equal(b, baseTraces.ResourceSpans().Len(), traces.ResourceSpans().Len()) + } +} + +func generateBenchmarkTraces(metricsCount int) Traces { + now := time.Now() + startTime := pcommon.NewTimestampFromTime(now.Add(-10 * time.Second)) + endTime := pcommon.NewTimestampFromTime(now) + + md := NewTraces() + ilm := md.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty() + ilm.Spans().EnsureCapacity(metricsCount) + for i := 0; i < metricsCount; i++ { + im := ilm.Spans().AppendEmpty() + im.SetName("test_name") + im.SetStartTimestamp(startTime) + im.SetEndTimestamp(endTime) + } + return md +} diff --git a/pdata/ptrace/ptraceotlp/traces.go b/pdata/ptrace/ptraceotlp/traces.go new file mode 100644 index 00000000000..95f87ba74f3 --- /dev/null +++ b/pdata/ptrace/ptraceotlp/traces.go @@ -0,0 +1,165 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ptraceotlp // import "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" + +import ( + "bytes" + "context" + + "github.com/gogo/protobuf/jsonpb" + "google.golang.org/grpc" + + "go.opentelemetry.io/collector/pdata/internal" + otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" + otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" + "go.opentelemetry.io/collector/pdata/internal/otlp" + "go.opentelemetry.io/collector/pdata/ptrace" +) + +var jsonMarshaler = &jsonpb.Marshaler{} +var jsonUnmarshaler = &jsonpb.Unmarshaler{} + +// Response represents the response for gRPC client/server. +type Response struct { + orig *otlpcollectortrace.ExportTraceServiceResponse +} + +// NewResponse returns an empty Response. +func NewResponse() Response { + return Response{orig: &otlpcollectortrace.ExportTraceServiceResponse{}} +} + +// MarshalProto marshals Response into proto bytes. +func (tr Response) MarshalProto() ([]byte, error) { + return tr.orig.Marshal() +} + +// UnmarshalProto unmarshalls Response from proto bytes. +func (tr Response) UnmarshalProto(data []byte) error { + return tr.orig.Unmarshal(data) +} + +// MarshalJSON marshals Response into JSON bytes. +func (tr Response) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + if err := jsonMarshaler.Marshal(&buf, tr.orig); err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +// UnmarshalJSON unmarshalls Response from JSON bytes. +func (tr Response) UnmarshalJSON(data []byte) error { + return jsonUnmarshaler.Unmarshal(bytes.NewReader(data), tr.orig) +} + +// Request represents the response for gRPC client/server. +type Request struct { + orig *otlpcollectortrace.ExportTraceServiceRequest +} + +// NewRequest returns an empty Request. +func NewRequest() Request { + return Request{orig: &otlpcollectortrace.ExportTraceServiceRequest{}} +} + +// MarshalProto marshals Request into proto bytes. +func (tr Request) MarshalProto() ([]byte, error) { + return tr.orig.Marshal() +} + +// UnmarshalProto unmarshalls Request from proto bytes. +func (tr Request) UnmarshalProto(data []byte) error { + if err := tr.orig.Unmarshal(data); err != nil { + return err + } + otlp.InstrumentationLibrarySpansToScope(tr.orig.ResourceSpans) + return nil +} + +// MarshalJSON marshals Request into JSON bytes. +func (tr Request) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + if err := jsonMarshaler.Marshal(&buf, tr.orig); err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +// UnmarshalJSON unmarshalls Request from JSON bytes. +func (tr Request) UnmarshalJSON(data []byte) error { + if err := jsonUnmarshaler.Unmarshal(bytes.NewReader(data), tr.orig); err != nil { + return err + } + otlp.InstrumentationLibrarySpansToScope(tr.orig.ResourceSpans) + return nil +} + +func (tr Request) SetTraces(td ptrace.Traces) { + tr.orig.ResourceSpans = internal.TracesToOtlp(td).ResourceSpans +} + +func (tr Request) Traces() ptrace.Traces { + return internal.TracesFromOtlp(&otlptrace.TracesData{ResourceSpans: tr.orig.ResourceSpans}) +} + +// Client is the client API for OTLP-GRPC Traces service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type Client interface { + // Export ptrace.Traces to the server. + // + // For performance reasons, it is recommended to keep this RPC + // alive for the entire life of the application. + Export(ctx context.Context, request Request, opts ...grpc.CallOption) (Response, error) +} + +type tracesClient struct { + rawClient otlpcollectortrace.TraceServiceClient +} + +// NewClient returns a new Client connected using the given connection. +func NewClient(cc *grpc.ClientConn) Client { + return &tracesClient{rawClient: otlpcollectortrace.NewTraceServiceClient(cc)} +} + +// Export implements the Client interface. +func (c *tracesClient) Export(ctx context.Context, request Request, opts ...grpc.CallOption) (Response, error) { + rsp, err := c.rawClient.Export(ctx, request.orig, opts...) + return Response{orig: rsp}, err +} + +// Server is the server API for OTLP gRPC TracesService service. +type Server interface { + // Export is called every time a new request is received. + // + // For performance reasons, it is recommended to keep this RPC + // alive for the entire life of the application. + Export(context.Context, Request) (Response, error) +} + +// RegisterServer registers the Server to the grpc.Server. +func RegisterServer(s *grpc.Server, srv Server) { + otlpcollectortrace.RegisterTraceServiceServer(s, &rawTracesServer{srv: srv}) +} + +type rawTracesServer struct { + srv Server +} + +func (s rawTracesServer) Export(ctx context.Context, request *otlpcollectortrace.ExportTraceServiceRequest) (*otlpcollectortrace.ExportTraceServiceResponse, error) { + rsp, err := s.srv.Export(ctx, Request{orig: request}) + return rsp.orig, err +} diff --git a/model/otlpgrpc/traces_test.go b/pdata/ptrace/ptraceotlp/traces_test.go similarity index 80% rename from model/otlpgrpc/traces_test.go rename to pdata/ptrace/ptraceotlp/traces_test.go index 82dc3bee39f..8af98b3ae27 100644 --- a/model/otlpgrpc/traces_test.go +++ b/pdata/ptrace/ptraceotlp/traces_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package otlpgrpc +package ptraceotlp import ( "context" @@ -31,16 +31,16 @@ import ( "google.golang.org/grpc/status" "google.golang.org/grpc/test/bufconn" - v1 "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" - "go.opentelemetry.io/collector/model/internal/otlp" - "go.opentelemetry.io/collector/model/pdata" + v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" + "go.opentelemetry.io/collector/pdata/internal/otlp" + "go.opentelemetry.io/collector/pdata/ptrace" ) -var _ json.Unmarshaler = TracesResponse{} -var _ json.Marshaler = TracesResponse{} +var _ json.Unmarshaler = Response{} +var _ json.Marshaler = Response{} -var _ json.Unmarshaler = TracesRequest{} -var _ json.Marshaler = TracesRequest{} +var _ json.Unmarshaler = Request{} +var _ json.Marshaler = Request{} var tracesRequestJSON = []byte(` { @@ -126,8 +126,8 @@ var tracesTransitionData = [][]byte{ }`), } -func TestTracesRequestJSON(t *testing.T) { - tr := NewTracesRequest() +func TestRequestJSON(t *testing.T) { + tr := NewRequest() assert.NoError(t, tr.UnmarshalJSON(tracesRequestJSON)) assert.Equal(t, "test_span", tr.Traces().ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) @@ -136,9 +136,9 @@ func TestTracesRequestJSON(t *testing.T) { assert.Equal(t, strings.Join(strings.Fields(string(tracesRequestJSON)), ""), string(got)) } -func TestTracesRequestJSONTransition(t *testing.T) { +func TestRequestJSONTransition(t *testing.T) { for _, data := range tracesTransitionData { - tr := NewTracesRequest() + tr := NewRequest() assert.NoError(t, tr.UnmarshalJSON(data)) assert.Equal(t, "test_span", tr.Traces().ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) @@ -148,10 +148,10 @@ func TestTracesRequestJSONTransition(t *testing.T) { } } -func TestTracesGrpc(t *testing.T) { +func TestGrpc(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterTracesServer(s, &fakeTracesServer{t: t}) + RegisterServer(s, &fakeTracesServer{t: t}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -174,17 +174,17 @@ func TestTracesGrpc(t *testing.T) { assert.NoError(t, cc.Close()) }) - logClient := NewTracesClient(cc) + logClient := NewClient(cc) resp, err := logClient.Export(context.Background(), generateTracesRequest()) assert.NoError(t, err) - assert.Equal(t, NewTracesResponse(), resp) + assert.Equal(t, NewResponse(), resp) } -func TestTracesGrpcTransition(t *testing.T) { +func TestGrpcTransition(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterTracesServer(s, &fakeTracesServer{t: t}) + RegisterServer(s, &fakeTracesServer{t: t}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -207,19 +207,19 @@ func TestTracesGrpcTransition(t *testing.T) { assert.NoError(t, cc.Close()) }) - logClient := NewTracesClient(cc) + logClient := NewClient(cc) req := generateTracesRequestWithInstrumentationLibrary() otlp.InstrumentationLibrarySpansToScope(req.orig.ResourceSpans) resp, err := logClient.Export(context.Background(), req) assert.NoError(t, err) - assert.Equal(t, NewTracesResponse(), resp) + assert.Equal(t, NewResponse(), resp) } -func TestTracesGrpcError(t *testing.T) { +func TestGrpcError(t *testing.T) { lis := bufconn.Listen(1024 * 1024) s := grpc.NewServer() - RegisterTracesServer(s, &fakeTracesServer{t: t, err: errors.New("my error")}) + RegisterServer(s, &fakeTracesServer{t: t, err: errors.New("my error")}) wg := sync.WaitGroup{} wg.Add(1) go func() { @@ -242,14 +242,14 @@ func TestTracesGrpcError(t *testing.T) { assert.NoError(t, cc.Close()) }) - logClient := NewTracesClient(cc) + logClient := NewClient(cc) resp, err := logClient.Export(context.Background(), generateTracesRequest()) require.Error(t, err) st, okSt := status.FromError(err) require.True(t, okSt) assert.Equal(t, "my error", st.Message()) assert.Equal(t, codes.Unknown, st.Code()) - assert.Equal(t, TracesResponse{}, resp) + assert.Equal(t, Response{}, resp) } type fakeTracesServer struct { @@ -257,21 +257,21 @@ type fakeTracesServer struct { err error } -func (f fakeTracesServer) Export(_ context.Context, request TracesRequest) (TracesResponse, error) { +func (f fakeTracesServer) Export(_ context.Context, request Request) (Response, error) { assert.Equal(f.t, generateTracesRequest(), request) - return NewTracesResponse(), f.err + return NewResponse(), f.err } -func generateTracesRequest() TracesRequest { - td := pdata.NewTraces() +func generateTracesRequest() Request { + td := ptrace.NewTraces() td.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty().Spans().AppendEmpty().SetName("test_span") - tr := NewTracesRequest() + tr := NewRequest() tr.SetTraces(td) return tr } -func generateTracesRequestWithInstrumentationLibrary() TracesRequest { +func generateTracesRequestWithInstrumentationLibrary() Request { tr := generateTracesRequest() tr.orig.ResourceSpans[0].InstrumentationLibrarySpans = []*v1.InstrumentationLibrarySpans{ //nolint:staticcheck // SA1019 ignore this! { diff --git a/processor/batchprocessor/batch_processor.go b/processor/batchprocessor/batch_processor.go index c7974f08bdd..abdaf532d2e 100644 --- a/processor/batchprocessor/batch_processor.go +++ b/processor/batchprocessor/batch_processor.go @@ -27,8 +27,9 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/configtelemetry" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // batch_processor is a component that accepts spans and metrics, places them @@ -187,20 +188,20 @@ func (bp *batchProcessor) sendItems(triggerMeasure *stats.Int64Measure) { } // ConsumeTraces implements TracesProcessor -func (bp *batchProcessor) ConsumeTraces(_ context.Context, td pdata.Traces) error { +func (bp *batchProcessor) ConsumeTraces(_ context.Context, td ptrace.Traces) error { bp.newItem <- td return nil } // ConsumeMetrics implements MetricsProcessor -func (bp *batchProcessor) ConsumeMetrics(_ context.Context, md pdata.Metrics) error { +func (bp *batchProcessor) ConsumeMetrics(_ context.Context, md pmetric.Metrics) error { // First thing is convert into a different internal format bp.newItem <- md return nil } // ConsumeLogs implements LogsProcessor -func (bp *batchProcessor) ConsumeLogs(_ context.Context, ld pdata.Logs) error { +func (bp *batchProcessor) ConsumeLogs(_ context.Context, ld plog.Logs) error { bp.newItem <- ld return nil } @@ -222,18 +223,18 @@ func newBatchLogsProcessor(set component.ProcessorCreateSettings, next consumer. type batchTraces struct { nextConsumer consumer.Traces - traceData pdata.Traces + traceData ptrace.Traces spanCount int - sizer pdata.TracesSizer + sizer ptrace.Sizer } func newBatchTraces(nextConsumer consumer.Traces) *batchTraces { - return &batchTraces{nextConsumer: nextConsumer, traceData: pdata.NewTraces(), sizer: otlp.NewProtobufTracesMarshaler().(pdata.TracesSizer)} + return &batchTraces{nextConsumer: nextConsumer, traceData: ptrace.NewTraces(), sizer: ptrace.NewProtoMarshaler().(ptrace.Sizer)} } // add updates current batchTraces by adding new TraceData object func (bt *batchTraces) add(item interface{}) { - td := item.(pdata.Traces) + td := item.(ptrace.Traces) newSpanCount := td.SpanCount() if newSpanCount == 0 { return @@ -244,13 +245,13 @@ func (bt *batchTraces) add(item interface{}) { } func (bt *batchTraces) export(ctx context.Context, sendBatchMaxSize int) error { - var req pdata.Traces + var req ptrace.Traces if sendBatchMaxSize > 0 && bt.itemCount() > sendBatchMaxSize { req = splitTraces(sendBatchMaxSize, bt.traceData) bt.spanCount -= sendBatchMaxSize } else { req = bt.traceData - bt.traceData = pdata.NewTraces() + bt.traceData = ptrace.NewTraces() bt.spanCount = 0 } return bt.nextConsumer.ConsumeTraces(ctx, req) @@ -266,23 +267,23 @@ func (bt *batchTraces) size() int { type batchMetrics struct { nextConsumer consumer.Metrics - metricData pdata.Metrics + metricData pmetric.Metrics dataPointCount int - sizer pdata.MetricsSizer + sizer pmetric.Sizer } func newBatchMetrics(nextConsumer consumer.Metrics) *batchMetrics { - return &batchMetrics{nextConsumer: nextConsumer, metricData: pdata.NewMetrics(), sizer: otlp.NewProtobufMetricsMarshaler().(pdata.MetricsSizer)} + return &batchMetrics{nextConsumer: nextConsumer, metricData: pmetric.NewMetrics(), sizer: pmetric.NewProtoMarshaler().(pmetric.Sizer)} } func (bm *batchMetrics) export(ctx context.Context, sendBatchMaxSize int) error { - var req pdata.Metrics + var req pmetric.Metrics if sendBatchMaxSize > 0 && bm.dataPointCount > sendBatchMaxSize { req = splitMetrics(sendBatchMaxSize, bm.metricData) bm.dataPointCount -= sendBatchMaxSize } else { req = bm.metricData - bm.metricData = pdata.NewMetrics() + bm.metricData = pmetric.NewMetrics() bm.dataPointCount = 0 } return bm.nextConsumer.ConsumeMetrics(ctx, req) @@ -297,7 +298,7 @@ func (bm *batchMetrics) size() int { } func (bm *batchMetrics) add(item interface{}) { - md := item.(pdata.Metrics) + md := item.(pmetric.Metrics) newDataPointCount := md.DataPointCount() if newDataPointCount == 0 { @@ -309,23 +310,23 @@ func (bm *batchMetrics) add(item interface{}) { type batchLogs struct { nextConsumer consumer.Logs - logData pdata.Logs + logData plog.Logs logCount int - sizer pdata.LogsSizer + sizer plog.Sizer } func newBatchLogs(nextConsumer consumer.Logs) *batchLogs { - return &batchLogs{nextConsumer: nextConsumer, logData: pdata.NewLogs(), sizer: otlp.NewProtobufLogsMarshaler().(pdata.LogsSizer)} + return &batchLogs{nextConsumer: nextConsumer, logData: plog.NewLogs(), sizer: plog.NewProtoMarshaler().(plog.Sizer)} } func (bl *batchLogs) export(ctx context.Context, sendBatchMaxSize int) error { - var req pdata.Logs + var req plog.Logs if sendBatchMaxSize > 0 && bl.logCount > sendBatchMaxSize { req = splitLogs(sendBatchMaxSize, bl.logData) bl.logCount -= sendBatchMaxSize } else { req = bl.logData - bl.logData = pdata.NewLogs() + bl.logData = plog.NewLogs() bl.logCount = 0 } return bl.nextConsumer.ConsumeLogs(ctx, req) @@ -340,7 +341,7 @@ func (bl *batchLogs) size() int { } func (bl *batchLogs) add(item interface{}) { - ld := item.(pdata.Logs) + ld := item.(plog.Logs) newLogsCount := ld.LogRecordCount() if newLogsCount == 0 { diff --git a/processor/batchprocessor/batch_processor_test.go b/processor/batchprocessor/batch_processor_test.go index 0b23cb7bff8..df85d4cc13a 100644 --- a/processor/batchprocessor/batch_processor_test.go +++ b/processor/batchprocessor/batch_processor_test.go @@ -31,8 +31,9 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) func TestBatchProcessorSpansDelivered(t *testing.T) { @@ -46,7 +47,7 @@ func TestBatchProcessorSpansDelivered(t *testing.T) { requestCount := 1000 spansPerRequest := 100 - traceDataSlice := make([]pdata.Traces, 0, requestCount) + traceDataSlice := make([]ptrace.Traces, 0, requestCount) for requestNum := 0; requestNum < requestCount; requestNum++ { td := testdata.GenerateTracesManySpansSameResource(spansPerRequest) spans := td.ResourceSpans().At(0).ScopeSpans().At(0).Spans() @@ -58,7 +59,7 @@ func TestBatchProcessorSpansDelivered(t *testing.T) { } // Added to test logic that check for empty resources. - td := pdata.NewTraces() + td := ptrace.NewTraces() assert.NoError(t, batcher.ConsumeTraces(context.Background(), td)) require.NoError(t, batcher.Shutdown(context.Background())) @@ -98,7 +99,7 @@ func TestBatchProcessorSpansDeliveredEnforceBatchSize(t *testing.T) { } // Added to test logic that check for empty resources. - td := pdata.NewTraces() + td := ptrace.NewTraces() require.NoError(t, batcher.ConsumeTraces(context.Background(), td)) // wait for all spans to be reported @@ -120,7 +121,7 @@ func TestBatchProcessorSpansDeliveredEnforceBatchSize(t *testing.T) { } func TestBatchProcessorSentBySize(t *testing.T) { - sizer := otlp.NewProtobufTracesMarshaler().(pdata.TracesSizer) + sizer := ptrace.NewProtoMarshaler().(ptrace.Sizer) views := MetricViews() require.NoError(t, view.Register(views...)) defer view.Unregister(views...) @@ -276,7 +277,7 @@ func TestBatchMetricProcessor_ReceivingData(t *testing.T) { require.NoError(t, err) require.NoError(t, batcher.Start(context.Background(), componenttest.NewNopHost())) - metricDataSlice := make([]pdata.Metrics, 0, requestCount) + metricDataSlice := make([]pmetric.Metrics, 0, requestCount) for requestNum := 0; requestNum < requestCount; requestNum++ { md := testdata.GenerateMetricsManyMetricsSameResource(metricsPerRequest) @@ -289,7 +290,7 @@ func TestBatchMetricProcessor_ReceivingData(t *testing.T) { } // Added to test case with empty resources sent. - md := pdata.NewMetrics() + md := pmetric.NewMetrics() assert.NoError(t, batcher.ConsumeMetrics(context.Background(), md)) require.NoError(t, batcher.Shutdown(context.Background())) @@ -308,7 +309,7 @@ func TestBatchMetricProcessor_ReceivingData(t *testing.T) { } func TestBatchMetricProcessor_BatchSize(t *testing.T) { - sizer := otlp.NewProtobufMetricsMarshaler().(pdata.MetricsSizer) + sizer := pmetric.NewProtoMarshaler().(pmetric.Sizer) views := MetricViews() require.NoError(t, view.Register(views...)) defer view.Unregister(views...) @@ -470,8 +471,8 @@ func getTestSpanName(requestNum, index int) string { return fmt.Sprintf("test-span-%d-%d", requestNum, index) } -func spansReceivedByName(tds []pdata.Traces) map[string]pdata.Span { - spansReceivedByName := map[string]pdata.Span{} +func spansReceivedByName(tds []ptrace.Traces) map[string]ptrace.Span { + spansReceivedByName := map[string]ptrace.Span{} for i := range tds { rss := tds[i].ResourceSpans() for i := 0; i < rss.Len(); i++ { @@ -488,8 +489,8 @@ func spansReceivedByName(tds []pdata.Traces) map[string]pdata.Span { return spansReceivedByName } -func metricsReceivedByName(mds []pdata.Metrics) map[string]pdata.Metric { - metricsReceivedByName := map[string]pdata.Metric{} +func metricsReceivedByName(mds []pmetric.Metrics) map[string]pmetric.Metric { + metricsReceivedByName := map[string]pmetric.Metric{} for _, md := range mds { rms := md.ResourceMetrics() for i := 0; i < rms.Len(); i++ { @@ -511,7 +512,7 @@ func getTestMetricName(requestNum, index int) string { } func BenchmarkTraceSizeBytes(b *testing.B) { - sizer := otlp.NewProtobufTracesMarshaler().(pdata.TracesSizer) + sizer := ptrace.NewProtoMarshaler().(ptrace.Sizer) td := testdata.GenerateTracesManySpansSameResource(8192) for n := 0; n < b.N; n++ { fmt.Println(sizer.TracesSize(td)) @@ -541,7 +542,7 @@ func BenchmarkBatchMetricProcessor(b *testing.B) { require.NoError(b, err) require.NoError(b, batcher.Start(ctx, componenttest.NewNopHost())) - mds := make([]pdata.Metrics, 0, b.N) + mds := make([]pmetric.Metrics, 0, b.N) for n := 0; n < b.N; n++ { mds = append(mds, testdata.GenerateMetricsManyMetricsSameResource(metricsPerRequest), @@ -567,7 +568,7 @@ func (sme *metricsSink) Capabilities() consumer.Capabilities { } } -func (sme *metricsSink) ConsumeMetrics(_ context.Context, md pdata.Metrics) error { +func (sme *metricsSink) ConsumeMetrics(_ context.Context, md pmetric.Metrics) error { sme.mu.Lock() defer sme.mu.Unlock() sme.metricsCount += md.MetricCount() @@ -592,7 +593,7 @@ func TestBatchLogProcessor_ReceivingData(t *testing.T) { require.NoError(t, err) require.NoError(t, batcher.Start(context.Background(), componenttest.NewNopHost())) - logDataSlice := make([]pdata.Logs, 0, requestCount) + logDataSlice := make([]plog.Logs, 0, requestCount) for requestNum := 0; requestNum < requestCount; requestNum++ { ld := testdata.GenerateLogsManyLogRecordsSameResource(logsPerRequest) @@ -605,7 +606,7 @@ func TestBatchLogProcessor_ReceivingData(t *testing.T) { } // Added to test case with empty resources sent. - ld := pdata.NewLogs() + ld := plog.NewLogs() assert.NoError(t, batcher.ConsumeLogs(context.Background(), ld)) require.NoError(t, batcher.Shutdown(context.Background())) @@ -624,7 +625,7 @@ func TestBatchLogProcessor_ReceivingData(t *testing.T) { } func TestBatchLogProcessor_BatchSize(t *testing.T) { - sizer := otlp.NewProtobufLogsMarshaler().(pdata.LogsSizer) + sizer := plog.NewProtoMarshaler().(plog.Sizer) views := MetricViews() require.NoError(t, view.Register(views...)) defer view.Unregister(views...) @@ -767,8 +768,8 @@ func getTestLogSeverityText(requestNum, index int) string { return fmt.Sprintf("test-log-int-%d-%d", requestNum, index) } -func logsReceivedBySeverityText(lds []pdata.Logs) map[string]pdata.LogRecord { - logsReceivedBySeverityText := map[string]pdata.LogRecord{} +func logsReceivedBySeverityText(lds []plog.Logs) map[string]plog.LogRecord { + logsReceivedBySeverityText := map[string]plog.LogRecord{} for i := range lds { ld := lds[i] rms := ld.ResourceLogs() diff --git a/processor/batchprocessor/splitlogs.go b/processor/batchprocessor/splitlogs.go index df40efec179..cbd40dbc621 100644 --- a/processor/batchprocessor/splitlogs.go +++ b/processor/batchprocessor/splitlogs.go @@ -15,18 +15,18 @@ package batchprocessor // import "go.opentelemetry.io/collector/processor/batchprocessor" import ( - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) // splitLogs removes logrecords from the input data and returns a new data of the specified size. -func splitLogs(size int, src pdata.Logs) pdata.Logs { +func splitLogs(size int, src plog.Logs) plog.Logs { if src.LogRecordCount() <= size { return src } totalCopiedLogRecords := 0 - dest := pdata.NewLogs() + dest := plog.NewLogs() - src.ResourceLogs().RemoveIf(func(srcRl pdata.ResourceLogs) bool { + src.ResourceLogs().RemoveIf(func(srcRl plog.ResourceLogs) bool { // If we are done skip everything else. if totalCopiedLogRecords == size { return false @@ -42,7 +42,7 @@ func splitLogs(size int, src pdata.Logs) pdata.Logs { destRl := dest.ResourceLogs().AppendEmpty() srcRl.Resource().CopyTo(destRl.Resource()) - srcRl.ScopeLogs().RemoveIf(func(srcIll pdata.ScopeLogs) bool { + srcRl.ScopeLogs().RemoveIf(func(srcIll plog.ScopeLogs) bool { // If we are done skip everything else. if totalCopiedLogRecords == size { return false @@ -58,7 +58,7 @@ func splitLogs(size int, src pdata.Logs) pdata.Logs { destIll := destRl.ScopeLogs().AppendEmpty() srcIll.Scope().CopyTo(destIll.Scope()) - srcIll.LogRecords().RemoveIf(func(srcMetric pdata.LogRecord) bool { + srcIll.LogRecords().RemoveIf(func(srcMetric plog.LogRecord) bool { // If we are done skip everything else. if totalCopiedLogRecords == size { return false @@ -75,8 +75,8 @@ func splitLogs(size int, src pdata.Logs) pdata.Logs { return dest } -// resourceLRC calculates the total number of log records in the pdata.ResourceLogs. -func resourceLRC(rs pdata.ResourceLogs) (count int) { +// resourceLRC calculates the total number of log records in the plog.ResourceLogs. +func resourceLRC(rs plog.ResourceLogs) (count int) { for k := 0; k < rs.ScopeLogs().Len(); k++ { count += rs.ScopeLogs().At(k).LogRecords().Len() } diff --git a/processor/batchprocessor/splitlogs_test.go b/processor/batchprocessor/splitlogs_test.go index 76d874932f2..c7339f4a107 100644 --- a/processor/batchprocessor/splitlogs_test.go +++ b/processor/batchprocessor/splitlogs_test.go @@ -20,7 +20,7 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) func TestSplitLogs_noop(t *testing.T) { @@ -30,7 +30,7 @@ func TestSplitLogs_noop(t *testing.T) { assert.Equal(t, td, split) i := 0 - td.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().RemoveIf(func(_ pdata.LogRecord) bool { + td.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().RemoveIf(func(_ plog.LogRecord) bool { i++ return i > 5 }) @@ -43,7 +43,7 @@ func TestSplitLogs(t *testing.T) { for i := 0; i < logs.Len(); i++ { logs.At(i).SetSeverityText(getTestLogSeverityText(0, i)) } - cp := pdata.NewLogs() + cp := plog.NewLogs() cpLogs := cp.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords() cpLogs.EnsureCapacity(5) ld.ResourceLogs().At(0).Resource().CopyTo( @@ -158,7 +158,7 @@ func TestSplitLogsMultipleILL(t *testing.T) { } func BenchmarkSplitLogs(b *testing.B) { - md := pdata.NewLogs() + md := plog.NewLogs() rms := md.ResourceLogs() for i := 0; i < 20; i++ { testdata.GenerateLogsManyLogRecordsSameResource(20).ResourceLogs().MoveAndAppendTo(md.ResourceLogs()) @@ -172,7 +172,7 @@ func BenchmarkSplitLogs(b *testing.B) { b.Skipf("SKIP: b.N too high, set -benchtime=x with n < 100000") } - clones := make([]pdata.Logs, b.N) + clones := make([]plog.Logs, b.N) for n := 0; n < b.N; n++ { clones[n] = md.Clone() } diff --git a/processor/batchprocessor/splitmetrics.go b/processor/batchprocessor/splitmetrics.go index f1c188984d0..f9394b0e134 100644 --- a/processor/batchprocessor/splitmetrics.go +++ b/processor/batchprocessor/splitmetrics.go @@ -15,19 +15,19 @@ package batchprocessor // import "go.opentelemetry.io/collector/processor/batchprocessor" import ( - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" ) // splitMetrics removes metrics from the input data and returns a new data of the specified size. -func splitMetrics(size int, src pdata.Metrics) pdata.Metrics { +func splitMetrics(size int, src pmetric.Metrics) pmetric.Metrics { dataPoints := src.DataPointCount() if dataPoints <= size { return src } totalCopiedDataPoints := 0 - dest := pdata.NewMetrics() + dest := pmetric.NewMetrics() - src.ResourceMetrics().RemoveIf(func(srcRs pdata.ResourceMetrics) bool { + src.ResourceMetrics().RemoveIf(func(srcRs pmetric.ResourceMetrics) bool { // If we are done skip everything else. if totalCopiedDataPoints == size { return false @@ -43,7 +43,7 @@ func splitMetrics(size int, src pdata.Metrics) pdata.Metrics { destRs := dest.ResourceMetrics().AppendEmpty() srcRs.Resource().CopyTo(destRs.Resource()) - srcRs.ScopeMetrics().RemoveIf(func(srcIlm pdata.ScopeMetrics) bool { + srcRs.ScopeMetrics().RemoveIf(func(srcIlm pmetric.ScopeMetrics) bool { // If we are done skip everything else. if totalCopiedDataPoints == size { return false @@ -59,7 +59,7 @@ func splitMetrics(size int, src pdata.Metrics) pdata.Metrics { destIlm := destRs.ScopeMetrics().AppendEmpty() srcIlm.Scope().CopyTo(destIlm.Scope()) - srcIlm.Metrics().RemoveIf(func(srcMetric pdata.Metric) bool { + srcIlm.Metrics().RemoveIf(func(srcMetric pmetric.Metric) bool { // If we are done skip everything else. if totalCopiedDataPoints == size { return false @@ -86,8 +86,8 @@ func splitMetrics(size int, src pdata.Metrics) pdata.Metrics { return dest } -// resourceMetricsDPC calculates the total number of data points in the pdata.ResourceMetrics. -func resourceMetricsDPC(rs pdata.ResourceMetrics) int { +// resourceMetricsDPC calculates the total number of data points in the pmetric.ResourceMetrics. +func resourceMetricsDPC(rs pmetric.ResourceMetrics) int { dataPointCount := 0 ilms := rs.ScopeMetrics() for k := 0; k < ilms.Len(); k++ { @@ -96,8 +96,8 @@ func resourceMetricsDPC(rs pdata.ResourceMetrics) int { return dataPointCount } -// scopeMetricsDPC calculates the total number of data points in the pdata.ScopeMetrics. -func scopeMetricsDPC(ilm pdata.ScopeMetrics) int { +// scopeMetricsDPC calculates the total number of data points in the pmetric.ScopeMetrics. +func scopeMetricsDPC(ilm pmetric.ScopeMetrics) int { dataPointCount := 0 ms := ilm.Metrics() for k := 0; k < ms.Len(); k++ { @@ -106,18 +106,18 @@ func scopeMetricsDPC(ilm pdata.ScopeMetrics) int { return dataPointCount } -// metricDPC calculates the total number of data points in the pdata.Metric. -func metricDPC(ms pdata.Metric) int { +// metricDPC calculates the total number of data points in the pmetric.Metric. +func metricDPC(ms pmetric.Metric) int { switch ms.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: return ms.Gauge().DataPoints().Len() - case pdata.MetricDataTypeSum: + case pmetric.MetricDataTypeSum: return ms.Sum().DataPoints().Len() - case pdata.MetricDataTypeHistogram: + case pmetric.MetricDataTypeHistogram: return ms.Histogram().DataPoints().Len() - case pdata.MetricDataTypeExponentialHistogram: + case pmetric.MetricDataTypeExponentialHistogram: return ms.ExponentialHistogram().DataPoints().Len() - case pdata.MetricDataTypeSummary: + case pmetric.MetricDataTypeSummary: return ms.Summary().DataPoints().Len() } return 0 @@ -125,35 +125,35 @@ func metricDPC(ms pdata.Metric) int { // splitMetric removes metric points from the input data and moves data of the specified size to destination. // Returns size of moved data and boolean describing, whether the metric should be removed from original slice. -func splitMetric(ms, dest pdata.Metric, size int) (int, bool) { +func splitMetric(ms, dest pmetric.Metric, size int) (int, bool) { dest.SetDataType(ms.DataType()) dest.SetName(ms.Name()) dest.SetDescription(ms.Description()) dest.SetUnit(ms.Unit()) switch ms.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: return splitNumberDataPoints(ms.Gauge().DataPoints(), dest.Gauge().DataPoints(), size) - case pdata.MetricDataTypeSum: + case pmetric.MetricDataTypeSum: dest.Sum().SetAggregationTemporality(ms.Sum().AggregationTemporality()) dest.Sum().SetIsMonotonic(ms.Sum().IsMonotonic()) return splitNumberDataPoints(ms.Sum().DataPoints(), dest.Sum().DataPoints(), size) - case pdata.MetricDataTypeHistogram: + case pmetric.MetricDataTypeHistogram: dest.Histogram().SetAggregationTemporality(ms.Histogram().AggregationTemporality()) return splitHistogramDataPoints(ms.Histogram().DataPoints(), dest.Histogram().DataPoints(), size) - case pdata.MetricDataTypeExponentialHistogram: + case pmetric.MetricDataTypeExponentialHistogram: dest.ExponentialHistogram().SetAggregationTemporality(ms.ExponentialHistogram().AggregationTemporality()) return splitExponentialHistogramDataPoints(ms.ExponentialHistogram().DataPoints(), dest.ExponentialHistogram().DataPoints(), size) - case pdata.MetricDataTypeSummary: + case pmetric.MetricDataTypeSummary: return splitSummaryDataPoints(ms.Summary().DataPoints(), dest.Summary().DataPoints(), size) } return size, false } -func splitNumberDataPoints(src, dst pdata.NumberDataPointSlice, size int) (int, bool) { +func splitNumberDataPoints(src, dst pmetric.NumberDataPointSlice, size int) (int, bool) { dst.EnsureCapacity(size) i := 0 - src.RemoveIf(func(dp pdata.NumberDataPoint) bool { + src.RemoveIf(func(dp pmetric.NumberDataPoint) bool { if i < size { dp.MoveTo(dst.AppendEmpty()) i++ @@ -164,10 +164,10 @@ func splitNumberDataPoints(src, dst pdata.NumberDataPointSlice, size int) (int, return size, false } -func splitHistogramDataPoints(src, dst pdata.HistogramDataPointSlice, size int) (int, bool) { +func splitHistogramDataPoints(src, dst pmetric.HistogramDataPointSlice, size int) (int, bool) { dst.EnsureCapacity(size) i := 0 - src.RemoveIf(func(dp pdata.HistogramDataPoint) bool { + src.RemoveIf(func(dp pmetric.HistogramDataPoint) bool { if i < size { dp.MoveTo(dst.AppendEmpty()) i++ @@ -178,10 +178,10 @@ func splitHistogramDataPoints(src, dst pdata.HistogramDataPointSlice, size int) return size, false } -func splitExponentialHistogramDataPoints(src, dst pdata.ExponentialHistogramDataPointSlice, size int) (int, bool) { +func splitExponentialHistogramDataPoints(src, dst pmetric.ExponentialHistogramDataPointSlice, size int) (int, bool) { dst.EnsureCapacity(size) i := 0 - src.RemoveIf(func(dp pdata.ExponentialHistogramDataPoint) bool { + src.RemoveIf(func(dp pmetric.ExponentialHistogramDataPoint) bool { if i < size { dp.MoveTo(dst.AppendEmpty()) i++ @@ -192,10 +192,10 @@ func splitExponentialHistogramDataPoints(src, dst pdata.ExponentialHistogramData return size, false } -func splitSummaryDataPoints(src, dst pdata.SummaryDataPointSlice, size int) (int, bool) { +func splitSummaryDataPoints(src, dst pmetric.SummaryDataPointSlice, size int) (int, bool) { dst.EnsureCapacity(size) i := 0 - src.RemoveIf(func(dp pdata.SummaryDataPoint) bool { + src.RemoveIf(func(dp pmetric.SummaryDataPoint) bool { if i < size { dp.MoveTo(dst.AppendEmpty()) i++ diff --git a/processor/batchprocessor/splitmetrics_test.go b/processor/batchprocessor/splitmetrics_test.go index 2ba9fa2cd65..b46ee286044 100644 --- a/processor/batchprocessor/splitmetrics_test.go +++ b/processor/batchprocessor/splitmetrics_test.go @@ -20,7 +20,7 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" ) func TestSplitMetrics_noop(t *testing.T) { @@ -30,7 +30,7 @@ func TestSplitMetrics_noop(t *testing.T) { assert.Equal(t, td, split) i := 0 - td.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().RemoveIf(func(_ pdata.Metric) bool { + td.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().RemoveIf(func(_ pmetric.Metric) bool { i++ return i > 5 }) @@ -45,7 +45,7 @@ func TestSplitMetrics(t *testing.T) { metrics.At(i).SetName(getTestMetricName(0, i)) assert.Equal(t, dataPointCount, metricDPC(metrics.At(i))) } - cp := pdata.NewMetrics() + cp := pmetric.NewMetrics() cpMetrics := cp.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() cpMetrics.EnsureCapacity(5) md.ResourceMetrics().At(0).ScopeMetrics().At(0).Scope().CopyTo( @@ -202,7 +202,7 @@ func TestSplitMetricsAllTypes(t *testing.T) { assert.Equal(t, 1, gaugeDouble.Gauge().DataPoints().Len()) assert.Equal(t, "test-metric-int-0-1", gaugeDouble.Name()) assert.Equal(t, 1, sumInt.Sum().DataPoints().Len()) - assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, sumInt.Sum().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, sumInt.Sum().AggregationTemporality()) assert.Equal(t, true, sumInt.Sum().IsMonotonic()) assert.Equal(t, "test-metric-int-0-2", sumInt.Name()) @@ -212,11 +212,11 @@ func TestSplitMetricsAllTypes(t *testing.T) { sumInt = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) sumDouble := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1) assert.Equal(t, 1, sumInt.Sum().DataPoints().Len()) - assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, sumInt.Sum().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, sumInt.Sum().AggregationTemporality()) assert.Equal(t, true, sumInt.Sum().IsMonotonic()) assert.Equal(t, "test-metric-int-0-2", sumInt.Name()) assert.Equal(t, 1, sumDouble.Sum().DataPoints().Len()) - assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, sumDouble.Sum().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, sumDouble.Sum().AggregationTemporality()) assert.Equal(t, true, sumDouble.Sum().IsMonotonic()) assert.Equal(t, "test-metric-int-0-3", sumDouble.Name()) @@ -226,11 +226,11 @@ func TestSplitMetricsAllTypes(t *testing.T) { sumDouble = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) histogram := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1) assert.Equal(t, 1, sumDouble.Sum().DataPoints().Len()) - assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, sumDouble.Sum().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, sumDouble.Sum().AggregationTemporality()) assert.Equal(t, true, sumDouble.Sum().IsMonotonic()) assert.Equal(t, "test-metric-int-0-3", sumDouble.Name()) assert.Equal(t, 1, histogram.Histogram().DataPoints().Len()) - assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, histogram.Histogram().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, histogram.Histogram().AggregationTemporality()) assert.Equal(t, "test-metric-int-0-4", histogram.Name()) split = splitMetrics(splitSize, md) @@ -239,10 +239,10 @@ func TestSplitMetricsAllTypes(t *testing.T) { histogram = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) exponentialHistogram := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1) assert.Equal(t, 1, histogram.Histogram().DataPoints().Len()) - assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, histogram.Histogram().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, histogram.Histogram().AggregationTemporality()) assert.Equal(t, "test-metric-int-0-4", histogram.Name()) assert.Equal(t, 1, exponentialHistogram.ExponentialHistogram().DataPoints().Len()) - assert.Equal(t, pdata.MetricAggregationTemporalityDelta, exponentialHistogram.ExponentialHistogram().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityDelta, exponentialHistogram.ExponentialHistogram().AggregationTemporality()) assert.Equal(t, "test-metric-int-0-5", exponentialHistogram.Name()) split = splitMetrics(splitSize, md) @@ -251,7 +251,7 @@ func TestSplitMetricsAllTypes(t *testing.T) { exponentialHistogram = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) summary := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1) assert.Equal(t, 1, exponentialHistogram.ExponentialHistogram().DataPoints().Len()) - assert.Equal(t, pdata.MetricAggregationTemporalityDelta, exponentialHistogram.ExponentialHistogram().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityDelta, exponentialHistogram.ExponentialHistogram().AggregationTemporality()) assert.Equal(t, "test-metric-int-0-5", exponentialHistogram.Name()) assert.Equal(t, 1, summary.Summary().DataPoints().Len()) assert.Equal(t, "test-metric-int-0-6", summary.Name()) @@ -276,7 +276,7 @@ func TestSplitMetricsBatchSizeSmallerThanDataPointCount(t *testing.T) { splitMetric := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) assert.Equal(t, 1, split.MetricCount()) assert.Equal(t, 2, md.MetricCount()) - assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) assert.Equal(t, true, splitMetric.Sum().IsMonotonic()) assert.Equal(t, "test-metric-int-0-0", splitMetric.Name()) @@ -284,7 +284,7 @@ func TestSplitMetricsBatchSizeSmallerThanDataPointCount(t *testing.T) { splitMetric = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) assert.Equal(t, 1, split.MetricCount()) assert.Equal(t, 1, md.MetricCount()) - assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) assert.Equal(t, true, splitMetric.Sum().IsMonotonic()) assert.Equal(t, "test-metric-int-0-0", splitMetric.Name()) @@ -292,7 +292,7 @@ func TestSplitMetricsBatchSizeSmallerThanDataPointCount(t *testing.T) { splitMetric = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) assert.Equal(t, 1, split.MetricCount()) assert.Equal(t, 1, md.MetricCount()) - assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) assert.Equal(t, true, splitMetric.Sum().IsMonotonic()) assert.Equal(t, "test-metric-int-0-1", splitMetric.Name()) @@ -300,7 +300,7 @@ func TestSplitMetricsBatchSizeSmallerThanDataPointCount(t *testing.T) { splitMetric = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) assert.Equal(t, 1, split.MetricCount()) assert.Equal(t, 1, md.MetricCount()) - assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) + assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) assert.Equal(t, true, splitMetric.Sum().IsMonotonic()) assert.Equal(t, "test-metric-int-0-1", splitMetric.Name()) } @@ -335,7 +335,7 @@ func TestSplitMetricsMultipleILM(t *testing.T) { } func BenchmarkSplitMetrics(b *testing.B) { - md := pdata.NewMetrics() + md := pmetric.NewMetrics() rms := md.ResourceMetrics() for i := 0; i < 20; i++ { testdata.GenerateMetricsManyMetricsSameResource(20).ResourceMetrics().MoveAndAppendTo(md.ResourceMetrics()) @@ -350,7 +350,7 @@ func BenchmarkSplitMetrics(b *testing.B) { } dataPointCount := metricDPC(md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)) - clones := make([]pdata.Metrics, b.N) + clones := make([]pmetric.Metrics, b.N) for n := 0; n < b.N; n++ { clones[n] = md.Clone() } diff --git a/processor/batchprocessor/splittraces.go b/processor/batchprocessor/splittraces.go index e8fbf779b7b..6c1212682ee 100644 --- a/processor/batchprocessor/splittraces.go +++ b/processor/batchprocessor/splittraces.go @@ -15,18 +15,18 @@ package batchprocessor // import "go.opentelemetry.io/collector/processor/batchprocessor" import ( - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) // splitTraces removes spans from the input trace and returns a new trace of the specified size. -func splitTraces(size int, src pdata.Traces) pdata.Traces { +func splitTraces(size int, src ptrace.Traces) ptrace.Traces { if src.SpanCount() <= size { return src } totalCopiedSpans := 0 - dest := pdata.NewTraces() + dest := ptrace.NewTraces() - src.ResourceSpans().RemoveIf(func(srcRs pdata.ResourceSpans) bool { + src.ResourceSpans().RemoveIf(func(srcRs ptrace.ResourceSpans) bool { // If we are done skip everything else. if totalCopiedSpans == size { return false @@ -42,7 +42,7 @@ func splitTraces(size int, src pdata.Traces) pdata.Traces { destRs := dest.ResourceSpans().AppendEmpty() srcRs.Resource().CopyTo(destRs.Resource()) - srcRs.ScopeSpans().RemoveIf(func(srcIls pdata.ScopeSpans) bool { + srcRs.ScopeSpans().RemoveIf(func(srcIls ptrace.ScopeSpans) bool { // If we are done skip everything else. if totalCopiedSpans == size { return false @@ -58,7 +58,7 @@ func splitTraces(size int, src pdata.Traces) pdata.Traces { destIls := destRs.ScopeSpans().AppendEmpty() srcIls.Scope().CopyTo(destIls.Scope()) - srcIls.Spans().RemoveIf(func(srcSpan pdata.Span) bool { + srcIls.Spans().RemoveIf(func(srcSpan ptrace.Span) bool { // If we are done skip everything else. if totalCopiedSpans == size { return false @@ -75,8 +75,8 @@ func splitTraces(size int, src pdata.Traces) pdata.Traces { return dest } -// resourceSC calculates the total number of spans in the pdata.ResourceSpans. -func resourceSC(rs pdata.ResourceSpans) (count int) { +// resourceSC calculates the total number of spans in the ptrace.ResourceSpans. +func resourceSC(rs ptrace.ResourceSpans) (count int) { for k := 0; k < rs.ScopeSpans().Len(); k++ { count += rs.ScopeSpans().At(k).Spans().Len() } diff --git a/processor/batchprocessor/splittraces_test.go b/processor/batchprocessor/splittraces_test.go index 863054ad544..61b859a0cfe 100644 --- a/processor/batchprocessor/splittraces_test.go +++ b/processor/batchprocessor/splittraces_test.go @@ -20,7 +20,7 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) func TestSplitTraces_noop(t *testing.T) { @@ -30,7 +30,7 @@ func TestSplitTraces_noop(t *testing.T) { assert.Equal(t, td, split) i := 0 - td.ResourceSpans().At(0).ScopeSpans().At(0).Spans().RemoveIf(func(_ pdata.Span) bool { + td.ResourceSpans().At(0).ScopeSpans().At(0).Spans().RemoveIf(func(_ ptrace.Span) bool { i++ return i > 5 }) @@ -43,7 +43,7 @@ func TestSplitTraces(t *testing.T) { for i := 0; i < spans.Len(); i++ { spans.At(i).SetName(getTestSpanName(0, i)) } - cp := pdata.NewTraces() + cp := ptrace.NewTraces() cpSpans := cp.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty().Spans() cpSpans.EnsureCapacity(5) td.ResourceSpans().At(0).Resource().CopyTo( @@ -128,7 +128,7 @@ func TestSplitTracesMultipleResourceSpans_SplitSizeGreaterThanSpanSize(t *testin } func BenchmarkCloneSpans(b *testing.B) { - td := pdata.NewTraces() + td := ptrace.NewTraces() rms := td.ResourceSpans() for i := 0; i < 20; i++ { testdata.GenerateTracesManySpansSameResource(20).ResourceSpans().MoveAndAppendTo(td.ResourceSpans()) @@ -179,7 +179,7 @@ func TestSplitTracesMultipleILS(t *testing.T) { } func BenchmarkSplitTraces(b *testing.B) { - td := pdata.NewTraces() + td := ptrace.NewTraces() rms := td.ResourceSpans() for i := 0; i < 20; i++ { testdata.GenerateTracesManySpansSameResource(20).ResourceSpans().MoveAndAppendTo(td.ResourceSpans()) @@ -193,7 +193,7 @@ func BenchmarkSplitTraces(b *testing.B) { b.Skipf("SKIP: b.N too high, set -benchtime=x with n < 100000") } - clones := make([]pdata.Traces, b.N) + clones := make([]ptrace.Traces, b.N) for n := 0; n < b.N; n++ { clones[n] = td.Clone() } diff --git a/processor/memorylimiterprocessor/memorylimiter.go b/processor/memorylimiterprocessor/memorylimiter.go index 93cfe0dbad8..42cf5ab7f3f 100644 --- a/processor/memorylimiterprocessor/memorylimiter.go +++ b/processor/memorylimiterprocessor/memorylimiter.go @@ -28,8 +28,10 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/extension/ballastextension" "go.opentelemetry.io/collector/internal/iruntime" - "go.opentelemetry.io/collector/model/pdata" "go.opentelemetry.io/collector/obsreport" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) const ( @@ -169,7 +171,7 @@ func (ml *memoryLimiter) shutdown(context.Context) error { return nil } -func (ml *memoryLimiter) processTraces(ctx context.Context, td pdata.Traces) (pdata.Traces, error) { +func (ml *memoryLimiter) processTraces(ctx context.Context, td ptrace.Traces) (ptrace.Traces, error) { numSpans := td.SpanCount() if ml.forcingDrop() { // TODO: actually to be 100% sure that this is "refused" and not "dropped" @@ -188,7 +190,7 @@ func (ml *memoryLimiter) processTraces(ctx context.Context, td pdata.Traces) (pd return td, nil } -func (ml *memoryLimiter) processMetrics(ctx context.Context, md pdata.Metrics) (pdata.Metrics, error) { +func (ml *memoryLimiter) processMetrics(ctx context.Context, md pmetric.Metrics) (pmetric.Metrics, error) { numDataPoints := md.DataPointCount() if ml.forcingDrop() { // TODO: actually to be 100% sure that this is "refused" and not "dropped" @@ -206,7 +208,7 @@ func (ml *memoryLimiter) processMetrics(ctx context.Context, md pdata.Metrics) ( return md, nil } -func (ml *memoryLimiter) processLogs(ctx context.Context, ld pdata.Logs) (pdata.Logs, error) { +func (ml *memoryLimiter) processLogs(ctx context.Context, ld plog.Logs) (plog.Logs, error) { numRecords := ld.LogRecordCount() if ml.forcingDrop() { // TODO: actually to be 100% sure that this is "refused" and not "dropped" diff --git a/processor/memorylimiterprocessor/memorylimiter_test.go b/processor/memorylimiterprocessor/memorylimiter_test.go index 33f2add071b..1d15405f877 100644 --- a/processor/memorylimiterprocessor/memorylimiter_test.go +++ b/processor/memorylimiterprocessor/memorylimiter_test.go @@ -31,8 +31,10 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/extension/ballastextension" "go.opentelemetry.io/collector/internal/iruntime" - "go.opentelemetry.io/collector/model/pdata" "go.opentelemetry.io/collector/obsreport" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/collector/processor/processorhelper" ) @@ -131,7 +133,7 @@ func TestMetricsMemoryPressureResponse(t *testing.T) { require.NoError(t, err) ctx := context.Background() - md := pdata.NewMetrics() + md := pmetric.NewMetrics() // Below memAllocLimit. currentMemAlloc = 800 @@ -202,7 +204,7 @@ func TestTraceMemoryPressureResponse(t *testing.T) { require.NoError(t, err) ctx := context.Background() - td := pdata.NewTraces() + td := ptrace.NewTraces() // Below memAllocLimit. currentMemAlloc = 800 @@ -273,7 +275,7 @@ func TestLogMemoryPressureResponse(t *testing.T) { require.NoError(t, err) ctx := context.Background() - ld := pdata.NewLogs() + ld := plog.NewLogs() // Below memAllocLimit. currentMemAlloc = 800 diff --git a/processor/processorhelper/logs.go b/processor/processorhelper/logs.go index 822a0c99a4b..8520df99820 100644 --- a/processor/processorhelper/logs.go +++ b/processor/processorhelper/logs.go @@ -24,12 +24,12 @@ import ( "go.opentelemetry.io/collector/component/componenterror" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) // ProcessLogsFunc is a helper function that processes the incoming data and returns the data to be sent to the next component. // If error is returned then returned data are ignored. It MUST not call the next component. -type ProcessLogsFunc func(context.Context, pdata.Logs) (pdata.Logs, error) +type ProcessLogsFunc func(context.Context, plog.Logs) (plog.Logs, error) type logProcessor struct { component.StartFunc @@ -55,7 +55,7 @@ func NewLogsProcessor( eventOptions := spanAttributes(cfg.ID()) bs := fromOptions(options) - logsConsumer, err := consumer.NewLogs(func(ctx context.Context, ld pdata.Logs) error { + logsConsumer, err := consumer.NewLogs(func(ctx context.Context, ld plog.Logs) error { span := trace.SpanFromContext(ctx) span.AddEvent("Start processing.", eventOptions) var err error diff --git a/processor/processorhelper/logs_test.go b/processor/processorhelper/logs_test.go index efe04e07fb5..7a8d56786ca 100644 --- a/processor/processorhelper/logs_test.go +++ b/processor/processorhelper/logs_test.go @@ -28,7 +28,7 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) var testLogsCfg = config.NewProcessorSettings(config.NewComponentID("test")) @@ -39,7 +39,7 @@ func TestNewLogsProcessor(t *testing.T) { assert.True(t, lp.Capabilities().MutatesData) assert.NoError(t, lp.Start(context.Background(), componenttest.NewNopHost())) - assert.NoError(t, lp.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.NoError(t, lp.ConsumeLogs(context.Background(), plog.NewLogs())) assert.NoError(t, lp.Shutdown(context.Background())) } @@ -68,17 +68,17 @@ func TestNewLogsProcessor_ProcessLogError(t *testing.T) { want := errors.New("my_error") lp, err := NewLogsProcessor(&testLogsCfg, consumertest.NewNop(), newTestLProcessor(want)) require.NoError(t, err) - assert.Equal(t, want, lp.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.Equal(t, want, lp.ConsumeLogs(context.Background(), plog.NewLogs())) } func TestNewLogsProcessor_ProcessLogsErrSkipProcessingData(t *testing.T) { lp, err := NewLogsProcessor(&testLogsCfg, consumertest.NewNop(), newTestLProcessor(ErrSkipProcessingData)) require.NoError(t, err) - assert.Equal(t, nil, lp.ConsumeLogs(context.Background(), pdata.NewLogs())) + assert.Equal(t, nil, lp.ConsumeLogs(context.Background(), plog.NewLogs())) } func newTestLProcessor(retError error) ProcessLogsFunc { - return func(_ context.Context, ld pdata.Logs) (pdata.Logs, error) { + return func(_ context.Context, ld plog.Logs) (plog.Logs, error) { return ld, retError } } diff --git a/processor/processorhelper/metrics.go b/processor/processorhelper/metrics.go index 4585e51fda5..30316debbe2 100644 --- a/processor/processorhelper/metrics.go +++ b/processor/processorhelper/metrics.go @@ -24,12 +24,12 @@ import ( "go.opentelemetry.io/collector/component/componenterror" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" ) // ProcessMetricsFunc is a helper function that processes the incoming data and returns the data to be sent to the next component. // If error is returned then returned data are ignored. It MUST not call the next component. -type ProcessMetricsFunc func(context.Context, pdata.Metrics) (pdata.Metrics, error) +type ProcessMetricsFunc func(context.Context, pmetric.Metrics) (pmetric.Metrics, error) type metricsProcessor struct { component.StartFunc @@ -55,7 +55,7 @@ func NewMetricsProcessor( eventOptions := spanAttributes(cfg.ID()) bs := fromOptions(options) - metricsConsumer, err := consumer.NewMetrics(func(ctx context.Context, md pdata.Metrics) error { + metricsConsumer, err := consumer.NewMetrics(func(ctx context.Context, md pmetric.Metrics) error { span := trace.SpanFromContext(ctx) span.AddEvent("Start processing.", eventOptions) var err error diff --git a/processor/processorhelper/metrics_test.go b/processor/processorhelper/metrics_test.go index 5e568037546..a95c8015832 100644 --- a/processor/processorhelper/metrics_test.go +++ b/processor/processorhelper/metrics_test.go @@ -28,7 +28,7 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" ) var testMetricsCfg = config.NewProcessorSettings(config.NewComponentID("test")) @@ -39,7 +39,7 @@ func TestNewMetricsProcessor(t *testing.T) { assert.True(t, mp.Capabilities().MutatesData) assert.NoError(t, mp.Start(context.Background(), componenttest.NewNopHost())) - assert.NoError(t, mp.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.NoError(t, mp.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) assert.NoError(t, mp.Shutdown(context.Background())) } @@ -68,17 +68,17 @@ func TestNewMetricsProcessor_ProcessMetricsError(t *testing.T) { want := errors.New("my_error") mp, err := NewMetricsProcessor(&testMetricsCfg, consumertest.NewNop(), newTestMProcessor(want)) require.NoError(t, err) - assert.Equal(t, want, mp.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.Equal(t, want, mp.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) } func TestNewMetricsProcessor_ProcessMetricsErrSkipProcessingData(t *testing.T) { mp, err := NewMetricsProcessor(&testMetricsCfg, consumertest.NewNop(), newTestMProcessor(ErrSkipProcessingData)) require.NoError(t, err) - assert.Equal(t, nil, mp.ConsumeMetrics(context.Background(), pdata.NewMetrics())) + assert.Equal(t, nil, mp.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) } func newTestMProcessor(retError error) ProcessMetricsFunc { - return func(_ context.Context, md pdata.Metrics) (pdata.Metrics, error) { + return func(_ context.Context, md pmetric.Metrics) (pmetric.Metrics, error) { return md, retError } } diff --git a/processor/processorhelper/traces.go b/processor/processorhelper/traces.go index b802c539ea7..2d7c2e953aa 100644 --- a/processor/processorhelper/traces.go +++ b/processor/processorhelper/traces.go @@ -24,12 +24,12 @@ import ( "go.opentelemetry.io/collector/component/componenterror" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) // ProcessTracesFunc is a helper function that processes the incoming data and returns the data to be sent to the next component. // If error is returned then returned data are ignored. It MUST not call the next component. -type ProcessTracesFunc func(context.Context, pdata.Traces) (pdata.Traces, error) +type ProcessTracesFunc func(context.Context, ptrace.Traces) (ptrace.Traces, error) type tracesProcessor struct { component.StartFunc @@ -55,7 +55,7 @@ func NewTracesProcessor( eventOptions := spanAttributes(cfg.ID()) bs := fromOptions(options) - traceConsumer, err := consumer.NewTraces(func(ctx context.Context, td pdata.Traces) error { + traceConsumer, err := consumer.NewTraces(func(ctx context.Context, td ptrace.Traces) error { span := trace.SpanFromContext(ctx) span.AddEvent("Start processing.", eventOptions) var err error diff --git a/processor/processorhelper/traces_test.go b/processor/processorhelper/traces_test.go index de2cc9209ac..3ece81ffe91 100644 --- a/processor/processorhelper/traces_test.go +++ b/processor/processorhelper/traces_test.go @@ -28,7 +28,7 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) var testTracesCfg = config.NewProcessorSettings(config.NewComponentID("test")) @@ -39,7 +39,7 @@ func TestNewTracesProcessor(t *testing.T) { assert.True(t, tp.Capabilities().MutatesData) assert.NoError(t, tp.Start(context.Background(), componenttest.NewNopHost())) - assert.NoError(t, tp.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.NoError(t, tp.ConsumeTraces(context.Background(), ptrace.NewTraces())) assert.NoError(t, tp.Shutdown(context.Background())) } @@ -68,17 +68,17 @@ func TestNewTracesProcessor_ProcessTraceError(t *testing.T) { want := errors.New("my_error") tp, err := NewTracesProcessor(&testTracesCfg, consumertest.NewNop(), newTestTProcessor(want)) require.NoError(t, err) - assert.Equal(t, want, tp.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.Equal(t, want, tp.ConsumeTraces(context.Background(), ptrace.NewTraces())) } func TestNewTracesProcessor_ProcessTracesErrSkipProcessingData(t *testing.T) { tp, err := NewTracesProcessor(&testTracesCfg, consumertest.NewNop(), newTestTProcessor(ErrSkipProcessingData)) require.NoError(t, err) - assert.Equal(t, nil, tp.ConsumeTraces(context.Background(), pdata.NewTraces())) + assert.Equal(t, nil, tp.ConsumeTraces(context.Background(), ptrace.NewTraces())) } func newTestTProcessor(retError error) ProcessTracesFunc { - return func(_ context.Context, td pdata.Traces) (pdata.Traces, error) { + return func(_ context.Context, td ptrace.Traces) (ptrace.Traces, error) { return td, retError } } diff --git a/proto_patch.sed b/proto_patch.sed index 2cd96c47a3f..d00e35af57c 100644 --- a/proto_patch.sed +++ b/proto_patch.sed @@ -1,4 +1,4 @@ -s+go.opentelemetry.io/proto/otlp/+go.opentelemetry.io/collector/model/internal/data/protogen/+g +s+go.opentelemetry.io/proto/otlp/+go.opentelemetry.io/collector/pdata/internal/data/protogen/+g s+package opentelemetry.proto.\(.*\).v1;+package opentelemetry.proto.\1.v1;\ \ @@ -8,14 +8,14 @@ s+bytes trace_id = \(.*\);+bytes trace_id = \1\ [\ // Use custom TraceId data type for this field.\ (gogoproto.nullable) = false,\ - (gogoproto.customtype) = "go.opentelemetry.io/collector/model/internal/data.TraceID"\ + (gogoproto.customtype) = "go.opentelemetry.io/collector/pdata/internal/data.TraceID"\ ];+g s+bytes \(.*span_id\) = \(.*\);+bytes \1 = \2\ [\ // Use custom SpanId data type for this field.\ (gogoproto.nullable) = false,\ - (gogoproto.customtype) = "go.opentelemetry.io/collector/model/internal/data.SpanID"\ + (gogoproto.customtype) = "go.opentelemetry.io/collector/pdata/internal/data.SpanID"\ ];+g s+repeated opentelemetry.proto.common.v1.KeyValue \(.*\);+repeated opentelemetry.proto.common.v1.KeyValue \1\ diff --git a/receiver/otlpreceiver/encoder.go b/receiver/otlpreceiver/encoder.go index 0d426acdb82..c486eebf07c 100644 --- a/receiver/otlpreceiver/encoder.go +++ b/receiver/otlpreceiver/encoder.go @@ -21,7 +21,9 @@ import ( "github.com/gogo/protobuf/proto" spb "google.golang.org/genproto/googleapis/rpc/status" - "go.opentelemetry.io/collector/model/otlpgrpc" + "go.opentelemetry.io/collector/pdata/plog/plogotlp" + "go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp" + "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" ) const ( @@ -36,13 +38,13 @@ var ( ) type encoder interface { - unmarshalTracesRequest(buf []byte) (otlpgrpc.TracesRequest, error) - unmarshalMetricsRequest(buf []byte) (otlpgrpc.MetricsRequest, error) - unmarshalLogsRequest(buf []byte) (otlpgrpc.LogsRequest, error) + unmarshalTracesRequest(buf []byte) (ptraceotlp.Request, error) + unmarshalMetricsRequest(buf []byte) (pmetricotlp.Request, error) + unmarshalLogsRequest(buf []byte) (plogotlp.Request, error) - marshalTracesResponse(otlpgrpc.TracesResponse) ([]byte, error) - marshalMetricsResponse(otlpgrpc.MetricsResponse) ([]byte, error) - marshalLogsResponse(otlpgrpc.LogsResponse) ([]byte, error) + marshalTracesResponse(ptraceotlp.Response) ([]byte, error) + marshalMetricsResponse(pmetricotlp.Response) ([]byte, error) + marshalLogsResponse(plogotlp.Response) ([]byte, error) marshalStatus(rsp *spb.Status) ([]byte, error) @@ -51,33 +53,33 @@ type encoder interface { type protoEncoder struct{} -func (protoEncoder) unmarshalTracesRequest(buf []byte) (otlpgrpc.TracesRequest, error) { - req := otlpgrpc.NewTracesRequest() +func (protoEncoder) unmarshalTracesRequest(buf []byte) (ptraceotlp.Request, error) { + req := ptraceotlp.NewRequest() err := req.UnmarshalProto(buf) return req, err } -func (protoEncoder) unmarshalMetricsRequest(buf []byte) (otlpgrpc.MetricsRequest, error) { - req := otlpgrpc.NewMetricsRequest() +func (protoEncoder) unmarshalMetricsRequest(buf []byte) (pmetricotlp.Request, error) { + req := pmetricotlp.NewRequest() err := req.UnmarshalProto(buf) return req, err } -func (protoEncoder) unmarshalLogsRequest(buf []byte) (otlpgrpc.LogsRequest, error) { - req := otlpgrpc.NewLogsRequest() +func (protoEncoder) unmarshalLogsRequest(buf []byte) (plogotlp.Request, error) { + req := plogotlp.NewRequest() err := req.UnmarshalProto(buf) return req, err } -func (protoEncoder) marshalTracesResponse(resp otlpgrpc.TracesResponse) ([]byte, error) { +func (protoEncoder) marshalTracesResponse(resp ptraceotlp.Response) ([]byte, error) { return resp.MarshalProto() } -func (protoEncoder) marshalMetricsResponse(resp otlpgrpc.MetricsResponse) ([]byte, error) { +func (protoEncoder) marshalMetricsResponse(resp pmetricotlp.Response) ([]byte, error) { return resp.MarshalProto() } -func (protoEncoder) marshalLogsResponse(resp otlpgrpc.LogsResponse) ([]byte, error) { +func (protoEncoder) marshalLogsResponse(resp plogotlp.Response) ([]byte, error) { return resp.MarshalProto() } @@ -91,33 +93,33 @@ func (protoEncoder) contentType() string { type jsonEncoder struct{} -func (jsonEncoder) unmarshalTracesRequest(buf []byte) (otlpgrpc.TracesRequest, error) { - req := otlpgrpc.NewTracesRequest() +func (jsonEncoder) unmarshalTracesRequest(buf []byte) (ptraceotlp.Request, error) { + req := ptraceotlp.NewRequest() err := req.UnmarshalJSON(buf) return req, err } -func (jsonEncoder) unmarshalMetricsRequest(buf []byte) (otlpgrpc.MetricsRequest, error) { - req := otlpgrpc.NewMetricsRequest() +func (jsonEncoder) unmarshalMetricsRequest(buf []byte) (pmetricotlp.Request, error) { + req := pmetricotlp.NewRequest() err := req.UnmarshalJSON(buf) return req, err } -func (jsonEncoder) unmarshalLogsRequest(buf []byte) (otlpgrpc.LogsRequest, error) { - req := otlpgrpc.NewLogsRequest() +func (jsonEncoder) unmarshalLogsRequest(buf []byte) (plogotlp.Request, error) { + req := plogotlp.NewRequest() err := req.UnmarshalJSON(buf) return req, err } -func (jsonEncoder) marshalTracesResponse(resp otlpgrpc.TracesResponse) ([]byte, error) { +func (jsonEncoder) marshalTracesResponse(resp ptraceotlp.Response) ([]byte, error) { return resp.MarshalJSON() } -func (jsonEncoder) marshalMetricsResponse(resp otlpgrpc.MetricsResponse) ([]byte, error) { +func (jsonEncoder) marshalMetricsResponse(resp pmetricotlp.Response) ([]byte, error) { return resp.MarshalJSON() } -func (jsonEncoder) marshalLogsResponse(resp otlpgrpc.LogsResponse) ([]byte, error) { +func (jsonEncoder) marshalLogsResponse(resp plogotlp.Response) ([]byte, error) { return resp.MarshalJSON() } diff --git a/receiver/otlpreceiver/internal/logs/otlp.go b/receiver/otlpreceiver/internal/logs/otlp.go index 8bdca9ec0c4..898a6ae9f28 100644 --- a/receiver/otlpreceiver/internal/logs/otlp.go +++ b/receiver/otlpreceiver/internal/logs/otlp.go @@ -20,8 +20,8 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/otlpgrpc" "go.opentelemetry.io/collector/obsreport" + "go.opentelemetry.io/collector/pdata/plog/plogotlp" ) const ( @@ -48,16 +48,16 @@ func New(id config.ComponentID, nextConsumer consumer.Logs, set component.Receiv } // Export implements the service Export logs func. -func (r *Receiver) Export(ctx context.Context, req otlpgrpc.LogsRequest) (otlpgrpc.LogsResponse, error) { +func (r *Receiver) Export(ctx context.Context, req plogotlp.Request) (plogotlp.Response, error) { ld := req.Logs() numSpans := ld.LogRecordCount() if numSpans == 0 { - return otlpgrpc.NewLogsResponse(), nil + return plogotlp.NewResponse(), nil } ctx = r.obsrecv.StartLogsOp(ctx) err := r.nextConsumer.ConsumeLogs(ctx, ld) r.obsrecv.EndLogsOp(ctx, dataFormatProtobuf, numSpans, err) - return otlpgrpc.NewLogsResponse(), err + return plogotlp.NewResponse(), err } diff --git a/receiver/otlpreceiver/internal/logs/otlp_test.go b/receiver/otlpreceiver/internal/logs/otlp_test.go index e64ce9d8c87..d7fe67d66e8 100644 --- a/receiver/otlpreceiver/internal/logs/otlp_test.go +++ b/receiver/otlpreceiver/internal/logs/otlp_test.go @@ -30,7 +30,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/otlpgrpc" + "go.opentelemetry.io/collector/pdata/plog/plogotlp" ) func TestExport(t *testing.T) { @@ -47,7 +47,7 @@ func TestExport(t *testing.T) { // Keep log data to compare the test result against it // Clone needed because OTLP proto XXX_ fields are altered in the GRPC downstream logData := ld.Clone() - req := otlpgrpc.NewLogsRequest() + req := plogotlp.NewRequest() req.SetLogs(ld) resp, err := traceClient.Export(context.Background(), req) @@ -69,7 +69,7 @@ func TestExport_EmptyRequest(t *testing.T) { require.NoError(t, err, "Failed to create the TraceServiceClient: %v", err) defer logClientDoneFn() - resp, err := logClient.Export(context.Background(), otlpgrpc.NewLogsRequest()) + resp, err := logClient.Export(context.Background(), plogotlp.NewRequest()) assert.NoError(t, err, "Failed to export trace: %v", err) assert.NotNil(t, resp, "The response is missing") } @@ -83,21 +83,21 @@ func TestExport_ErrorConsumer(t *testing.T) { defer logClientDoneFn() ld := testdata.GenerateLogsOneLogRecord() - req := otlpgrpc.NewLogsRequest() + req := plogotlp.NewRequest() req.SetLogs(ld) resp, err := logClient.Export(context.Background(), req) assert.EqualError(t, err, "rpc error: code = Unknown desc = my error") - assert.Equal(t, otlpgrpc.LogsResponse{}, resp) + assert.Equal(t, plogotlp.Response{}, resp) } -func makeLogsServiceClient(addr net.Addr) (otlpgrpc.LogsClient, func(), error) { +func makeLogsServiceClient(addr net.Addr) (plogotlp.Client, func(), error) { cc, err := grpc.Dial(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) if err != nil { return nil, nil, err } - logClient := otlpgrpc.NewLogsClient(cc) + logClient := plogotlp.NewClient(cc) doneFn := func() { _ = cc.Close() } return logClient, doneFn, nil @@ -119,7 +119,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, tc consumer.Logs) (net.Addr, func()) // Now run it as a gRPC server srv := grpc.NewServer() - otlpgrpc.RegisterLogsServer(srv, r) + plogotlp.RegisterServer(srv, r) go func() { _ = srv.Serve(ln) }() diff --git a/receiver/otlpreceiver/internal/metrics/otlp.go b/receiver/otlpreceiver/internal/metrics/otlp.go index 3a6c01bee11..514910958a6 100644 --- a/receiver/otlpreceiver/internal/metrics/otlp.go +++ b/receiver/otlpreceiver/internal/metrics/otlp.go @@ -20,8 +20,8 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/otlpgrpc" "go.opentelemetry.io/collector/obsreport" + "go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp" ) const ( @@ -48,16 +48,16 @@ func New(id config.ComponentID, nextConsumer consumer.Metrics, set component.Rec } // Export implements the service Export metrics func. -func (r *Receiver) Export(ctx context.Context, req otlpgrpc.MetricsRequest) (otlpgrpc.MetricsResponse, error) { +func (r *Receiver) Export(ctx context.Context, req pmetricotlp.Request) (pmetricotlp.Response, error) { md := req.Metrics() dataPointCount := md.DataPointCount() if dataPointCount == 0 { - return otlpgrpc.NewMetricsResponse(), nil + return pmetricotlp.NewResponse(), nil } ctx = r.obsrecv.StartMetricsOp(ctx) err := r.nextConsumer.ConsumeMetrics(ctx, md) r.obsrecv.EndMetricsOp(ctx, dataFormatProtobuf, dataPointCount, err) - return otlpgrpc.NewMetricsResponse(), err + return pmetricotlp.NewResponse(), err } diff --git a/receiver/otlpreceiver/internal/metrics/otlp_test.go b/receiver/otlpreceiver/internal/metrics/otlp_test.go index 949a63a3129..a998cad2db5 100644 --- a/receiver/otlpreceiver/internal/metrics/otlp_test.go +++ b/receiver/otlpreceiver/internal/metrics/otlp_test.go @@ -30,7 +30,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/otlpgrpc" + "go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp" ) func TestExport(t *testing.T) { @@ -49,7 +49,7 @@ func TestExport(t *testing.T) { // Clone needed because OTLP proto XXX_ fields are altered in the GRPC downstream metricData := md.Clone() - req := otlpgrpc.NewMetricsRequest() + req := pmetricotlp.NewRequest() req.SetMetrics(md) resp, err := metricsClient.Export(context.Background(), req) @@ -71,7 +71,7 @@ func TestExport_EmptyRequest(t *testing.T) { require.NoError(t, err, "Failed to create the MetricsServiceClient: %v", err) defer metricsClientDoneFn() - resp, err := metricsClient.Export(context.Background(), otlpgrpc.NewMetricsRequest()) + resp, err := metricsClient.Export(context.Background(), pmetricotlp.NewRequest()) require.NoError(t, err) require.NotNil(t, resp) } @@ -85,21 +85,21 @@ func TestExport_ErrorConsumer(t *testing.T) { defer metricsClientDoneFn() md := testdata.GenerateMetricsOneMetric() - req := otlpgrpc.NewMetricsRequest() + req := pmetricotlp.NewRequest() req.SetMetrics(md) resp, err := metricsClient.Export(context.Background(), req) assert.EqualError(t, err, "rpc error: code = Unknown desc = my error") - assert.Equal(t, otlpgrpc.MetricsResponse{}, resp) + assert.Equal(t, pmetricotlp.Response{}, resp) } -func makeMetricsServiceClient(addr net.Addr) (otlpgrpc.MetricsClient, func(), error) { +func makeMetricsServiceClient(addr net.Addr) (pmetricotlp.Client, func(), error) { cc, err := grpc.Dial(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) if err != nil { return nil, nil, err } - metricsClient := otlpgrpc.NewMetricsClient(cc) + metricsClient := pmetricotlp.NewClient(cc) doneFn := func() { _ = cc.Close() } return metricsClient, doneFn, nil @@ -119,7 +119,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, mc consumer.Metrics) (net.Addr, func r := New(config.NewComponentIDWithName("otlp", "metrics"), mc, componenttest.NewNopReceiverCreateSettings()) // Now run it as a gRPC server srv := grpc.NewServer() - otlpgrpc.RegisterMetricsServer(srv, r) + pmetricotlp.RegisterServer(srv, r) go func() { _ = srv.Serve(ln) }() diff --git a/receiver/otlpreceiver/internal/trace/otlp.go b/receiver/otlpreceiver/internal/trace/otlp.go index cb20562e1b3..d92cd08fb5a 100644 --- a/receiver/otlpreceiver/internal/trace/otlp.go +++ b/receiver/otlpreceiver/internal/trace/otlp.go @@ -20,8 +20,8 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/otlpgrpc" "go.opentelemetry.io/collector/obsreport" + "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" ) const ( @@ -48,17 +48,17 @@ func New(id config.ComponentID, nextConsumer consumer.Traces, set component.Rece } // Export implements the service Export traces func. -func (r *Receiver) Export(ctx context.Context, req otlpgrpc.TracesRequest) (otlpgrpc.TracesResponse, error) { +func (r *Receiver) Export(ctx context.Context, req ptraceotlp.Request) (ptraceotlp.Response, error) { td := req.Traces() // We need to ensure that it propagates the receiver name as a tag numSpans := td.SpanCount() if numSpans == 0 { - return otlpgrpc.NewTracesResponse(), nil + return ptraceotlp.NewResponse(), nil } ctx = r.obsrecv.StartTracesOp(ctx) err := r.nextConsumer.ConsumeTraces(ctx, td) r.obsrecv.EndTracesOp(ctx, dataFormatProtobuf, numSpans, err) - return otlpgrpc.NewTracesResponse(), err + return ptraceotlp.NewResponse(), err } diff --git a/receiver/otlpreceiver/internal/trace/otlp_test.go b/receiver/otlpreceiver/internal/trace/otlp_test.go index ded44b49548..5faeb14aba9 100644 --- a/receiver/otlpreceiver/internal/trace/otlp_test.go +++ b/receiver/otlpreceiver/internal/trace/otlp_test.go @@ -30,7 +30,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/otlpgrpc" + "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" ) func TestExport(t *testing.T) { @@ -48,7 +48,7 @@ func TestExport(t *testing.T) { // Keep trace data to compare the test result against it // Clone needed because OTLP proto XXX_ fields are altered in the GRPC downstream traceData := td.Clone() - req := otlpgrpc.NewTracesRequest() + req := ptraceotlp.NewRequest() req.SetTraces(td) resp, err := traceClient.Export(context.Background(), req) @@ -69,7 +69,7 @@ func TestExport_EmptyRequest(t *testing.T) { require.NoError(t, err, "Failed to create the TraceServiceClient: %v", err) defer traceClientDoneFn() - resp, err := traceClient.Export(context.Background(), otlpgrpc.NewTracesRequest()) + resp, err := traceClient.Export(context.Background(), ptraceotlp.NewRequest()) assert.NoError(t, err, "Failed to export trace: %v", err) assert.NotNil(t, resp, "The response is missing") } @@ -83,20 +83,20 @@ func TestExport_ErrorConsumer(t *testing.T) { defer traceClientDoneFn() td := testdata.GenerateTracesOneSpan() - req := otlpgrpc.NewTracesRequest() + req := ptraceotlp.NewRequest() req.SetTraces(td) resp, err := traceClient.Export(context.Background(), req) assert.EqualError(t, err, "rpc error: code = Unknown desc = my error") - assert.Equal(t, otlpgrpc.TracesResponse{}, resp) + assert.Equal(t, ptraceotlp.Response{}, resp) } -func makeTraceServiceClient(addr net.Addr) (otlpgrpc.TracesClient, func(), error) { +func makeTraceServiceClient(addr net.Addr) (ptraceotlp.Client, func(), error) { cc, err := grpc.Dial(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) if err != nil { return nil, nil, err } - metricsClient := otlpgrpc.NewTracesClient(cc) + metricsClient := ptraceotlp.NewClient(cc) doneFn := func() { _ = cc.Close() } return metricsClient, doneFn, nil @@ -118,7 +118,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, tc consumer.Traces) (net.Addr, func( // Now run it as a gRPC server srv := grpc.NewServer() - otlpgrpc.RegisterTracesServer(srv, r) + ptraceotlp.RegisterServer(srv, r) go func() { _ = srv.Serve(ln) }() diff --git a/receiver/otlpreceiver/otlp.go b/receiver/otlpreceiver/otlp.go index 94a64d8425b..cfe1e787dd7 100644 --- a/receiver/otlpreceiver/otlp.go +++ b/receiver/otlpreceiver/otlp.go @@ -29,7 +29,9 @@ import ( "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/otlpgrpc" + "go.opentelemetry.io/collector/pdata/plog/plogotlp" + "go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp" + "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" "go.opentelemetry.io/collector/receiver/otlpreceiver/internal/logs" "go.opentelemetry.io/collector/receiver/otlpreceiver/internal/metrics" "go.opentelemetry.io/collector/receiver/otlpreceiver/internal/trace" @@ -112,15 +114,15 @@ func (r *otlpReceiver) startProtocolServers(host component.Host) error { r.serverGRPC = grpc.NewServer(opts...) if r.traceReceiver != nil { - otlpgrpc.RegisterTracesServer(r.serverGRPC, r.traceReceiver) + ptraceotlp.RegisterServer(r.serverGRPC, r.traceReceiver) } if r.metricsReceiver != nil { - otlpgrpc.RegisterMetricsServer(r.serverGRPC, r.metricsReceiver) + pmetricotlp.RegisterServer(r.serverGRPC, r.metricsReceiver) } if r.logReceiver != nil { - otlpgrpc.RegisterLogsServer(r.serverGRPC, r.logReceiver) + plogotlp.RegisterServer(r.serverGRPC, r.logReceiver) } err = r.startGRPCServer(r.cfg.GRPC, host) diff --git a/receiver/otlpreceiver/otlp_test.go b/receiver/otlpreceiver/otlp_test.go index 9a45e47d9fc..b3bf05179b8 100644 --- a/receiver/otlpreceiver/otlp_test.go +++ b/receiver/otlpreceiver/otlp_test.go @@ -48,11 +48,11 @@ import ( "go.opentelemetry.io/collector/internal/internalconsumertest" "go.opentelemetry.io/collector/internal/testdata" "go.opentelemetry.io/collector/internal/testutil" - "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/otlpgrpc" - "go.opentelemetry.io/collector/model/pdata" semconv "go.opentelemetry.io/collector/model/semconv/v1.5.0" "go.opentelemetry.io/collector/obsreport/obsreporttest" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" ) const otlpReceiverName = "receiver_test" @@ -108,27 +108,27 @@ var traceJSON = []byte(` ] }`) -var traceOtlp = func() pdata.Traces { - td := pdata.NewTraces() +var traceOtlp = func() ptrace.Traces { + td := ptrace.NewTraces() rs := td.ResourceSpans().AppendEmpty() rs.Resource().Attributes().UpsertString(semconv.AttributeHostName, "testHost") spans := rs.ScopeSpans().AppendEmpty().Spans() span1 := spans.AppendEmpty() - span1.SetTraceID(pdata.NewTraceID([16]byte{0x5B, 0x8E, 0xFF, 0xF7, 0x98, 0x3, 0x81, 0x3, 0xD2, 0x69, 0xB6, 0x33, 0x81, 0x3F, 0xC6, 0xC})) - span1.SetSpanID(pdata.NewSpanID([8]byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x74})) - span1.SetParentSpanID(pdata.NewSpanID([8]byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x73})) + span1.SetTraceID(pcommon.NewTraceID([16]byte{0x5B, 0x8E, 0xFF, 0xF7, 0x98, 0x3, 0x81, 0x3, 0xD2, 0x69, 0xB6, 0x33, 0x81, 0x3F, 0xC6, 0xC})) + span1.SetSpanID(pcommon.NewSpanID([8]byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x74})) + span1.SetParentSpanID(pcommon.NewSpanID([8]byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x73})) span1.SetName("testSpan") span1.SetStartTimestamp(1544712660300000000) span1.SetEndTimestamp(1544712660600000000) - span1.SetKind(pdata.SpanKindServer) + span1.SetKind(ptrace.SpanKindServer) span1.Attributes().UpsertInt("attr1", 55) span2 := spans.AppendEmpty() - span2.SetTraceID(pdata.NewTraceID([16]byte{0x5B, 0x8E, 0xFF, 0xF7, 0x98, 0x3, 0x81, 0x3, 0xD2, 0x69, 0xB6, 0x33, 0x81, 0x3F, 0xC6, 0xC})) - span2.SetSpanID(pdata.NewSpanID([8]byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x73})) + span2.SetTraceID(pcommon.NewTraceID([16]byte{0x5B, 0x8E, 0xFF, 0xF7, 0x98, 0x3, 0x81, 0x3, 0xD2, 0x69, 0xB6, 0x33, 0x81, 0x3F, 0xC6, 0xC})) + span2.SetSpanID(pcommon.NewSpanID([8]byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x73})) span2.SetName("testSpan") span2.SetStartTimestamp(1544712660000000000) span2.SetEndTimestamp(1544712661000000000) - span2.SetKind(pdata.SpanKindClient) + span2.SetKind(ptrace.SpanKindClient) span2.Attributes().UpsertInt("attr1", 55) return td }() @@ -365,8 +365,8 @@ func testHTTPJSONRequest(t *testing.T, url string, sink *internalconsumertest.Er allTraces := sink.AllTraces() if expectedErr == nil { assert.Equal(t, 200, resp.StatusCode) - tr := otlpgrpc.NewTracesResponse() - assert.NoError(t, tr.UnmarshalJSON(respBytes), "Unable to unmarshal response to TracesResponse") + tr := ptraceotlp.NewResponse() + assert.NoError(t, tr.UnmarshalJSON(respBytes), "Unable to unmarshal response to Response") require.Len(t, allTraces, 1) assert.EqualValues(t, allTraces[0], traceOtlp) @@ -423,7 +423,7 @@ func TestProtoHttp(t *testing.T) { <-time.After(10 * time.Millisecond) td := testdata.GenerateTracesOneSpan() - traceBytes, err := otlp.NewProtobufTracesMarshaler().MarshalTraces(td) + traceBytes, err := ptrace.NewProtoMarshaler().MarshalTraces(td) if err != nil { t.Errorf("Error marshaling protobuf: %v", err) } @@ -466,7 +466,7 @@ func testHTTPProtobufRequest( encoding string, traceBytes []byte, expectedErr error, - wantData pdata.Traces, + wantData ptrace.Traces, ) { tSink.SetConsumeError(expectedErr) @@ -487,8 +487,8 @@ func testHTTPProtobufRequest( if expectedErr == nil { require.Equal(t, 200, resp.StatusCode, "Unexpected return status") - tr := otlpgrpc.NewTracesResponse() - assert.NoError(t, tr.UnmarshalProto(respBytes), "Unable to unmarshal response to TracesResponse") + tr := ptraceotlp.NewResponse() + assert.NoError(t, tr.UnmarshalProto(respBytes), "Unable to unmarshal response to Response") require.Len(t, allTraces, 1) assert.EqualValues(t, allTraces[0], wantData) @@ -651,7 +651,7 @@ func TestOTLPReceiverTrace_HandleNextConsumerResponse(t *testing.T) { receiverTag string exportFn func( cc *grpc.ClientConn, - td pdata.Traces) error + td ptrace.Traces) error }{ { receiverTag: "trace", @@ -885,7 +885,7 @@ func compressGzip(body []byte) (*bytes.Buffer, error) { return &buf, nil } -type senderFunc func(td pdata.Traces) +type senderFunc func(td ptrace.Traces) func TestShutdown(t *testing.T) { endpointGrpc := testutil.GetAvailableLocalAddress(t) @@ -915,13 +915,13 @@ func TestShutdown(t *testing.T) { doneSignalGrpc := make(chan bool) doneSignalHTTP := make(chan bool) - senderGrpc := func(td pdata.Traces) { + senderGrpc := func(td ptrace.Traces) { // Ignore error, may be executed after the receiver shutdown. _ = exportTraces(conn, td) } - senderHTTP := func(td pdata.Traces) { + senderHTTP := func(td ptrace.Traces) { // Send request via OTLP/HTTP. - traceBytes, err2 := otlp.NewProtobufTracesMarshaler().MarshalTraces(td) + traceBytes, err2 := ptrace.NewProtoMarshaler().MarshalTraces(td) if err2 != nil { t.Errorf("Error marshaling protobuf: %v", err2) } @@ -989,9 +989,9 @@ loop: close(doneSignal) } -func exportTraces(cc *grpc.ClientConn, td pdata.Traces) error { - acc := otlpgrpc.NewTracesClient(cc) - req := otlpgrpc.NewTracesRequest() +func exportTraces(cc *grpc.ClientConn, td ptrace.Traces) error { + acc := ptraceotlp.NewClient(cc) + req := ptraceotlp.NewRequest() req.SetTraces(td) _, err := acc.Export(context.Background(), req) diff --git a/receiver/scraperhelper/scraper.go b/receiver/scraperhelper/scraper.go index 2c6c75296c6..8b16e63514b 100644 --- a/receiver/scraperhelper/scraper.go +++ b/receiver/scraperhelper/scraper.go @@ -20,15 +20,15 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" ) var errNilFunc = errors.New("nil scrape func") // ScrapeFunc scrapes metrics. -type ScrapeFunc func(context.Context) (pdata.Metrics, error) +type ScrapeFunc func(context.Context) (pmetric.Metrics, error) -func (sf ScrapeFunc) Scrape(ctx context.Context) (pdata.Metrics, error) { +func (sf ScrapeFunc) Scrape(ctx context.Context) (pmetric.Metrics, error) { return sf(ctx) } @@ -38,7 +38,7 @@ type Scraper interface { // ID returns the scraper id. ID() config.ComponentID - Scrape(context.Context) (pdata.Metrics, error) + Scrape(context.Context) (pmetric.Metrics, error) } // ScraperOption apply changes to internal options. diff --git a/receiver/scraperhelper/scrapercontroller.go b/receiver/scraperhelper/scrapercontroller.go index 8b96c379d87..5a5596f4605 100644 --- a/receiver/scraperhelper/scrapercontroller.go +++ b/receiver/scraperhelper/scrapercontroller.go @@ -26,8 +26,8 @@ import ( "go.opentelemetry.io/collector/component/componenterror" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" "go.opentelemetry.io/collector/obsreport" + "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/receiver/scrapererror" ) @@ -183,7 +183,7 @@ func (sc *controller) startScraping() { // Scrapers, records observability information, and passes the scraped metrics // to the next component. func (sc *controller) scrapeMetricsAndReport(ctx context.Context) { - metrics := pdata.NewMetrics() + metrics := pmetric.NewMetrics() for _, scraper := range sc.scrapers { scrp := obsreport.NewScraper(obsreport.ScraperSettings{ diff --git a/receiver/scraperhelper/scrapercontroller_test.go b/receiver/scraperhelper/scrapercontroller_test.go index 0adff240e60..1c283952be4 100644 --- a/receiver/scraperhelper/scrapercontroller_test.go +++ b/receiver/scraperhelper/scrapercontroller_test.go @@ -31,8 +31,8 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" - "go.opentelemetry.io/collector/model/pdata" "go.opentelemetry.io/collector/obsreport/obsreporttest" + "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/receiver/scrapererror" ) @@ -62,17 +62,17 @@ type testScrapeMetrics struct { err error } -func (ts *testScrapeMetrics) scrape(_ context.Context) (pdata.Metrics, error) { +func (ts *testScrapeMetrics) scrape(_ context.Context) (pmetric.Metrics, error) { ts.timesScrapeCalled++ ts.ch <- ts.timesScrapeCalled if ts.err != nil { - return pdata.Metrics{}, ts.err + return pmetric.Metrics{}, ts.err } - md := pdata.NewMetrics() + md := pmetric.NewMetrics() metric := md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty() - metric.SetDataType(pdata.MetricDataTypeGauge) + metric.SetDataType(pmetric.MetricDataTypeGauge) metric.Gauge().DataPoints().AppendEmpty() return md, nil } diff --git a/service/internal/builder/pipelines_builder_test.go b/service/internal/builder/pipelines_builder_test.go index e67c1ce9487..e678cf782fe 100644 --- a/service/internal/builder/pipelines_builder_test.go +++ b/service/internal/builder/pipelines_builder_test.go @@ -27,7 +27,7 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/internal/testcomponents" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/service/servicetest" ) @@ -154,7 +154,7 @@ func TestBuildPipelines_BuildVarious(t *testing.T) { } // Send one custom data. - log := pdata.Logs{} + log := plog.Logs{} require.NoError(t, processor.firstLC.ConsumeLogs(context.Background(), log)) // Now verify received data. diff --git a/service/internal/builder/receivers_builder_test.go b/service/internal/builder/receivers_builder_test.go index 0aa6d43cd09..a14c9ccd763 100644 --- a/service/internal/builder/receivers_builder_test.go +++ b/service/internal/builder/receivers_builder_test.go @@ -28,7 +28,7 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/internal/testcomponents" "go.opentelemetry.io/collector/internal/testdata" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/service/servicetest" ) @@ -235,7 +235,7 @@ func TestBuildReceivers_BuildCustom(t *testing.T) { } // Send one data. - log := pdata.Logs{} + log := plog.Logs{} producer := receiver.receiver.(*testcomponents.ExampleReceiverProducer) require.NoError(t, producer.ConsumeLogs(context.Background(), log)) diff --git a/service/internal/fanoutconsumer/logs.go b/service/internal/fanoutconsumer/logs.go index 9dde97673a1..8673bacb2a9 100644 --- a/service/internal/fanoutconsumer/logs.go +++ b/service/internal/fanoutconsumer/logs.go @@ -22,7 +22,7 @@ import ( "go.uber.org/multierr" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) // NewLogs wraps multiple log consumers in a single one. @@ -64,8 +64,8 @@ func (lsc *logsConsumer) Capabilities() consumer.Capabilities { return consumer.Capabilities{MutatesData: false} } -// ConsumeLogs exports the pdata.Logs to all consumers wrapped by the current one. -func (lsc *logsConsumer) ConsumeLogs(ctx context.Context, ld pdata.Logs) error { +// ConsumeLogs exports the plog.Logs to all consumers wrapped by the current one. +func (lsc *logsConsumer) ConsumeLogs(ctx context.Context, ld plog.Logs) error { var errs error // Initially pass to clone exporter to avoid the case where the optimization of sending // the incoming data to a mutating consumer is used that may change the incoming data before diff --git a/service/internal/fanoutconsumer/metrics.go b/service/internal/fanoutconsumer/metrics.go index 371643252b5..a44c12979d1 100644 --- a/service/internal/fanoutconsumer/metrics.go +++ b/service/internal/fanoutconsumer/metrics.go @@ -20,7 +20,7 @@ import ( "go.uber.org/multierr" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" ) // NewMetrics wraps multiple metrics consumers in a single one. @@ -62,8 +62,8 @@ func (msc *metricsConsumer) Capabilities() consumer.Capabilities { return consumer.Capabilities{MutatesData: false} } -// ConsumeMetrics exports the pdata.Metrics to all consumers wrapped by the current one. -func (msc *metricsConsumer) ConsumeMetrics(ctx context.Context, md pdata.Metrics) error { +// ConsumeMetrics exports the pmetric.Metrics to all consumers wrapped by the current one. +func (msc *metricsConsumer) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error { var errs error // Initially pass to clone exporter to avoid the case where the optimization of sending // the incoming data to a mutating consumer is used that may change the incoming data before diff --git a/service/internal/fanoutconsumer/traces.go b/service/internal/fanoutconsumer/traces.go index 04dcd9fb5e8..e286c92e8b6 100644 --- a/service/internal/fanoutconsumer/traces.go +++ b/service/internal/fanoutconsumer/traces.go @@ -20,7 +20,7 @@ import ( "go.uber.org/multierr" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/ptrace" ) // NewTraces wraps multiple trace consumers in a single one. @@ -62,8 +62,8 @@ func (tsc *tracesConsumer) Capabilities() consumer.Capabilities { return consumer.Capabilities{MutatesData: false} } -// ConsumeTraces exports the pdata.Traces to all consumers wrapped by the current one. -func (tsc *tracesConsumer) ConsumeTraces(ctx context.Context, td pdata.Traces) error { +// ConsumeTraces exports the ptrace.Traces to all consumers wrapped by the current one. +func (tsc *tracesConsumer) ConsumeTraces(ctx context.Context, td ptrace.Traces) error { var errs error // Initially pass to clone exporter to avoid the case where the optimization of sending // the incoming data to a mutating consumer is used that may change the incoming data before diff --git a/versions.yaml b/versions.yaml index 93558919938..c2e1e1d1d2f 100644 --- a/versions.yaml +++ b/versions.yaml @@ -19,6 +19,7 @@ module-sets: - go.opentelemetry.io/collector - go.opentelemetry.io/collector/cmd/builder - go.opentelemetry.io/collector/model + - go.opentelemetry.io/collector/pdata excluded-modules: - go.opentelemetry.io/collector/cmd/otelcorecol - go.opentelemetry.io/collector/internal/tools