config: use *float32 with nil instead of float32 with sentinel value
This commit is contained in:
parent
059f6262fe
commit
fb1dcff2f3
2 changed files with 5 additions and 11 deletions
|
@ -87,11 +87,6 @@ const (
|
|||
// Parameters for a shared memory zone that will keep states for various keys.
|
||||
// http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html#limit_conn_zone
|
||||
defaultLimitConnZoneVariable = "$binary_remote_addr"
|
||||
|
||||
// Default sentinel value for Configuration.DatadogSampleRate, indicating
|
||||
// that the Datadog tracer should consult the Datadog Agent for sampling
|
||||
// rates rather than use a configured value.
|
||||
DatadogDynamicSampleRate = -1.0
|
||||
)
|
||||
|
||||
// Configuration represents the content of nginx.conf file
|
||||
|
@ -713,7 +708,7 @@ type Configuration struct {
|
|||
|
||||
// DatadogSampleRate specifies sample rate for any traces created.
|
||||
// Default: use a dynamic rate instead
|
||||
DatadogSampleRate float32 `json:"datadog-sample-rate"`
|
||||
DatadogSampleRate *float32 `json:"datadog-sample-rate",omitempty`
|
||||
|
||||
// MainSnippet adds custom configuration to the main section of the nginx configuration
|
||||
MainSnippet string `json:"main-snippet"`
|
||||
|
@ -999,7 +994,7 @@ func NewDefault() Configuration {
|
|||
DatadogEnvironment: "prod",
|
||||
DatadogCollectorPort: 8126,
|
||||
DatadogOperationNameOverride: "nginx.handle",
|
||||
DatadogSampleRate: DatadogDynamicSampleRate,
|
||||
DatadogSampleRate: nil,
|
||||
LimitReqStatusCode: 503,
|
||||
LimitConnStatusCode: 503,
|
||||
SyslogPort: 514,
|
||||
|
|
|
@ -1083,12 +1083,11 @@ func datadogOpentracingCfg(cfg ngx_config.Configuration) (string, error) {
|
|||
"operation_name_override": cfg.DatadogOperationNameOverride,
|
||||
}
|
||||
|
||||
// Omit "sample_rate" if the configuration's sample rate is set to the
|
||||
// default sentinel value DatadogDynamicSampleRate (-1).
|
||||
// Omit "sample_rate" if the configuration's sample rate is unset (nil).
|
||||
// Omitting "sample_rate" from the plugin JSON indicates to the tracer that
|
||||
// it should use dynamic rates instead of a configured rate.
|
||||
if cfg.DatadogSampleRate != ngx_config.DatadogDynamicSampleRate {
|
||||
jsn["sample_rate"] = cfg.DatadogSampleRate
|
||||
if cfg.DatadogSampleRate != nil {
|
||||
jsn["sample_rate"] = *cfg.DatadogSampleRate
|
||||
}
|
||||
|
||||
jsnBytes, err := json.Marshal(jsn)
|
||||
|
|
Loading…
Reference in a new issue