Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update opentelemetry-mapping-go to v0.9.0 #21524

Merged
merged 8 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ core,github.com/masahiro331/go-xfs-filesystem/xfs/utils,Apache-2.0,Copyright (c)
core,github.com/mattn/go-colorable,MIT,Copyright (c) 2016 Yasuhiro Matsumoto
core,github.com/mattn/go-isatty,MIT,Copyright (c) Yasuhiro MATSUMOTO <[email protected]>
core,github.com/mattn/go-runewidth,MIT,Copyright (c) 2016 Yasuhiro Matsumoto
core,github.com/matttproud/golang_protobuf_extensions/pbutil,Apache-2.0,Copyright 2012 Matt T. Proud ([email protected])
core,github.com/matttproud/golang_protobuf_extensions/v2/pbutil,Apache-2.0,Copyright 2012 Matt T. Proud ([email protected])
core,github.com/mdlayher/netlink,MIT,Copyright (C) 2016-2022 Matt Layher
core,github.com/mdlayher/netlink/nlenc,MIT,Copyright (C) 2016-2022 Matt Layher
core,github.com/mdlayher/socket,MIT,Copyright (C) 2021 Matt Layher
Expand Down Expand Up @@ -1671,6 +1671,7 @@ core,go.opentelemetry.io/collector/receiver/otlpreceiver/internal/logs,Apache-2.
core,go.opentelemetry.io/collector/receiver/otlpreceiver/internal/metrics,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/receiver/otlpreceiver/internal/trace,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/receiver/receiverhelper,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/receiver/receivertest,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/semconv/v1.17.0,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/semconv/v1.18.0,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/semconv/v1.6.1,Apache-2.0,Copyright The OpenTelemetry Authors
Expand All @@ -1685,6 +1686,7 @@ core,go.opentelemetry.io/collector/service/internal/status,Apache-2.0,Copyright
core,go.opentelemetry.io/collector/service/internal/zpages,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/service/pipelines,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/collector/service/telemetry,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/contrib/config,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/internal,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp,Apache-2.0,Copyright The OpenTelemetry Authors
Expand All @@ -1699,7 +1701,6 @@ core,go.opentelemetry.io/otel/bridge/opencensus/internal/oc2otel,Apache-2.0,Copy
core,go.opentelemetry.io/otel/bridge/opencensus/internal/ocmetric,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/otel/bridge/opencensus/internal/otel2oc,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/otel/codes,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/otel/exporters/otlp/otlpmetric,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc/internal,Apache-2.0,Copyright The OpenTelemetry Authors
core,go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/envconfig,Apache-2.0,Copyright The OpenTelemetry Authors
Expand Down Expand Up @@ -1859,6 +1860,8 @@ core,golang.org/x/oauth2/authhandler,BSD-3-Clause,Copyright (c) 2009 The Go Auth
core,golang.org/x/oauth2/clientcredentials,BSD-3-Clause,Copyright (c) 2009 The Go Authors. All rights reserved
core,golang.org/x/oauth2/google,BSD-3-Clause,Copyright (c) 2009 The Go Authors. All rights reserved
core,golang.org/x/oauth2/google/internal/externalaccount,BSD-3-Clause,Copyright (c) 2009 The Go Authors. All rights reserved
core,golang.org/x/oauth2/google/internal/externalaccountauthorizeduser,BSD-3-Clause,Copyright (c) 2009 The Go Authors. All rights reserved
core,golang.org/x/oauth2/google/internal/stsexchange,BSD-3-Clause,Copyright (c) 2009 The Go Authors. All rights reserved
core,golang.org/x/oauth2/internal,BSD-3-Clause,Copyright (c) 2009 The Go Authors. All rights reserved
core,golang.org/x/oauth2/jws,BSD-3-Clause,Copyright (c) 2009 The Go Authors. All rights reserved
core,golang.org/x/oauth2/jwt,BSD-3-Clause,Copyright (c) 2009 The Go Authors. All rights reserved
Expand Down Expand Up @@ -1952,9 +1955,7 @@ core,google.golang.org/appengine/internal/datastore,Apache-2.0,Copyright 2011 Go
core,google.golang.org/appengine/internal/log,Apache-2.0,Copyright 2011 Google Inc. All rights reserved.
core,google.golang.org/appengine/internal/modules,Apache-2.0,Copyright 2011 Google Inc. All rights reserved.
core,google.golang.org/appengine/internal/remote_api,Apache-2.0,Copyright 2011 Google Inc. All rights reserved.
core,google.golang.org/appengine/internal/socket,Apache-2.0,Copyright 2011 Google Inc. All rights reserved.
core,google.golang.org/appengine/internal/urlfetch,Apache-2.0,Copyright 2011 Google Inc. All rights reserved.
core,google.golang.org/appengine/socket,Apache-2.0,Copyright 2011 Google Inc. All rights reserved.
core,google.golang.org/appengine/urlfetch,Apache-2.0,Copyright 2011 Google Inc. All rights reserved.
core,google.golang.org/genproto/googleapis/api,Apache-2.0,Copyright 2015 Google LLC
core,google.golang.org/genproto/googleapis/api/annotations,Apache-2.0,Copyright 2015 Google LLC
Expand Down
9 changes: 3 additions & 6 deletions comp/otelcol/otlp/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ func NewPipeline(cfg PipelineConfig, s serializer.MetricSerializer, logsAgentCha
return nil, fmt.Errorf("failed to get build info: %w", err)
}

factories, err := getComponents(s, logsAgentChannel)
if err != nil {
return nil, fmt.Errorf("failed to get components: %w", err)
}

// Replace default core to use Agent logger
options := []zap.Option{zap.WrapCore(func(zapcore.Core) zapcore.Core {
return zapAgent.NewZapCore()
Expand All @@ -178,7 +173,9 @@ func NewPipeline(cfg PipelineConfig, s serializer.MetricSerializer, logsAgentCha
}

col, err := otelcol.NewCollector(otelcol.CollectorSettings{
Factories: factories,
Factories: func() (otelcol.Factories, error) {
return getComponents(s, logsAgentChannel)
},
BuildInfo: buildInfo,
DisableGracefulShutdown: true,
ConfigProvider: configProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"encoding/json"
"fmt"
"testing"
"time"

"github.com/DataDog/datadog-agent/comp/otelcol/otlp/internal/testutil"
"github.com/DataDog/datadog-agent/pkg/logs/message"
Expand Down Expand Up @@ -48,7 +47,7 @@ func TestLogsExporter(t *testing.T) {
"message": ld.Body().AsString(),
"app": "server",
"instance_num": "1",
"@timestamp": testutil.TestLogTime.Format(time.RFC3339),
"@timestamp": testutil.TestLogTime.Format("2006-01-02T15:04:05.000Z07:00"),
"status": "Info",
"dd.span_id": fmt.Sprintf("%d", spanIDToUint64(ld.SpanID())),
"dd.trace_id": fmt.Sprintf("%d", traceIDToUint64(ld.TraceID())),
Expand Down Expand Up @@ -78,7 +77,7 @@ func TestLogsExporter(t *testing.T) {
"message": "hello",
"app": "server",
"instance_num": "1",
"@timestamp": testutil.TestLogTime.Format(time.RFC3339),
"@timestamp": testutil.TestLogTime.Format("2006-01-02T15:04:05.000Z07:00"),
"status": "Info",
"dd.span_id": fmt.Sprintf("%d", spanIDToUint64(ld.SpanID())),
"dd.trace_id": fmt.Sprintf("%d", traceIDToUint64(ld.TraceID())),
Expand Down Expand Up @@ -108,7 +107,7 @@ func TestLogsExporter(t *testing.T) {
"message": ld.Body().AsString(),
"app": "server",
"instance_num": "1",
"@timestamp": testutil.TestLogTime.Format(time.RFC3339),
"@timestamp": testutil.TestLogTime.Format("2006-01-02T15:04:05.000Z07:00"),
"status": "Info",
"dd.span_id": fmt.Sprintf("%d", spanIDToUint64(ld.SpanID())),
"dd.trace_id": fmt.Sprintf("%d", traceIDToUint64(ld.TraceID())),
Expand Down Expand Up @@ -140,7 +139,7 @@ func TestLogsExporter(t *testing.T) {
"message": ld.Body().AsString(),
"app": "server",
"instance_num": "1",
"@timestamp": testutil.TestLogTime.Format(time.RFC3339),
"@timestamp": testutil.TestLogTime.Format("2006-01-02T15:04:05.000Z07:00"),
"status": "Info",
"dd.span_id": fmt.Sprintf("%d", spanIDToUint64(ld.SpanID())),
"dd.trace_id": fmt.Sprintf("%d", traceIDToUint64(ld.TraceID())),
Expand All @@ -155,7 +154,7 @@ func TestLogsExporter(t *testing.T) {
"message": "something happened",
"env": "dev",
"customer": "acme",
"@timestamp": testutil.TestLogTime.Format(time.RFC3339),
"@timestamp": testutil.TestLogTime.Format("2006-01-02T15:04:05.000Z07:00"),
"status": "Info",
"otel.severity_text": "Info",
"otel.severity_number": "9",
Expand Down Expand Up @@ -183,7 +182,7 @@ func TestLogsExporter(t *testing.T) {
"message": ld.Body().AsString(),
"app": "server",
"instance_num": "1",
"@timestamp": testutil.TestLogTime.Format(time.RFC3339),
"@timestamp": testutil.TestLogTime.Format("2006-01-02T15:04:05.000Z07:00"),
"status": "Info",
"dd.span_id": fmt.Sprintf("%d", spanIDToUint64(ld.SpanID())),
"dd.trace_id": fmt.Sprintf("%d", traceIDToUint64(ld.TraceID())),
Expand All @@ -198,7 +197,7 @@ func TestLogsExporter(t *testing.T) {
"message": "something happened",
"env": "dev",
"customer": "acme",
"@timestamp": testutil.TestLogTime.Format(time.RFC3339),
"@timestamp": testutil.TestLogTime.Format("2006-01-02T15:04:05.000Z07:00"),
"status": "Info",
"otel.severity_text": "Info",
"otel.severity_number": "9",
Expand Down
11 changes: 5 additions & 6 deletions comp/otelcol/otlp/internal/serializerexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.uber.org/zap"

"github.com/DataDog/datadog-agent/pkg/serializer"
"github.com/DataDog/datadog-agent/pkg/tagger/collectors"
Expand Down Expand Up @@ -81,7 +80,7 @@ type exporter struct {
cardinality collectors.TagCardinality
}

func translatorFromConfig(logger *zap.Logger, cfg *exporterConfig) (*metrics.Translator, error) {
func translatorFromConfig(set component.TelemetrySettings, cfg *exporterConfig) (*metrics.Translator, error) {
histogramMode := metrics.HistogramMode(cfg.Metrics.HistConfig.Mode)
switch histogramMode {
case metrics.HistogramModeCounters, metrics.HistogramModeNoBuckets, metrics.HistogramModeDistributions:
Expand Down Expand Up @@ -128,16 +127,16 @@ func translatorFromConfig(logger *zap.Logger, cfg *exporterConfig) (*metrics.Tra
options = append(options, metrics.WithInitialCumulMonoValueMode(
metrics.InitialCumulMonoValueMode(cfg.Metrics.SumConfig.InitialCumulativeMonotonicMode)))

return metrics.NewTranslator(logger, options...)
return metrics.NewTranslator(set, options...)
}

func newExporter(logger *zap.Logger, s serializer.MetricSerializer, cfg *exporterConfig) (*exporter, error) {
func newExporter(set component.TelemetrySettings, s serializer.MetricSerializer, cfg *exporterConfig) (*exporter, error) {
// Log any warnings from unmarshaling.
for _, warning := range cfg.warnings {
logger.Warn(warning)
set.Logger.Warn(warning)
}

tr, err := translatorFromConfig(logger, cfg)
tr, err := translatorFromConfig(set, cfg)
if err != nil {
return nil, fmt.Errorf("incorrect OTLP metrics configuration: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.uber.org/zap"

"github.com/DataDog/datadog-agent/pkg/config"
"github.com/DataDog/datadog-agent/pkg/metrics"
Expand Down Expand Up @@ -191,7 +191,7 @@ func Test_ConsumeMetrics_Tags(t *testing.T) {
}
rec := &metricRecorder{}
exp, err := newExporter(
zap.NewNop(),
componenttest.NewNopTelemetrySettings(),
rec,
NewFactory(rec).CreateDefaultConfig().(*exporterConfig),
)
Expand Down
2 changes: 1 addition & 1 deletion comp/otelcol/otlp/internal/serializerexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewFactory(s serializer.MetricSerializer) exp.Factory {
func (f *factory) createMetricExporter(ctx context.Context, params exp.CreateSettings, c component.Config) (exp.Metrics, error) {
cfg := c.(*exporterConfig)

newExp, err := newExporter(params.Logger, f.s, cfg)
newExp, err := newExporter(params.TelemetrySettings, f.s, cfg)
if err != nil {
return nil, err
}
Expand Down
Loading
Loading