Use hexadecimal ids and lowercase names in zipkin input (#3488)

This commit is contained in:
Chris Goller
2017-11-20 16:19:32 -06:00
committed by Daniel Nelson
parent f9b808572f
commit 113184ddae
8 changed files with 120 additions and 110 deletions

View File

@@ -1,6 +1,8 @@
package zipkin
import (
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs/zipkin/trace"
)
@@ -28,12 +30,13 @@ func (l *LineProtocolConverter) Record(t trace.Trace) error {
fields := map[string]interface{}{
"duration_ns": s.Duration.Nanoseconds(),
}
tags := map[string]string{
"id": s.ID,
"parent_id": s.ParentID,
"trace_id": s.TraceID,
"name": s.Name,
"service_name": s.ServiceName,
"name": formatName(s.Name),
"service_name": formatName(s.ServiceName),
}
l.acc.AddFields("zipkin", fields, tags, s.Timestamp)
@@ -42,8 +45,8 @@ func (l *LineProtocolConverter) Record(t trace.Trace) error {
"id": s.ID,
"parent_id": s.ParentID,
"trace_id": s.TraceID,
"name": s.Name,
"service_name": a.ServiceName,
"name": formatName(s.Name),
"service_name": formatName(a.ServiceName),
"annotation": a.Value,
"endpoint_host": a.Host,
}
@@ -55,8 +58,8 @@ func (l *LineProtocolConverter) Record(t trace.Trace) error {
"id": s.ID,
"parent_id": s.ParentID,
"trace_id": s.TraceID,
"name": s.Name,
"service_name": b.ServiceName,
"name": formatName(s.Name),
"service_name": formatName(b.ServiceName),
"annotation": b.Value,
"endpoint_host": b.Host,
"annotation_key": b.Key,
@@ -71,3 +74,10 @@ func (l *LineProtocolConverter) Record(t trace.Trace) error {
func (l *LineProtocolConverter) Error(err error) {
l.acc.AddError(err)
}
// formatName formats name and service name
// Zipkin forces span and service names to be lowercase:
// https://github.com/openzipkin/zipkin/pull/805
func formatName(name string) string {
return strings.ToLower(name)
}