Merge pull request #4897 from dmxlsj/feature/datadog-sample-rate

Support Datadog sample rate with global trace sampling from configmap
This commit is contained in:
Kubernetes Prow Robot 2020-01-08 03:13:40 -08:00 committed by GitHub
commit c2d6dcd162
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 1 deletions

View file

@ -131,6 +131,12 @@ The following table shows a configuration option's name, type, and the default v
|[jaeger-debug-header](#jaeger-debug-header)|string|uber-debug-id| |[jaeger-debug-header](#jaeger-debug-header)|string|uber-debug-id|
|[jaeger-baggage-header](#jaeger-baggage-header)|string|jaeger-baggage| |[jaeger-baggage-header](#jaeger-baggage-header)|string|jaeger-baggage|
|[jaeger-trace-baggage-header-prefix](#jaeger-trace-baggage-header-prefix)|string|uberctx-| |[jaeger-trace-baggage-header-prefix](#jaeger-trace-baggage-header-prefix)|string|uberctx-|
|[datadog-collector-host](#datadog-collector-host)|string|""|
|[datadog-collector-port](#datadog-collector-port)|int|8126|
|[datadog-service-name](#datadog-service-name)|service|"nginx"|
|[datadog-operation-name-override](#datadog-operation-name-override)|service|"nginx.handle"|
|[datadog-priority-sampling](#datadog-priority-sampling)|bool|"true"|
|[datadog-sample-rate](#datadog-sample-rate)|float|1.0|
|[main-snippet](#main-snippet)|string|""| |[main-snippet](#main-snippet)|string|""|
|[http-snippet](#http-snippet)|string|""| |[http-snippet](#http-snippet)|string|""|
|[server-snippet](#server-snippet)|string|""| |[server-snippet](#server-snippet)|string|""|
@ -780,6 +786,32 @@ Specifies the header name used to submit baggage if there is no root span. _**de
Specifies the header prefix used to propagate baggage. _**default:**_ uberctx- Specifies the header prefix used to propagate baggage. _**default:**_ uberctx-
## datadog-collector-host
Specifies the datadog agent host to use when uploading traces. It must be a valid URL.
## datadog-collector-port
Specifies the port to use when uploading traces. _**default:**_ 8126
## datadog-service-name
Specifies the service name to use for any traces created. _**default:**_ nginx
## datadog-operation-name-override
Overrides the operation naem to use for any traces crated. _**default:**_ nginx.handle
## datadog-priority-sampling
Specifies to use client-side sampling.
If true disables client-side sampling (thus ignoring `sample_rate`) and enables distributed priority sampling, where traces are sampled based on a combination of user-assigned priorities and configuration from the agent. _**default:**_ true
## datadog-sample-rate
Specifies sample rate for any traces created.
This is effective only when `datadog-priority-sampling` is `false` _**default:**_ 1.0
## main-snippet ## main-snippet
Adds custom configuration to the main section of the nginx configuration. Adds custom configuration to the main section of the nginx configuration.

View file

@ -88,6 +88,12 @@ datadog-service-name
# specifies the operation name to use for any traces collected, Default: nginx.handle # specifies the operation name to use for any traces collected, Default: nginx.handle
datadog-operation-name-override datadog-operation-name-override
# Specifies to use client-side sampling for distributed priority sampling and ignore sample rate, Default: true
datadog-priority-sampling
# specifies sample rate for any traces created, Default: 1.0
datadog-sample-rate
``` ```
All these options (including host) allow environment variables, such as `$HOSTNAME` or `$HOST_IP`. In the case of Jaeger, if you have a Jaeger agent running on each machine in your cluster, you can use something like `$HOST_IP` (which can be 'mounted' with the `status.hostIP` fieldpath, as described [here](https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/#capabilities-of-the-downward-api)) to make sure traces will be sent to the local agent. All these options (including host) allow environment variables, such as `$HOSTNAME` or `$HOST_IP`. In the case of Jaeger, if you have a Jaeger agent running on each machine in your cluster, you can use something like `$HOST_IP` (which can be 'mounted' with the `status.hostIP` fieldpath, as described [here](https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/#capabilities-of-the-downward-api)) to make sure traces will be sent to the local agent.

View file

@ -552,6 +552,17 @@ type Configuration struct {
// Default: nginx.handle // Default: nginx.handle
DatadogOperationNameOverride string `json:"datadog-operation-name-override"` DatadogOperationNameOverride string `json:"datadog-operation-name-override"`
// DatadogPrioritySampling specifies to use client-side sampling
// If true disables client-side sampling (thus ignoring sample_rate) and enables distributed
// priority sampling, where traces are sampled based on a combination of user-assigned
// Default: true
DatadogPrioritySampling bool `json:"datadog-priority-sampling"`
// DatadogSampleRate specifies sample rate for any traces created.
// This is effective only when datadog-priority-sampling is false
// Default: 1.0
DatadogSampleRate float32 `json:"datadog-sample-rate"`
// MainSnippet adds custom configuration to the main section of the nginx configuration // MainSnippet adds custom configuration to the main section of the nginx configuration
MainSnippet string `json:"main-snippet"` MainSnippet string `json:"main-snippet"`
@ -767,6 +778,8 @@ func NewDefault() Configuration {
DatadogServiceName: "nginx", DatadogServiceName: "nginx",
DatadogCollectorPort: 8126, DatadogCollectorPort: 8126,
DatadogOperationNameOverride: "nginx.handle", DatadogOperationNameOverride: "nginx.handle",
DatadogSampleRate: 1.0,
DatadogPrioritySampling: true,
LimitReqStatusCode: 503, LimitReqStatusCode: 503,
LimitConnStatusCode: 503, LimitConnStatusCode: 503,
SyslogPort: 514, SyslogPort: 514,

View file

@ -1075,7 +1075,9 @@ const datadogTmpl = `{
"service": "{{ .DatadogServiceName }}", "service": "{{ .DatadogServiceName }}",
"agent_host": "{{ .DatadogCollectorHost }}", "agent_host": "{{ .DatadogCollectorHost }}",
"agent_port": {{ .DatadogCollectorPort }}, "agent_port": {{ .DatadogCollectorPort }},
"operation_name_override": "{{ .DatadogOperationNameOverride }}" "operation_name_override": "{{ .DatadogOperationNameOverride }}",
"sample_rate": {{ .DatadogSampleRate }},
"dd.priority.sampling": {{ .DatadogPrioritySampling }}
}` }`
func createOpentracingCfg(cfg ngx_config.Configuration) error { func createOpentracingCfg(cfg ngx_config.Configuration) error {