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

Add container tags #31642

Merged
Prev Previous commit
Next Next commit
PR feedback
  • Loading branch information
dineshg13 committed Mar 18, 2024
commit 3499beb8d827bb53744903e122038c09527a260f
11 changes: 10 additions & 1 deletion connector/datadogconnector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package datadogconnector // import "github.com/open-telemetry/opentelemetry-coll
import (
"context"
"fmt"
"time"

pb "github.com/DataDog/datadog-agent/pkg/proto/pbgo/trace"
traceconfig "github.com/DataDog/datadog-agent/pkg/trace/config"
Expand Down Expand Up @@ -51,6 +52,13 @@ type traceToMetricConnector struct {

var _ component.Component = (*traceToMetricConnector)(nil) // testing that the connectorImp properly implements the type Component interface

// cacheExpiration is the time after which a container tag cache entry will expire
// and be removed from the cache.
var cacheExpiration = time.Minute * 5
dineshg13 marked this conversation as resolved.
Show resolved Hide resolved

// cacheCleanupInterval is the time after which the cache will be cleaned up.
var cacheCleanupInterval = time.Minute

// function to create a new connector
func newTraceToMetricConnector(set component.TelemetrySettings, cfg component.Config, metricsConsumer consumer.Metrics, metricsClient statsd.ClientInterface, timingReporter timing.Reporter) (*traceToMetricConnector, error) {
set.Logger.Info("Building datadog connector for traces to metrics")
Expand Down Expand Up @@ -79,7 +87,7 @@ func newTraceToMetricConnector(set component.TelemetrySettings, cfg component.Co
in: in,
metricsConsumer: metricsConsumer,
resourceAttrs: ddtags,
containerTagCache: cache.New(cache.DefaultExpiration, cache.DefaultExpiration),
containerTagCache: cache.New(cacheExpiration, cacheCleanupInterval),
exit: make(chan struct{}),
}, nil
}
Expand All @@ -95,6 +103,7 @@ func getTraceAgentCfg(cfg TracesConfig, attributesTranslator *attributes.Transla
acfg.PeerTags = cfg.PeerTags
if len(cfg.ResourceAttributesAsContainerTags) > 0 {
acfg.Features["enable_cid_stats"] = struct{}{}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

songy23 marked this conversation as resolved.
Show resolved Hide resolved
delete(acfg.Features, "disable_cid_stats")
}
if v := cfg.TraceBuffer; v > 0 {
acfg.TraceBuffer = v
Expand Down
6 changes: 3 additions & 3 deletions connector/datadogconnector/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter v0.96.0
github.com/open-telemetry/opentelemetry-collector-contrib/internal/datadog v0.96.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.96.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.96.1-0.20240306115632-b2693620eff6
go.opentelemetry.io/collector/connector v0.96.1-0.20240306115632-b2693620eff6
Expand All @@ -23,9 +24,11 @@ require (
go.opentelemetry.io/collector/processor/batchprocessor v0.96.1-0.20240306115632-b2693620eff6
go.opentelemetry.io/collector/receiver v0.96.1-0.20240306115632-b2693620eff6
go.opentelemetry.io/collector/receiver/otlpreceiver v0.96.1-0.20240306115632-b2693620eff6
go.opentelemetry.io/collector/semconv v0.96.1-0.20240306115632-b2693620eff6
go.opentelemetry.io/otel/metric v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
go.uber.org/zap v1.27.0
google.golang.org/protobuf v1.33.0
)

require (
Expand Down Expand Up @@ -116,7 +119,6 @@ require (
github.com/openshift/api v3.9.0+incompatible // indirect
github.com/openshift/client-go v0.0.0-20210521082421-73d9475a9142 // indirect
github.com/outcaste-io/ristretto v0.2.1 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
Expand Down Expand Up @@ -158,7 +160,6 @@ require (
go.opentelemetry.io/collector/extension v0.96.1-0.20240306115632-b2693620eff6 // indirect
go.opentelemetry.io/collector/extension/auth v0.96.1-0.20240306115632-b2693620eff6 // indirect
go.opentelemetry.io/collector/featuregate v1.3.1-0.20240306115632-b2693620eff6 // indirect
go.opentelemetry.io/collector/semconv v0.96.1-0.20240306115632-b2693620eff6 // indirect
go.opentelemetry.io/collector/service v0.96.1-0.20240306115632-b2693620eff6 // indirect
go.opentelemetry.io/contrib/config v0.4.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 // indirect
Expand Down Expand Up @@ -193,7 +194,6 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down