Skip to content

Commit

Permalink
Report telemetry for 'config consistency' config items
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoffl01 committed Sep 17, 2024
1 parent 4574919 commit 48ea87b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ddtrace/tracer/rules_sampler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext"
"gopkg.in/DataDog/dd-trace-go.v1/internal/log"
"gopkg.in/DataDog/dd-trace-go.v1/internal/samplernames"
"gopkg.in/DataDog/dd-trace-go.v1/internal/telemetry"

"golang.org/x/time/rate"
)
Expand Down Expand Up @@ -533,6 +534,7 @@ const defaultRateLimit = 100.0
// The limit is DD_TRACE_RATE_LIMIT if set, `defaultRateLimit` otherwise.
func newRateLimiter() *rateLimiter {
limit := defaultRateLimit
origin := telemetry.OriginDefault
v := os.Getenv("DD_TRACE_RATE_LIMIT")
if v != "" {
l, err := strconv.ParseFloat(v, 64)
Expand All @@ -542,9 +544,11 @@ func newRateLimiter() *rateLimiter {
log.Warn("DD_TRACE_RATE_LIMIT negative, using default value %f", limit)
} else {
// override the default limit
origin = telemetry.OriginEnvVar
limit = l
}
}
reportTelemetryOnAppStarted(telemetry.Configuration{Name: "trace_rate_limit", Value: limit, Origin: origin})
return &rateLimiter{
limiter: rate.NewLimiter(rate.Limit(limit), int(math.Ceil(limit))),
prevTime: time.Now(),
Expand Down
10 changes: 9 additions & 1 deletion ddtrace/tracer/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import (
"gopkg.in/DataDog/dd-trace-go.v1/internal/telemetry"
)

var additionalConfigs []telemetry.Configuration

func reportTelemetryOnAppStarted(c telemetry.Configuration) {
additionalConfigs = append(additionalConfigs, c)
}

// startTelemetry starts the global instrumentation telemetry client with tracer data
// unless instrumentation telemetry is disabled via the DD_INSTRUMENTATION_TELEMETRY_ENABLED
// env var.
Expand Down Expand Up @@ -44,7 +50,8 @@ func startTelemetry(c *config) {
{Name: "service", Value: c.serviceName},
{Name: "universal_version", Value: c.universalVersion},
{Name: "env", Value: c.env},
{Name: "agent_url", Value: c.agentURL.String()},
{Name: "version", Value: c.version},
{Name: "trace_agent_url", Value: c.agentURL.String()},
{Name: "agent_hostname", Value: c.hostname},
{Name: "runtime_metrics_enabled", Value: c.runtimeMetrics},
{Name: "dogstatsd_addr", Value: c.dogstatsdAddr},
Expand Down Expand Up @@ -102,5 +109,6 @@ func startTelemetry(c *config) {
telemetryConfigs = append(telemetryConfigs, telemetry.Configuration{Name: "orchestrion_" + k, Value: v})
}
}
telemetryConfigs = append(telemetryConfigs, additionalConfigs...)
telemetry.GlobalClient.ProductChange(telemetry.NamespaceTracers, true, telemetryConfigs)
}

0 comments on commit 48ea87b

Please sign in to comment.