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

tracer: report rc capabilities for dynamic config #2369

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ddtrace/tracer/remote_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
18 changes: 18 additions & 0 deletions ddtrace/tracer/remote_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
14 changes: 13 additions & 1 deletion internal/remoteconfig/remoteconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +58 to +69
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The order of these capabilities matters that's why I had to add a few that aren't currently used. Each capability is defined by its rank in the list.
The full and detailed documentation for RC capabilities is internal, I can share it offline if the reviewer is interested.

Copy link
Member

Choose a reason for hiding this comment

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

IIUC, our tracer only supports APMTracingSampleRate and APMTracingHTTPHeaderTags, but no APMTracingLogsInjection and APMTracingCustomTags. From the JIRA issue, it's not clear what is the support of the latter. Probably I'm missing context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

APMTracingLogsInjection won't be supported since there is no automatic logs injection in Go. APMTracingCustomTags will be supported in future versions though.

)

// ErrClientNotStarted is returned when the remote config client is not started.
Expand Down
Loading