From 081036f7ec3a79ef81e21dc159289a47883a978d Mon Sep 17 00:00:00 2001 From: Ahmed Mezghani Date: Mon, 20 Nov 2023 10:24:01 +0100 Subject: [PATCH] tracer: report rc capabilities for dynamic config --- ddtrace/tracer/remote_config.go | 8 ++++++++ ddtrace/tracer/remote_config_test.go | 18 ++++++++++++++++++ internal/remoteconfig/remoteconfig.go | 14 +++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/ddtrace/tracer/remote_config.go b/ddtrace/tracer/remote_config.go index 9e276b1d09..e6b95aa0da 100644 --- a/ddtrace/tracer/remote_config.go +++ b/ddtrace/tracer/remote_config.go @@ -115,5 +115,13 @@ func (t *tracer) startRemoteConfig(rcConfig remoteconfig.ClientConfig) error { if err != nil { return err } + err = remoteconfig.RegisterCapability(remoteconfig.APMTracingSampleRate) + if err != nil { + return err + } + err = remoteconfig.RegisterCapability(remoteconfig.APMTracingHTTPHeaderTags) + if err != nil { + return err + } return remoteconfig.RegisterCallback(t.onRemoteConfigUpdate) } diff --git a/ddtrace/tracer/remote_config_test.go b/ddtrace/tracer/remote_config_test.go index 86f441973b..3e7a339ea4 100644 --- a/ddtrace/tracer/remote_config_test.go +++ b/ddtrace/tracer/remote_config_test.go @@ -237,3 +237,21 @@ func TestOnRemoteConfigUpdate(t *testing.T) { telemetryClient.AssertNumberOfCalls(t, "ConfigChange", 0) }) } + +func TestStartRemoteConfig(t *testing.T) { + tracer, _, _, stop := startTestTracer(t) + defer stop() + + tracer.startRemoteConfig(remoteconfig.DefaultClientConfig()) + found, err := remoteconfig.HasProduct(state.ProductAPMTracing) + require.NoError(t, err) + require.True(t, found) + + found, err = remoteconfig.HasCapability(remoteconfig.APMTracingSampleRate) + require.NoError(t, err) + require.True(t, found) + + found, err = remoteconfig.HasCapability(remoteconfig.APMTracingHTTPHeaderTags) + require.NoError(t, err) + require.True(t, found) +} diff --git a/internal/remoteconfig/remoteconfig.go b/internal/remoteconfig/remoteconfig.go index 593eb06042..70c0b9190f 100644 --- a/internal/remoteconfig/remoteconfig.go +++ b/internal/remoteconfig/remoteconfig.go @@ -53,8 +53,20 @@ const ( ASMUserBlocking // ASMCustomRules represents the capability for ASM to receive and use user-defined security rules ASMCustomRules - // ASMCustomRules represents the capability for ASM to receive and use user-defined blocking responses + // ASMCustomBlockingResponse represents the capability for ASM to receive and use user-defined blocking responses ASMCustomBlockingResponse + // ASMTrustedIPs represents Trusted IPs through the ASM product + ASMTrustedIPs + // ASMApiSecuritySampleRate represents API Security sampling rate + ASMApiSecuritySampleRate + // APMTracingSampleRate represents the rate at which to sample traces from APM client libraries + APMTracingSampleRate + // APMTracingLogsInjection enables APM client libraries to inject trace ids into log records + APMTracingLogsInjection + // APMTracingHTTPHeaderTags enables APM client libraries to tag http header values to http server or client spans + APMTracingHTTPHeaderTags + // APMTracingCustomTags enables APM client to set custom tags on all spans + APMTracingCustomTags ) // ErrClientNotStarted is returned when the remote config client is not started.