Skip to content

Commit

Permalink
[pkg/otlp] Use resourcetotelemetry when ResourceAttributesAsTags is t…
Browse files Browse the repository at this point in the history
…rue (DataDog#9982)

Wraps the internal metrics exporter with resourcetotelemetry to automatically convert resource attributes into tags when ResourceAttributesAsTags is true.
  • Loading branch information
KSerrania authored Nov 24, 2021
1 parent 8a8e514 commit cd3afeb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions .copyright-overrides.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ github.com/google/go-cmp/*: The Go Authors
github.com/grpc-ecosystem/*: Gengo, Inc
github.com/hashicorp/*: HashiCorp Inc.
github.com/prometheus/*: The Prometheus Authors
github.com/open-telemetry/*: Open Telemetry Maintainers
go.etcd.io/*: the etcd maintainers
google.golang.org/appengine: the Go App Engine Maintainers
google.golang.org/appengine/*: the Go App Engine Maintainers
Expand Down
1 change: 1 addition & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ core,github.com/open-policy-agent/opa/topdown/print,Apache-2.0,The OPA Authors
core,github.com/open-policy-agent/opa/types,Apache-2.0,The OPA Authors
core,github.com/open-policy-agent/opa/util,Apache-2.0,The OPA Authors
core,github.com/open-policy-agent/opa/version,Apache-2.0,The OPA Authors
core,github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry,Apache-2.0,Open Telemetry Maintainers
core,github.com/opencontainers/go-digest,Apache-2.0,"Docker, Inc | OCI Contributors"
core,github.com/opencontainers/image-spec/identity,Apache-2.0,The Linux Foundation
core,github.com/opencontainers/image-spec/specs-go,Apache-2.0,The Linux Foundation
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852 // indirect
github.com/open-policy-agent/opa v0.34.2
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.38.0
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
github.com/openshift/api v0.0.0-20190924102528-32369d4db2ad
github.com/patrickmn/go-cache v2.1.0+incompatible
Expand Down
18 changes: 18 additions & 0 deletions go.sum

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

9 changes: 8 additions & 1 deletion pkg/otlp/internal/serializerexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"context"

"github.com/DataDog/datadog-agent/pkg/serializer"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/exporter/exporterhelper"
Expand Down Expand Up @@ -42,8 +43,14 @@ func (f *factory) createMetricExporter(_ context.Context, params component.Expor
return nil, err
}

return exporterhelper.NewMetricsExporter(cfg, params, exp.ConsumeMetrics,
exporter, err := exporterhelper.NewMetricsExporter(cfg, params, exp.ConsumeMetrics,
exporterhelper.WithQueue(cfg.QueueSettings),
exporterhelper.WithTimeout(cfg.TimeoutSettings),
)
if err != nil {
return nil, err
}

return resourcetotelemetry.WrapMetricsExporter(
resourcetotelemetry.Settings{Enabled: cfg.Metrics.ExporterConfig.ResourceAttributesAsTags}, exporter), nil
}

0 comments on commit cd3afeb

Please sign in to comment.