From 9a34aea049669c76d716885d347c96c5f6e3e3dc Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 21 Dec 2023 19:11:39 +0100 Subject: [PATCH] [*/datadog] Update to opentelemetry-mapping-go v0.11.0 (#30158) **Description:** - [*/datadog] Bump to opentelemetry-mapping-go v0.11.0. This includes: - Refactor related to upcoming metric: - DataDog/opentelemetry-mapping-go/pull/230 - DataDog/opentelemetry-mapping-go/pull/231 - DataDog/opentelemetry-mapping-go/pull/229 - Host metadata updates: - DataDog/opentelemetry-mapping-go/pull/184 - DataDog/opentelemetry-mapping-go/pull/225 - Use `logs.Translator` for logs implementation - Set `MeterProvider` to noop to prevent sending metrics for now until we agree on the design. Note that I reverted one of the changelog items added in #29785, since it's no longer true that we add this metric. --- ...tric.yaml => mx-psi_update-tov0.11.0.yaml} | 13 ++++-- cmd/configschema/go.mod | 10 ++--- cmd/configschema/go.sum | 22 +++++----- cmd/otelcontribcol/go.mod | 10 ++--- cmd/otelcontribcol/go.sum | 22 +++++----- connector/datadogconnector/connector.go | 16 +++++-- connector/datadogconnector/go.mod | 6 +-- connector/datadogconnector/go.sum | 14 +++---- exporter/datadogexporter/factory.go | 32 +++++++++++++- exporter/datadogexporter/go.mod | 10 ++--- exporter/datadogexporter/go.sum | 22 +++++----- .../datadogexporter/integrationtest/go.mod | 10 ++--- .../datadogexporter/integrationtest/go.sum | 22 +++++----- .../internal/metrics/consumer_test.go | 3 ++ exporter/datadogexporter/logs_exporter.go | 42 +++++++------------ exporter/datadogexporter/metrics_exporter.go | 8 ++-- .../datadogexporter/metrics_exporter_test.go | 24 +++++++---- go.mod | 10 ++--- go.sum | 22 +++++----- internal/datadog/go.mod | 6 +-- internal/datadog/go.sum | 14 +++---- processor/datadogprocessor/go.mod | 6 +-- processor/datadogprocessor/go.sum | 14 +++---- processor/datadogprocessor/processor.go | 9 +++- 24 files changed, 208 insertions(+), 159 deletions(-) rename .chloggen/{dd-exporter-metric.yaml => mx-psi_update-tov0.11.0.yaml} (78%) mode change 100644 => 100755 diff --git a/.chloggen/dd-exporter-metric.yaml b/.chloggen/mx-psi_update-tov0.11.0.yaml old mode 100644 new mode 100755 similarity index 78% rename from .chloggen/dd-exporter-metric.yaml rename to .chloggen/mx-psi_update-tov0.11.0.yaml index d0c4066429e5..4cbd58bd736c --- a/.chloggen/dd-exporter-metric.yaml +++ b/.chloggen/mx-psi_update-tov0.11.0.yaml @@ -7,15 +7,22 @@ change_type: enhancement component: datadogexporter # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Add `datadog.otlp_translator.metrics.missing_source` counter, which counts the number of metrics that are missing a source (e.g. hostname). +note: Add support for more semantic conventions related to host metadata # Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. -issues: [29785] +issues: [30158] # (Optional) One or more lines of additional information to render under the primary note. # These lines will be padded with 2 spaces and then inserted directly into the document. # Use pipe (|) for multiline entries. -subtext: +subtext: | + The following semantic conventions are now detected for host metadata: + - `host.ip` + - `host.mac` + - `system.cpu.physical.count` + - `system.cpu.logical.count` + - `system.cpu.frequency` + - `system.memory.limit` # If your change doesn't affect end users or the exported elements of any package, # you should instead start your pull request title with [chore] or use the "Skip Changelog" label. diff --git a/cmd/configschema/go.mod b/cmd/configschema/go.mod index ce957f8c076e..4dfa737a6ad1 100644 --- a/cmd/configschema/go.mod +++ b/cmd/configschema/go.mod @@ -22,8 +22,8 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor v0.11.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 // indirect github.com/gocql/gocql v1.6.0 // indirect github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.91.0 // indirect @@ -229,9 +229,9 @@ require ( github.com/DataDog/go-sqllexer v0.0.8 // indirect github.com/DataDog/go-tuf v1.0.2-0.5.2 // indirect github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 // indirect github.com/DataDog/sketches-go v1.4.3 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect diff --git a/cmd/configschema/go.sum b/cmd/configschema/go.sum index 758f2b3dfc14..12ee102583f4 100644 --- a/cmd/configschema/go.sum +++ b/cmd/configschema/go.sum @@ -184,17 +184,17 @@ github.com/DataDog/go-tuf v1.0.2-0.5.2 h1:EeZr937eKAWPxJ26IykAdWA4A0jQXJgkhUjqEI github.com/DataDog/go-tuf v1.0.2-0.5.2/go.mod h1:zBcq6f654iVqmkk8n2Cx81E1JnNTMOAx1UEO/wZR+P0= github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee h1:tXibLZk3G6HncIFJKaNItsdzcrk4YqILNDZlXPTNt4k= github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee/go.mod h1:nTot/Iy0kW16bXgXr6blEc8gFeAS7vTqYlhAxh+dbc0= -github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0 h1:kiPtYAgzvlOc6HV0qwS8xNeA39cYyAJs6q9dIRDpCFk= -github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0/go.mod h1:MV/L0ESKjLGGE4JPDIDtz6H5u+9w0UKp1Wsw2lLREII= -github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.10.0 h1:O2PYvgTQA+31NuepzQqLexEpUX8FWsdNgq+0241OtH0= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 h1:56vp8vflG6lmhTO+YldUBTe0cIjStOC1neW1dIHYm5s= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0/go.mod h1:naFq9h+fQpgI7AKJ+YkWlAAYDU8/FB8LyfA39bmRNHs= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0 h1:+LxQNTpRM57lfcbGV7s+PVQ2B2Pegabfpf3yGJUXcgM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0/go.mod h1:WYm0DRBxBrKrmZrwoAJhcyJ7bGAFZbVQFcrrwwaGozU= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 h1:XwGT7/2NnO1RGxS5WD4BTsLWqO+z8234XBccUGhP8tM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0/go.mod h1:1fYkFs2pUyqBUUVDsjn1cKVEI79R+NluYhqX+pDTkSY= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 h1:mEao3xEP7iCfCd+teps0oM8U+ZRPVz02W6aE5cfi2Sc= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0/go.mod h1:vPjlCjTrBzzZpVJbbVpox8x9nRYx5giCl/9Zy8oWFw0= +github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0 h1:7Y53V1RUKMI5M8lyte5QziGxUEaGcWO4Raq89cL5oZo= +github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0/go.mod h1:HZEgHdrdgnyYCT1veZEn8TonMMo+oBHuq2IZ/PlTbyE= +github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.11.0 h1:4ifgkQU0qHxrCE5axRmI4AaJYZLj95VEVxIbXlIPLUg= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 h1:qaqPqVPoiW8p9/RYaF5m7qt47+jSv6bXXeP9XM7UbfA= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0/go.mod h1:YV4ZdhvqDCGIA17CFm2QZWe1AHL+YY5UEpnTWYXLIm8= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0 h1:hI0ADWaPLkG7TDZSx/RX+hxTwBeI0BKF0Wmx2genfMw= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0/go.mod h1:Xl5jjxQujCHLCB5gMwHB2jkVsE/TX+YUAkHBc6pFLu0= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 h1:JAFzV1P69kSvlmd8D+i9V6kpxOuy8WVbGUBGxufLjtI= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0/go.mod h1:cP0qZvP+u4jzz2z28KzxFYww4xX2sYv+yPQAMSLoSMU= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 h1:G5fefqlKYsJX0iqkp5Smdica6J3Ty7Gay8NINjwpdpY= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0/go.mod h1:4ed2dYa6xQKKfVhJoLpNf89N0pKA8H2R0SyiCcL6PoI= github.com/DataDog/sketches-go v1.4.3 h1:ZB9nijteJRFUQixkQfatCqASartGNfiolIlMiEv3u/w= github.com/DataDog/sketches-go v1.4.3/go.mod h1:XR0ns2RtEEF09mDKXiKZiQg+nfZStrq1ZuL1eezeZe0= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index 97f2ec722e39..5b827d02377a 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -274,11 +274,11 @@ require ( github.com/DataDog/go-sqllexer v0.0.8 // indirect github.com/DataDog/go-tuf v1.0.2-0.5.2 // indirect github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 // indirect github.com/DataDog/sketches-go v1.4.3 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect diff --git a/cmd/otelcontribcol/go.sum b/cmd/otelcontribcol/go.sum index b4d6632603c9..0a3956c7e69d 100644 --- a/cmd/otelcontribcol/go.sum +++ b/cmd/otelcontribcol/go.sum @@ -183,17 +183,17 @@ github.com/DataDog/go-tuf v1.0.2-0.5.2 h1:EeZr937eKAWPxJ26IykAdWA4A0jQXJgkhUjqEI github.com/DataDog/go-tuf v1.0.2-0.5.2/go.mod h1:zBcq6f654iVqmkk8n2Cx81E1JnNTMOAx1UEO/wZR+P0= github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee h1:tXibLZk3G6HncIFJKaNItsdzcrk4YqILNDZlXPTNt4k= github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee/go.mod h1:nTot/Iy0kW16bXgXr6blEc8gFeAS7vTqYlhAxh+dbc0= -github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0 h1:kiPtYAgzvlOc6HV0qwS8xNeA39cYyAJs6q9dIRDpCFk= -github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0/go.mod h1:MV/L0ESKjLGGE4JPDIDtz6H5u+9w0UKp1Wsw2lLREII= -github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.10.0 h1:O2PYvgTQA+31NuepzQqLexEpUX8FWsdNgq+0241OtH0= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 h1:56vp8vflG6lmhTO+YldUBTe0cIjStOC1neW1dIHYm5s= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0/go.mod h1:naFq9h+fQpgI7AKJ+YkWlAAYDU8/FB8LyfA39bmRNHs= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0 h1:+LxQNTpRM57lfcbGV7s+PVQ2B2Pegabfpf3yGJUXcgM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0/go.mod h1:WYm0DRBxBrKrmZrwoAJhcyJ7bGAFZbVQFcrrwwaGozU= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 h1:XwGT7/2NnO1RGxS5WD4BTsLWqO+z8234XBccUGhP8tM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0/go.mod h1:1fYkFs2pUyqBUUVDsjn1cKVEI79R+NluYhqX+pDTkSY= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 h1:mEao3xEP7iCfCd+teps0oM8U+ZRPVz02W6aE5cfi2Sc= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0/go.mod h1:vPjlCjTrBzzZpVJbbVpox8x9nRYx5giCl/9Zy8oWFw0= +github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0 h1:7Y53V1RUKMI5M8lyte5QziGxUEaGcWO4Raq89cL5oZo= +github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0/go.mod h1:HZEgHdrdgnyYCT1veZEn8TonMMo+oBHuq2IZ/PlTbyE= +github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.11.0 h1:4ifgkQU0qHxrCE5axRmI4AaJYZLj95VEVxIbXlIPLUg= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 h1:qaqPqVPoiW8p9/RYaF5m7qt47+jSv6bXXeP9XM7UbfA= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0/go.mod h1:YV4ZdhvqDCGIA17CFm2QZWe1AHL+YY5UEpnTWYXLIm8= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0 h1:hI0ADWaPLkG7TDZSx/RX+hxTwBeI0BKF0Wmx2genfMw= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0/go.mod h1:Xl5jjxQujCHLCB5gMwHB2jkVsE/TX+YUAkHBc6pFLu0= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 h1:JAFzV1P69kSvlmd8D+i9V6kpxOuy8WVbGUBGxufLjtI= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0/go.mod h1:cP0qZvP+u4jzz2z28KzxFYww4xX2sYv+yPQAMSLoSMU= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 h1:G5fefqlKYsJX0iqkp5Smdica6J3Ty7Gay8NINjwpdpY= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0/go.mod h1:4ed2dYa6xQKKfVhJoLpNf89N0pKA8H2R0SyiCcL6PoI= github.com/DataDog/sketches-go v1.4.3 h1:ZB9nijteJRFUQixkQfatCqASartGNfiolIlMiEv3u/w= github.com/DataDog/sketches-go v1.4.3/go.mod h1:XR0ns2RtEEF09mDKXiKZiQg+nfZStrq1ZuL1eezeZe0= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= diff --git a/connector/datadogconnector/connector.go b/connector/datadogconnector/connector.go index 69c7a0f1f99e..a5bb5026a078 100644 --- a/connector/datadogconnector/connector.go +++ b/connector/datadogconnector/connector.go @@ -5,12 +5,15 @@ package datadogconnector // import "github.com/open-telemetry/opentelemetry-coll import ( "context" + "fmt" pb "github.com/DataDog/datadog-agent/pkg/proto/pbgo/trace" + "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/otel/metric/noop" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/datadog" @@ -45,12 +48,17 @@ func newConnector(set component.TelemetrySettings, _ component.Config, metricsCo set.Logger.Info("Building datadog connector") in := make(chan *pb.StatsPayload, 100) - trans, err := metrics.NewTranslator(set) - - ctx := context.Background() + set.MeterProvider = noop.NewMeterProvider() // disable metrics for the connector + attributesTranslator, err := attributes.NewTranslator(set) + if err != nil { + return nil, fmt.Errorf("failed to create attributes translator: %w", err) + } + trans, err := metrics.NewTranslator(set, attributesTranslator) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to create metrics translator: %w", err) } + + ctx := context.Background() return &connectorImp{ logger: set.Logger, agent: datadog.NewAgent(ctx, in), diff --git a/connector/datadogconnector/go.mod b/connector/datadogconnector/go.mod index 5f93f75981d9..5c40abb38e87 100644 --- a/connector/datadogconnector/go.mod +++ b/connector/datadogconnector/go.mod @@ -4,7 +4,8 @@ go 1.20 require ( github.com/DataDog/datadog-agent/pkg/proto v0.50.0 - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/datadog v0.91.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.91.0 @@ -27,8 +28,7 @@ require ( github.com/DataDog/datadog-go/v5 v5.1.1 // indirect github.com/DataDog/go-sqllexer v0.0.8 // indirect github.com/DataDog/go-tuf v1.0.2-0.5.2 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 // indirect github.com/DataDog/sketches-go v1.4.3 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect diff --git a/connector/datadogconnector/go.sum b/connector/datadogconnector/go.sum index 691d369204b3..62de96a5052e 100644 --- a/connector/datadogconnector/go.sum +++ b/connector/datadogconnector/go.sum @@ -20,13 +20,13 @@ github.com/DataDog/go-sqllexer v0.0.8 h1:vfC8R9PhmJfeOKcFYAX9UOd890A3wu3KrjU9Kr7 github.com/DataDog/go-sqllexer v0.0.8/go.mod h1:nB4Ea2YNsqMwtbWMc4Fm/oP98IIrSPapqwOwPioMspY= github.com/DataDog/go-tuf v1.0.2-0.5.2 h1:EeZr937eKAWPxJ26IykAdWA4A0jQXJgkhUjqEI/w7+I= github.com/DataDog/go-tuf v1.0.2-0.5.2/go.mod h1:zBcq6f654iVqmkk8n2Cx81E1JnNTMOAx1UEO/wZR+P0= -github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.10.0 h1:O2PYvgTQA+31NuepzQqLexEpUX8FWsdNgq+0241OtH0= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 h1:56vp8vflG6lmhTO+YldUBTe0cIjStOC1neW1dIHYm5s= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0/go.mod h1:naFq9h+fQpgI7AKJ+YkWlAAYDU8/FB8LyfA39bmRNHs= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 h1:XwGT7/2NnO1RGxS5WD4BTsLWqO+z8234XBccUGhP8tM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0/go.mod h1:1fYkFs2pUyqBUUVDsjn1cKVEI79R+NluYhqX+pDTkSY= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 h1:mEao3xEP7iCfCd+teps0oM8U+ZRPVz02W6aE5cfi2Sc= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0/go.mod h1:vPjlCjTrBzzZpVJbbVpox8x9nRYx5giCl/9Zy8oWFw0= +github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.11.0 h1:4ifgkQU0qHxrCE5axRmI4AaJYZLj95VEVxIbXlIPLUg= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 h1:qaqPqVPoiW8p9/RYaF5m7qt47+jSv6bXXeP9XM7UbfA= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0/go.mod h1:YV4ZdhvqDCGIA17CFm2QZWe1AHL+YY5UEpnTWYXLIm8= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 h1:JAFzV1P69kSvlmd8D+i9V6kpxOuy8WVbGUBGxufLjtI= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0/go.mod h1:cP0qZvP+u4jzz2z28KzxFYww4xX2sYv+yPQAMSLoSMU= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 h1:G5fefqlKYsJX0iqkp5Smdica6J3Ty7Gay8NINjwpdpY= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0/go.mod h1:4ed2dYa6xQKKfVhJoLpNf89N0pKA8H2R0SyiCcL6PoI= github.com/DataDog/sketches-go v1.4.3 h1:ZB9nijteJRFUQixkQfatCqASartGNfiolIlMiEv3u/w= github.com/DataDog/sketches-go v1.4.3/go.mod h1:XR0ns2RtEEF09mDKXiKZiQg+nfZStrq1ZuL1eezeZe0= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= diff --git a/exporter/datadogexporter/factory.go b/exporter/datadogexporter/factory.go index 017e9fd0512a..6b5f94f8964f 100644 --- a/exporter/datadogexporter/factory.go +++ b/exporter/datadogexporter/factory.go @@ -11,6 +11,7 @@ import ( "github.com/DataDog/datadog-agent/pkg/trace/agent" "github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata" + "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes/source" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/confignet" @@ -22,6 +23,7 @@ import ( "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/otel/metric/noop" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter/internal/hostmetadata" @@ -77,6 +79,10 @@ type factory struct { reporter *inframetadata.Reporter reporterErr error + onceAttributesTranslator sync.Once + attributesTranslator *attributes.Translator + attributesErr error + wg sync.WaitGroup // waits for agent to exit registry *featuregate.Registry @@ -89,6 +95,16 @@ func (f *factory) SourceProvider(set component.TelemetrySettings, configHostname return f.sourceProvider, f.providerErr } +func (f *factory) AttributesTranslator(set component.TelemetrySettings) (*attributes.Translator, error) { + f.onceAttributesTranslator.Do(func() { + // disable metrics for the translator + // Metrics are disabled until we figure out the details on how do we want to report the metric. + set.MeterProvider = noop.NewMeterProvider() + f.attributesTranslator, f.attributesErr = attributes.NewTranslator(set) + }) + return f.attributesTranslator, f.attributesErr +} + // Reporter builds and returns an *inframetadata.Reporter. func (f *factory) Reporter(params exporter.CreateSettings, pcfg hostmetadata.PusherConfig) (*inframetadata.Reporter, error) { f.onceReporter.Do(func() { @@ -245,6 +261,12 @@ func (f *factory) createMetricsExporter( return nil, fmt.Errorf("failed to build host metadata reporter: %w", err) } + attrsTranslator, err := f.AttributesTranslator(set.TelemetrySettings) + if err != nil { + cancel() + return nil, fmt.Errorf("failed to build attributes translator: %w", err) + } + if cfg.OnlyMetadata { pushMetricsFn = func(_ context.Context, md pmetric.Metrics) error { // only sending metadata use only metrics @@ -264,7 +286,7 @@ func (f *factory) createMetricsExporter( return nil } } else { - exp, metricsErr := newMetricsExporter(ctx, set, cfg, &f.onceMetadata, hostProvider, traceagent, metadataReporter) + exp, metricsErr := newMetricsExporter(ctx, set, cfg, &f.onceMetadata, attrsTranslator, hostProvider, traceagent, metadataReporter) if metricsErr != nil { cancel() // first cancel context f.wg.Wait() // then wait for shutdown @@ -404,6 +426,12 @@ func (f *factory) createLogsExporter( return nil, fmt.Errorf("failed to build host metadata reporter: %w", err) } + attributesTranslator, err := f.AttributesTranslator(set.TelemetrySettings) + if err != nil { + cancel() + return nil, fmt.Errorf("failed to build attributes translator: %w", err) + } + if cfg.OnlyMetadata { // only host metadata needs to be sent, once. pusher = func(_ context.Context, td plog.Logs) error { @@ -418,7 +446,7 @@ func (f *factory) createLogsExporter( return nil } } else { - exp, err := newLogsExporter(ctx, set, cfg, &f.onceMetadata, hostProvider, metadataReporter) + exp, err := newLogsExporter(ctx, set, cfg, &f.onceMetadata, attributesTranslator, hostProvider, metadataReporter) if err != nil { cancel() f.wg.Wait() // then wait for shutdown diff --git a/exporter/datadogexporter/go.mod b/exporter/datadogexporter/go.mod index d0269317c9e4..c8064b86dc0e 100644 --- a/exporter/datadogexporter/go.mod +++ b/exporter/datadogexporter/go.mod @@ -8,11 +8,11 @@ require ( github.com/DataDog/datadog-agent/pkg/trace v0.50.0 github.com/DataDog/datadog-api-client-go/v2 v2.20.0 github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee - github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0 - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0 - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 - github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 + github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0 + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0 + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 + github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 github.com/DataDog/sketches-go v1.4.3 github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 github.com/aws/aws-sdk-go v1.49.6 diff --git a/exporter/datadogexporter/go.sum b/exporter/datadogexporter/go.sum index 6039c802fbf7..e159cef58396 100644 --- a/exporter/datadogexporter/go.sum +++ b/exporter/datadogexporter/go.sum @@ -92,17 +92,17 @@ github.com/DataDog/go-tuf v1.0.2-0.5.2 h1:EeZr937eKAWPxJ26IykAdWA4A0jQXJgkhUjqEI github.com/DataDog/go-tuf v1.0.2-0.5.2/go.mod h1:zBcq6f654iVqmkk8n2Cx81E1JnNTMOAx1UEO/wZR+P0= github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee h1:tXibLZk3G6HncIFJKaNItsdzcrk4YqILNDZlXPTNt4k= github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee/go.mod h1:nTot/Iy0kW16bXgXr6blEc8gFeAS7vTqYlhAxh+dbc0= -github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0 h1:kiPtYAgzvlOc6HV0qwS8xNeA39cYyAJs6q9dIRDpCFk= -github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0/go.mod h1:MV/L0ESKjLGGE4JPDIDtz6H5u+9w0UKp1Wsw2lLREII= -github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.10.0 h1:O2PYvgTQA+31NuepzQqLexEpUX8FWsdNgq+0241OtH0= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 h1:56vp8vflG6lmhTO+YldUBTe0cIjStOC1neW1dIHYm5s= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0/go.mod h1:naFq9h+fQpgI7AKJ+YkWlAAYDU8/FB8LyfA39bmRNHs= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0 h1:+LxQNTpRM57lfcbGV7s+PVQ2B2Pegabfpf3yGJUXcgM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0/go.mod h1:WYm0DRBxBrKrmZrwoAJhcyJ7bGAFZbVQFcrrwwaGozU= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 h1:XwGT7/2NnO1RGxS5WD4BTsLWqO+z8234XBccUGhP8tM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0/go.mod h1:1fYkFs2pUyqBUUVDsjn1cKVEI79R+NluYhqX+pDTkSY= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 h1:mEao3xEP7iCfCd+teps0oM8U+ZRPVz02W6aE5cfi2Sc= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0/go.mod h1:vPjlCjTrBzzZpVJbbVpox8x9nRYx5giCl/9Zy8oWFw0= +github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0 h1:7Y53V1RUKMI5M8lyte5QziGxUEaGcWO4Raq89cL5oZo= +github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0/go.mod h1:HZEgHdrdgnyYCT1veZEn8TonMMo+oBHuq2IZ/PlTbyE= +github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.11.0 h1:4ifgkQU0qHxrCE5axRmI4AaJYZLj95VEVxIbXlIPLUg= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 h1:qaqPqVPoiW8p9/RYaF5m7qt47+jSv6bXXeP9XM7UbfA= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0/go.mod h1:YV4ZdhvqDCGIA17CFm2QZWe1AHL+YY5UEpnTWYXLIm8= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0 h1:hI0ADWaPLkG7TDZSx/RX+hxTwBeI0BKF0Wmx2genfMw= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0/go.mod h1:Xl5jjxQujCHLCB5gMwHB2jkVsE/TX+YUAkHBc6pFLu0= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 h1:JAFzV1P69kSvlmd8D+i9V6kpxOuy8WVbGUBGxufLjtI= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0/go.mod h1:cP0qZvP+u4jzz2z28KzxFYww4xX2sYv+yPQAMSLoSMU= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 h1:G5fefqlKYsJX0iqkp5Smdica6J3Ty7Gay8NINjwpdpY= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0/go.mod h1:4ed2dYa6xQKKfVhJoLpNf89N0pKA8H2R0SyiCcL6PoI= github.com/DataDog/sketches-go v1.4.3 h1:ZB9nijteJRFUQixkQfatCqASartGNfiolIlMiEv3u/w= github.com/DataDog/sketches-go v1.4.3/go.mod h1:XR0ns2RtEEF09mDKXiKZiQg+nfZStrq1ZuL1eezeZe0= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= diff --git a/exporter/datadogexporter/integrationtest/go.mod b/exporter/datadogexporter/integrationtest/go.mod index 68408c08cf5a..abab5718042c 100644 --- a/exporter/datadogexporter/integrationtest/go.mod +++ b/exporter/datadogexporter/integrationtest/go.mod @@ -42,11 +42,11 @@ require ( github.com/DataDog/go-sqllexer v0.0.8 // indirect github.com/DataDog/go-tuf v1.0.2-0.5.2 // indirect github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 // indirect github.com/DataDog/sketches-go v1.4.3 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 // indirect diff --git a/exporter/datadogexporter/integrationtest/go.sum b/exporter/datadogexporter/integrationtest/go.sum index 9cef59653640..f4b04467cd13 100644 --- a/exporter/datadogexporter/integrationtest/go.sum +++ b/exporter/datadogexporter/integrationtest/go.sum @@ -80,17 +80,17 @@ github.com/DataDog/go-tuf v1.0.2-0.5.2 h1:EeZr937eKAWPxJ26IykAdWA4A0jQXJgkhUjqEI github.com/DataDog/go-tuf v1.0.2-0.5.2/go.mod h1:zBcq6f654iVqmkk8n2Cx81E1JnNTMOAx1UEO/wZR+P0= github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee h1:tXibLZk3G6HncIFJKaNItsdzcrk4YqILNDZlXPTNt4k= github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee/go.mod h1:nTot/Iy0kW16bXgXr6blEc8gFeAS7vTqYlhAxh+dbc0= -github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0 h1:kiPtYAgzvlOc6HV0qwS8xNeA39cYyAJs6q9dIRDpCFk= -github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0/go.mod h1:MV/L0ESKjLGGE4JPDIDtz6H5u+9w0UKp1Wsw2lLREII= -github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.10.0 h1:O2PYvgTQA+31NuepzQqLexEpUX8FWsdNgq+0241OtH0= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 h1:56vp8vflG6lmhTO+YldUBTe0cIjStOC1neW1dIHYm5s= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0/go.mod h1:naFq9h+fQpgI7AKJ+YkWlAAYDU8/FB8LyfA39bmRNHs= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0 h1:+LxQNTpRM57lfcbGV7s+PVQ2B2Pegabfpf3yGJUXcgM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0/go.mod h1:WYm0DRBxBrKrmZrwoAJhcyJ7bGAFZbVQFcrrwwaGozU= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 h1:XwGT7/2NnO1RGxS5WD4BTsLWqO+z8234XBccUGhP8tM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0/go.mod h1:1fYkFs2pUyqBUUVDsjn1cKVEI79R+NluYhqX+pDTkSY= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 h1:mEao3xEP7iCfCd+teps0oM8U+ZRPVz02W6aE5cfi2Sc= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0/go.mod h1:vPjlCjTrBzzZpVJbbVpox8x9nRYx5giCl/9Zy8oWFw0= +github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0 h1:7Y53V1RUKMI5M8lyte5QziGxUEaGcWO4Raq89cL5oZo= +github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0/go.mod h1:HZEgHdrdgnyYCT1veZEn8TonMMo+oBHuq2IZ/PlTbyE= +github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.11.0 h1:4ifgkQU0qHxrCE5axRmI4AaJYZLj95VEVxIbXlIPLUg= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 h1:qaqPqVPoiW8p9/RYaF5m7qt47+jSv6bXXeP9XM7UbfA= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0/go.mod h1:YV4ZdhvqDCGIA17CFm2QZWe1AHL+YY5UEpnTWYXLIm8= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0 h1:hI0ADWaPLkG7TDZSx/RX+hxTwBeI0BKF0Wmx2genfMw= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0/go.mod h1:Xl5jjxQujCHLCB5gMwHB2jkVsE/TX+YUAkHBc6pFLu0= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 h1:JAFzV1P69kSvlmd8D+i9V6kpxOuy8WVbGUBGxufLjtI= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0/go.mod h1:cP0qZvP+u4jzz2z28KzxFYww4xX2sYv+yPQAMSLoSMU= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 h1:G5fefqlKYsJX0iqkp5Smdica6J3Ty7Gay8NINjwpdpY= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0/go.mod h1:4ed2dYa6xQKKfVhJoLpNf89N0pKA8H2R0SyiCcL6PoI= github.com/DataDog/sketches-go v1.4.3 h1:ZB9nijteJRFUQixkQfatCqASartGNfiolIlMiEv3u/w= github.com/DataDog/sketches-go v1.4.3/go.mod h1:XR0ns2RtEEF09mDKXiKZiQg+nfZStrq1ZuL1eezeZe0= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= diff --git a/exporter/datadogexporter/internal/metrics/consumer_test.go b/exporter/datadogexporter/internal/metrics/consumer_test.go index d9b84df03367..eefe38964830 100644 --- a/exporter/datadogexporter/internal/metrics/consumer_test.go +++ b/exporter/datadogexporter/internal/metrics/consumer_test.go @@ -31,7 +31,10 @@ func (t testProvider) Source(context.Context) (source.Source, error) { func newTranslator(t *testing.T, logger *zap.Logger) *metrics.Translator { set := componenttest.NewNopTelemetrySettings() set.Logger = logger + attributesTranslator, err := attributes.NewTranslator(set) + require.NoError(t, err) tr, err := metrics.NewTranslator(set, + attributesTranslator, metrics.WithHistogramMode(metrics.HistogramModeDistributions), metrics.WithNumberMode(metrics.NumberModeCumulativeToDelta), metrics.WithFallbackSourceProvider(testProvider("fallbackHostname")), diff --git a/exporter/datadogexporter/logs_exporter.go b/exporter/datadogexporter/logs_exporter.go index 92f5e50d20a6..64fbd02373cc 100644 --- a/exporter/datadogexporter/logs_exporter.go +++ b/exporter/datadogexporter/logs_exporter.go @@ -5,10 +5,11 @@ package datadogexporter // import "github.com/open-telemetry/opentelemetry-colle import ( "context" + "fmt" "sync" - "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" "github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata" + "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes/source" logsmapping "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs" "go.opentelemetry.io/collector/consumer" @@ -22,14 +23,16 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter/internal/scrub" ) -// otelTag specifies a tag to be added to all logs sent from the Datadog exporter -const otelTag = "otel_source:datadog_exporter" +// otelSource specifies a source to be added to all logs sent from the Datadog exporter +// The tag has key `otel_source` and the value specified on this constant. +const otelSource = "datadog_exporter" type logsExporter struct { params exporter.CreateSettings cfg *Config ctx context.Context // ctx triggers shutdown upon cancellation scrubber scrub.Scrubber // scrubber scrubs sensitive information from error messages + translator *logsmapping.Translator sender *logs.Sender onceMetadata *sync.Once sourceProvider source.Provider @@ -42,6 +45,7 @@ func newLogsExporter( params exporter.CreateSettings, cfg *Config, onceMetadata *sync.Once, + attributesTranslator *attributes.Translator, sourceProvider source.Provider, metadataReporter *inframetadata.Reporter, ) (*logsExporter, error) { @@ -66,12 +70,17 @@ func newLogsExporter( } } + translator, err := logsmapping.NewTranslator(params.TelemetrySettings, attributesTranslator, otelSource) + if err != nil { + return nil, fmt.Errorf("failed to create logs translator: %w", err) + } s := logs.NewSender(cfg.Logs.TCPAddr.Endpoint, params.Logger, cfg.TimeoutSettings, cfg.LimitedHTTPClientSettings.TLSSetting.InsecureSkipVerify, cfg.Logs.DumpPayloads, string(cfg.API.Key)) return &logsExporter{ params: params, cfg: cfg, ctx: ctx, + translator: translator, sender: s, onceMetadata: onceMetadata, scrubber: scrub.NewScrubber(), @@ -83,7 +92,7 @@ func newLogsExporter( var _ consumer.ConsumeLogsFunc = (*logsExporter)(nil).consumeLogs // consumeLogs is implementation of cosumer.ConsumeLogsFunc -func (exp *logsExporter) consumeLogs(_ context.Context, ld plog.Logs) (err error) { +func (exp *logsExporter) consumeLogs(ctx context.Context, ld plog.Logs) (err error) { defer func() { err = exp.scrubber.Scrub(err) }() if exp.cfg.HostMetadata.Enabled { // start host metadata with resource attributes from @@ -103,29 +112,6 @@ func (exp *logsExporter) consumeLogs(_ context.Context, ld plog.Logs) (err error } } - rsl := ld.ResourceLogs() - var payloads []datadogV2.HTTPLogItem - // Iterate over resource logs - for i := 0; i < rsl.Len(); i++ { - rl := rsl.At(i) - sls := rl.ScopeLogs() - res := rl.Resource() - for j := 0; j < sls.Len(); j++ { - sl := sls.At(j) - lsl := sl.LogRecords() - // iterate over Logs - for k := 0; k < lsl.Len(); k++ { - log := lsl.At(k) - payload := logsmapping.Transform(log, res, exp.params.Logger) - ddtags := payload.GetDdtags() - if ddtags != "" { - payload.SetDdtags(ddtags + "," + otelTag) - } else { - payload.SetDdtags(otelTag) - } - payloads = append(payloads, payload) - } - } - } + payloads := exp.translator.MapLogs(ctx, ld) return exp.sender.SubmitLogs(exp.ctx, payloads) } diff --git a/exporter/datadogexporter/metrics_exporter.go b/exporter/datadogexporter/metrics_exporter.go index b0144727ebd0..c09450465952 100644 --- a/exporter/datadogexporter/metrics_exporter.go +++ b/exporter/datadogexporter/metrics_exporter.go @@ -16,6 +16,7 @@ import ( "github.com/DataDog/datadog-agent/pkg/trace/api" "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" "github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata" + "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes/source" otlpmetrics "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics" "go.opentelemetry.io/collector/component" @@ -51,7 +52,7 @@ type metricsExporter struct { } // translatorFromConfig creates a new metrics translator from the exporter -func translatorFromConfig(set component.TelemetrySettings, cfg *Config, sourceProvider source.Provider) (*otlpmetrics.Translator, error) { +func translatorFromConfig(set component.TelemetrySettings, cfg *Config, attrsTranslator *attributes.Translator, sourceProvider source.Provider) (*otlpmetrics.Translator, error) { options := []otlpmetrics.TranslatorOption{ otlpmetrics.WithDeltaTTL(cfg.Metrics.DeltaTTL), otlpmetrics.WithFallbackSourceProvider(sourceProvider), @@ -83,7 +84,7 @@ func translatorFromConfig(set component.TelemetrySettings, cfg *Config, sourcePr options = append(options, otlpmetrics.WithInitialCumulMonoValueMode( otlpmetrics.InitialCumulMonoValueMode(cfg.Metrics.SumConfig.InitialCumulativeMonotonicMode))) - return otlpmetrics.NewTranslator(set, options...) + return otlpmetrics.NewTranslator(set, attrsTranslator, options...) } func newMetricsExporter( @@ -91,11 +92,12 @@ func newMetricsExporter( params exporter.CreateSettings, cfg *Config, onceMetadata *sync.Once, + attrsTranslator *attributes.Translator, sourceProvider source.Provider, apmStatsProcessor api.StatsProcessor, metadataReporter *inframetadata.Reporter, ) (*metricsExporter, error) { - tr, err := translatorFromConfig(params.TelemetrySettings, cfg, sourceProvider) + tr, err := translatorFromConfig(params.TelemetrySettings, cfg, attrsTranslator, sourceProvider) if err != nil { return nil, err } diff --git a/exporter/datadogexporter/metrics_exporter_test.go b/exporter/datadogexporter/metrics_exporter_test.go index 8bb134e86d83..5d3482a159f4 100644 --- a/exporter/datadogexporter/metrics_exporter_test.go +++ b/exporter/datadogexporter/metrics_exporter_test.go @@ -19,6 +19,7 @@ import ( "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" "github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata" "github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata/payload" + "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes/source" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics" "github.com/stretchr/testify/assert" @@ -303,12 +304,14 @@ func Test_metricsExporter_PushMetricsData(t *testing.T) { pusher := newTestPusher(t) reporter, err := inframetadata.NewReporter(zap.NewNop(), pusher, 1*time.Second) require.NoError(t, err) - + attributesTranslator, err := attributes.NewTranslator(componenttest.NewNopTelemetrySettings()) + require.NoError(t, err) exp, err := newMetricsExporter( context.Background(), exportertest.NewNopCreateSettings(), newTestConfig(t, server.URL, tt.hostTags, tt.histogramMode), &once, + attributesTranslator, &testutil.MockSourceProvider{Src: tt.source}, &statsRecorder, reporter, @@ -615,7 +618,7 @@ func Test_metricsExporter_PushMetricsData_Zorkian(t *testing.T) { expectedErr: nil, }, { - metrics: createTestMetricsWithStats(), + metrics: createTestMetricsWithStats(t), source: source.Source{ Kind: source.HostnameKind, Identifier: "test-host", @@ -692,11 +695,14 @@ func Test_metricsExporter_PushMetricsData_Zorkian(t *testing.T) { pusher := newTestPusher(t) reporter, err := inframetadata.NewReporter(zap.NewNop(), pusher, 1*time.Second) require.NoError(t, err) + attributesTranslator, err := attributes.NewTranslator(componenttest.NewNopTelemetrySettings()) + require.NoError(t, err) exp, err := newMetricsExporter( context.Background(), exportertest.NewNopCreateSettings(), newTestConfig(t, server.URL, tt.hostTags, tt.histogramMode), &once, + attributesTranslator, &testutil.MockSourceProvider{Src: tt.source}, &statsRecorder, reporter, @@ -745,18 +751,20 @@ func Test_metricsExporter_PushMetricsData_Zorkian(t *testing.T) { } } -func createTestMetricsWithStats() pmetric.Metrics { +func createTestMetricsWithStats(t *testing.T) pmetric.Metrics { md := createTestMetrics(map[string]string{ conventions.AttributeDeploymentEnvironment: "dev", "custom_attribute": "custom_value", }) dest := md.ResourceMetrics() set := componenttest.NewNopTelemetrySettings() - set.Logger, _ = zap.NewDevelopment() - trans, err := metrics.NewTranslator(set) - if err != nil { - panic(err) - } + var err error + set.Logger, err = zap.NewDevelopment() + require.NoError(t, err) + attributesTranslator, err := attributes.NewTranslator(set) + require.NoError(t, err) + trans, err := metrics.NewTranslator(set, attributesTranslator) + require.NoError(t, err) src := trans. StatsPayloadToMetrics(&pb.StatsPayload{Stats: testutil.StatsPayloads}). ResourceMetrics() diff --git a/go.mod b/go.mod index 60a9ad77c3bb..0c72fa1e9a7e 100644 --- a/go.mod +++ b/go.mod @@ -250,11 +250,11 @@ require ( github.com/DataDog/go-sqllexer v0.0.8 // indirect github.com/DataDog/go-tuf v1.0.2-0.5.2 // indirect github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 // indirect github.com/DataDog/sketches-go v1.4.3 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect diff --git a/go.sum b/go.sum index fe1ebd8830b8..15c99338a8f9 100644 --- a/go.sum +++ b/go.sum @@ -188,17 +188,17 @@ github.com/DataDog/go-tuf v1.0.2-0.5.2 h1:EeZr937eKAWPxJ26IykAdWA4A0jQXJgkhUjqEI github.com/DataDog/go-tuf v1.0.2-0.5.2/go.mod h1:zBcq6f654iVqmkk8n2Cx81E1JnNTMOAx1UEO/wZR+P0= github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee h1:tXibLZk3G6HncIFJKaNItsdzcrk4YqILNDZlXPTNt4k= github.com/DataDog/gohai v0.0.0-20230524154621-4316413895ee/go.mod h1:nTot/Iy0kW16bXgXr6blEc8gFeAS7vTqYlhAxh+dbc0= -github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0 h1:kiPtYAgzvlOc6HV0qwS8xNeA39cYyAJs6q9dIRDpCFk= -github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.10.0/go.mod h1:MV/L0ESKjLGGE4JPDIDtz6H5u+9w0UKp1Wsw2lLREII= -github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.10.0 h1:O2PYvgTQA+31NuepzQqLexEpUX8FWsdNgq+0241OtH0= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 h1:56vp8vflG6lmhTO+YldUBTe0cIjStOC1neW1dIHYm5s= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0/go.mod h1:naFq9h+fQpgI7AKJ+YkWlAAYDU8/FB8LyfA39bmRNHs= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0 h1:+LxQNTpRM57lfcbGV7s+PVQ2B2Pegabfpf3yGJUXcgM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.10.0/go.mod h1:WYm0DRBxBrKrmZrwoAJhcyJ7bGAFZbVQFcrrwwaGozU= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 h1:XwGT7/2NnO1RGxS5WD4BTsLWqO+z8234XBccUGhP8tM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0/go.mod h1:1fYkFs2pUyqBUUVDsjn1cKVEI79R+NluYhqX+pDTkSY= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 h1:mEao3xEP7iCfCd+teps0oM8U+ZRPVz02W6aE5cfi2Sc= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0/go.mod h1:vPjlCjTrBzzZpVJbbVpox8x9nRYx5giCl/9Zy8oWFw0= +github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0 h1:7Y53V1RUKMI5M8lyte5QziGxUEaGcWO4Raq89cL5oZo= +github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.11.0/go.mod h1:HZEgHdrdgnyYCT1veZEn8TonMMo+oBHuq2IZ/PlTbyE= +github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.11.0 h1:4ifgkQU0qHxrCE5axRmI4AaJYZLj95VEVxIbXlIPLUg= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 h1:qaqPqVPoiW8p9/RYaF5m7qt47+jSv6bXXeP9XM7UbfA= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0/go.mod h1:YV4ZdhvqDCGIA17CFm2QZWe1AHL+YY5UEpnTWYXLIm8= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0 h1:hI0ADWaPLkG7TDZSx/RX+hxTwBeI0BKF0Wmx2genfMw= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.11.0/go.mod h1:Xl5jjxQujCHLCB5gMwHB2jkVsE/TX+YUAkHBc6pFLu0= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 h1:JAFzV1P69kSvlmd8D+i9V6kpxOuy8WVbGUBGxufLjtI= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0/go.mod h1:cP0qZvP+u4jzz2z28KzxFYww4xX2sYv+yPQAMSLoSMU= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 h1:G5fefqlKYsJX0iqkp5Smdica6J3Ty7Gay8NINjwpdpY= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0/go.mod h1:4ed2dYa6xQKKfVhJoLpNf89N0pKA8H2R0SyiCcL6PoI= github.com/DataDog/sketches-go v1.4.3 h1:ZB9nijteJRFUQixkQfatCqASartGNfiolIlMiEv3u/w= github.com/DataDog/sketches-go v1.4.3/go.mod h1:XR0ns2RtEEF09mDKXiKZiQg+nfZStrq1ZuL1eezeZe0= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= diff --git a/internal/datadog/go.mod b/internal/datadog/go.mod index 7c9d7c17a721..67aa8fe8bcfa 100644 --- a/internal/datadog/go.mod +++ b/internal/datadog/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/DataDog/datadog-agent/pkg/proto v0.50.0 github.com/DataDog/datadog-agent/pkg/trace v0.50.0 - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/pdata v1.0.0 ) @@ -20,8 +20,8 @@ require ( github.com/DataDog/datadog-go/v5 v5.1.1 // indirect github.com/DataDog/go-sqllexer v0.0.8 // indirect github.com/DataDog/go-tuf v1.0.2-0.5.2 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 // indirect github.com/DataDog/sketches-go v1.4.3 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect diff --git a/internal/datadog/go.sum b/internal/datadog/go.sum index 21b1924ee64f..3ef5da9d5d28 100644 --- a/internal/datadog/go.sum +++ b/internal/datadog/go.sum @@ -20,13 +20,13 @@ github.com/DataDog/go-sqllexer v0.0.8 h1:vfC8R9PhmJfeOKcFYAX9UOd890A3wu3KrjU9Kr7 github.com/DataDog/go-sqllexer v0.0.8/go.mod h1:nB4Ea2YNsqMwtbWMc4Fm/oP98IIrSPapqwOwPioMspY= github.com/DataDog/go-tuf v1.0.2-0.5.2 h1:EeZr937eKAWPxJ26IykAdWA4A0jQXJgkhUjqEI/w7+I= github.com/DataDog/go-tuf v1.0.2-0.5.2/go.mod h1:zBcq6f654iVqmkk8n2Cx81E1JnNTMOAx1UEO/wZR+P0= -github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.10.0 h1:O2PYvgTQA+31NuepzQqLexEpUX8FWsdNgq+0241OtH0= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 h1:56vp8vflG6lmhTO+YldUBTe0cIjStOC1neW1dIHYm5s= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0/go.mod h1:naFq9h+fQpgI7AKJ+YkWlAAYDU8/FB8LyfA39bmRNHs= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 h1:XwGT7/2NnO1RGxS5WD4BTsLWqO+z8234XBccUGhP8tM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0/go.mod h1:1fYkFs2pUyqBUUVDsjn1cKVEI79R+NluYhqX+pDTkSY= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 h1:mEao3xEP7iCfCd+teps0oM8U+ZRPVz02W6aE5cfi2Sc= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0/go.mod h1:vPjlCjTrBzzZpVJbbVpox8x9nRYx5giCl/9Zy8oWFw0= +github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.11.0 h1:4ifgkQU0qHxrCE5axRmI4AaJYZLj95VEVxIbXlIPLUg= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 h1:qaqPqVPoiW8p9/RYaF5m7qt47+jSv6bXXeP9XM7UbfA= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0/go.mod h1:YV4ZdhvqDCGIA17CFm2QZWe1AHL+YY5UEpnTWYXLIm8= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 h1:JAFzV1P69kSvlmd8D+i9V6kpxOuy8WVbGUBGxufLjtI= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0/go.mod h1:cP0qZvP+u4jzz2z28KzxFYww4xX2sYv+yPQAMSLoSMU= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 h1:G5fefqlKYsJX0iqkp5Smdica6J3Ty7Gay8NINjwpdpY= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0/go.mod h1:4ed2dYa6xQKKfVhJoLpNf89N0pKA8H2R0SyiCcL6PoI= github.com/DataDog/sketches-go v1.4.3 h1:ZB9nijteJRFUQixkQfatCqASartGNfiolIlMiEv3u/w= github.com/DataDog/sketches-go v1.4.3/go.mod h1:XR0ns2RtEEF09mDKXiKZiQg+nfZStrq1ZuL1eezeZe0= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= diff --git a/processor/datadogprocessor/go.mod b/processor/datadogprocessor/go.mod index 3d8f74b6ee56..24cc16d5f015 100644 --- a/processor/datadogprocessor/go.mod +++ b/processor/datadogprocessor/go.mod @@ -5,7 +5,8 @@ go 1.20 require ( github.com/DataDog/datadog-agent/pkg/proto v0.50.0 - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 + github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 github.com/DataDog/sketches-go v1.4.3 github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.91.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/datadog v0.91.0 @@ -34,8 +35,7 @@ require ( github.com/DataDog/datadog-go/v5 v5.1.1 // indirect github.com/DataDog/go-sqllexer v0.0.8 // indirect github.com/DataDog/go-tuf v1.0.2-0.5.2 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 // indirect + github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect diff --git a/processor/datadogprocessor/go.sum b/processor/datadogprocessor/go.sum index fe22064596f0..149750071d92 100644 --- a/processor/datadogprocessor/go.sum +++ b/processor/datadogprocessor/go.sum @@ -20,13 +20,13 @@ github.com/DataDog/go-sqllexer v0.0.8 h1:vfC8R9PhmJfeOKcFYAX9UOd890A3wu3KrjU9Kr7 github.com/DataDog/go-sqllexer v0.0.8/go.mod h1:nB4Ea2YNsqMwtbWMc4Fm/oP98IIrSPapqwOwPioMspY= github.com/DataDog/go-tuf v1.0.2-0.5.2 h1:EeZr937eKAWPxJ26IykAdWA4A0jQXJgkhUjqEI/w7+I= github.com/DataDog/go-tuf v1.0.2-0.5.2/go.mod h1:zBcq6f654iVqmkk8n2Cx81E1JnNTMOAx1UEO/wZR+P0= -github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.10.0 h1:O2PYvgTQA+31NuepzQqLexEpUX8FWsdNgq+0241OtH0= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0 h1:56vp8vflG6lmhTO+YldUBTe0cIjStOC1neW1dIHYm5s= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.10.0/go.mod h1:naFq9h+fQpgI7AKJ+YkWlAAYDU8/FB8LyfA39bmRNHs= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0 h1:XwGT7/2NnO1RGxS5WD4BTsLWqO+z8234XBccUGhP8tM= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.10.0/go.mod h1:1fYkFs2pUyqBUUVDsjn1cKVEI79R+NluYhqX+pDTkSY= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0 h1:mEao3xEP7iCfCd+teps0oM8U+ZRPVz02W6aE5cfi2Sc= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.10.0/go.mod h1:vPjlCjTrBzzZpVJbbVpox8x9nRYx5giCl/9Zy8oWFw0= +github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.11.0 h1:4ifgkQU0qHxrCE5axRmI4AaJYZLj95VEVxIbXlIPLUg= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0 h1:qaqPqVPoiW8p9/RYaF5m7qt47+jSv6bXXeP9XM7UbfA= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.11.0/go.mod h1:YV4ZdhvqDCGIA17CFm2QZWe1AHL+YY5UEpnTWYXLIm8= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0 h1:JAFzV1P69kSvlmd8D+i9V6kpxOuy8WVbGUBGxufLjtI= +github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.11.0/go.mod h1:cP0qZvP+u4jzz2z28KzxFYww4xX2sYv+yPQAMSLoSMU= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0 h1:G5fefqlKYsJX0iqkp5Smdica6J3Ty7Gay8NINjwpdpY= +github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.11.0/go.mod h1:4ed2dYa6xQKKfVhJoLpNf89N0pKA8H2R0SyiCcL6PoI= github.com/DataDog/sketches-go v1.4.3 h1:ZB9nijteJRFUQixkQfatCqASartGNfiolIlMiEv3u/w= github.com/DataDog/sketches-go v1.4.3/go.mod h1:XR0ns2RtEEF09mDKXiKZiQg+nfZStrq1ZuL1eezeZe0= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= diff --git a/processor/datadogprocessor/processor.go b/processor/datadogprocessor/processor.go index 7eb70d5fa3e3..47a29912f1af 100644 --- a/processor/datadogprocessor/processor.go +++ b/processor/datadogprocessor/processor.go @@ -8,11 +8,13 @@ import ( "fmt" pb "github.com/DataDog/datadog-agent/pkg/proto/pbgo/trace" + "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/otel/metric/noop" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/datadog" @@ -47,7 +49,12 @@ type datadogProcessor struct { func newProcessor(ctx context.Context, set component.TelemetrySettings, config component.Config, nextConsumer consumer.Traces) (*datadogProcessor, error) { cfg := config.(*Config) in := make(chan *pb.StatsPayload, 100) - trans, err := metrics.NewTranslator(set) + set.MeterProvider = noop.NewMeterProvider() // disable metrics for the processor + attributesTranslator, err := attributes.NewTranslator(set) + if err != nil { + return nil, err + } + trans, err := metrics.NewTranslator(set, attributesTranslator) if err != nil { return nil, err }