Skip to content

Commit

Permalink
[*/datadog] Update to opentelemetry-mapping-go v0.11.0 (#30158)
Browse files Browse the repository at this point in the history
**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.
  • Loading branch information
mx-psi authored Dec 21, 2023
1 parent 43932b2 commit 9a34aea
Show file tree
Hide file tree
Showing 24 changed files with 208 additions and 159 deletions.
13 changes: 10 additions & 3 deletions .chloggen/dd-exporter-metric.yaml → .chloggen/mx-psi_update-tov0.11.0.yaml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions cmd/configschema/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions cmd/otelcontribcol/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions connector/datadogconnector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions connector/datadogconnector/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions connector/datadogconnector/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 30 additions & 2 deletions exporter/datadogexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions exporter/datadogexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 9a34aea

Please sign in to comment.