Datadog Opentracing support - part 2
This commit is part 2 of 2, adding configuration of the Datadog Opentracing module to the controller. Fixes half of #3752
This commit is contained in:
parent
b72dfa99d8
commit
a29c27ed4c
6 changed files with 59 additions and 3 deletions
|
|
@ -491,6 +491,21 @@ type Configuration struct {
|
|||
// Default: 1
|
||||
JaegerSamplerParam string `json:"jaeger-sampler-param"`
|
||||
|
||||
// DatadogCollectorHost specifies the datadog agent host to use when uploading traces
|
||||
DatadogCollectorHost string `json:"datadog-collector-host"`
|
||||
|
||||
// DatadogCollectorPort specifies the port to use when uploading traces
|
||||
// Default: 8126
|
||||
DatadogCollectorPort int `json:"datadog-collector-port"`
|
||||
|
||||
// DatadogServiceName specifies the service name to use for any traces created
|
||||
// Default: nginx
|
||||
DatadogServiceName string `json:"datadog-service-name"`
|
||||
|
||||
// DatadogOperationNameOverride overrides the operation naem to use for any traces crated
|
||||
// Default: nginx.handle
|
||||
DatadogOperationNameOverride string `json:"datadog-operation-name-override"`
|
||||
|
||||
// MainSnippet adds custom configuration to the main section of the nginx configuration
|
||||
MainSnippet string `json:"main-snippet"`
|
||||
|
||||
|
|
@ -685,6 +700,9 @@ func NewDefault() Configuration {
|
|||
JaegerServiceName: "nginx",
|
||||
JaegerSamplerType: "const",
|
||||
JaegerSamplerParam: "1",
|
||||
DatadogServiceName: "nginx",
|
||||
DatadogCollectorPort: 8126,
|
||||
DatadogOperationNameOverride: "nginx.handle",
|
||||
LimitReqStatusCode: 503,
|
||||
LimitConnStatusCode: 503,
|
||||
SyslogPort: 514,
|
||||
|
|
|
|||
|
|
@ -943,6 +943,13 @@ const jaegerTmpl = `{
|
|||
}
|
||||
}`
|
||||
|
||||
const datadogTmpl = `{
|
||||
"service": "{{ .DatadogServiceName }}",
|
||||
"agent_host": "{{ .DatadogCollectorHost }}",
|
||||
"agent_port": {{ .DatadogCollectorPort }},
|
||||
"operation_name_override": "{{ .DatadogOperationNameOverride }}"
|
||||
}`
|
||||
|
||||
func createOpentracingCfg(cfg ngx_config.Configuration) error {
|
||||
var tmpl *template.Template
|
||||
var err error
|
||||
|
|
@ -957,6 +964,11 @@ func createOpentracingCfg(cfg ngx_config.Configuration) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else if cfg.DatadogCollectorHost != "" {
|
||||
tmpl, err = template.New("datadog").Parse(datadogTmpl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
tmpl, _ = template.New("empty").Parse("{}")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -836,6 +836,8 @@ func buildOpentracing(input interface{}) string {
|
|||
buf.WriteString("opentracing_load_tracer /usr/local/lib/libzipkin_opentracing.so /etc/nginx/opentracing.json;")
|
||||
} else if cfg.JaegerCollectorHost != "" {
|
||||
buf.WriteString("opentracing_load_tracer /usr/local/lib/libjaegertracing_plugin.so /etc/nginx/opentracing.json;")
|
||||
} else if cfg.DatadogCollectorHost != "" {
|
||||
buf.WriteString("opentracing_load_tracer /usr/local/lib/libdd_opentracing.so /etc/nginx/opentracing.json;")
|
||||
}
|
||||
|
||||
buf.WriteString("\r\n")
|
||||
|
|
|
|||
|
|
@ -1002,6 +1002,17 @@ func TestBuildOpenTracing(t *testing.T) {
|
|||
t.Errorf("Expected '%v' but returned '%v'", expected, actual)
|
||||
}
|
||||
|
||||
cfgDatadog := config.Configuration{
|
||||
EnableOpentracing: true,
|
||||
DatadogCollectorHost: "datadog-host.com",
|
||||
}
|
||||
expected = "opentracing_load_tracer /usr/local/lib/libdd_opentracing.so /etc/nginx/opentracing.json;\r\n"
|
||||
actual = buildOpentracing(cfgDatadog)
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("Expected '%v' but returned '%v'", expected, actual)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestEnforceRegexModifier(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue