// AddTagsToTracePayloads takes a single string of tags, eg 'a:b,c:d', and applies them
// to each span in a trace
AddTagsToTracePayloads takes a single string of tags, eg 'a:b,c:d', and applies them
to each span in a trace
// AddTagsToTracePayloads takes a single string of tags eg ' a : b c : d ' and applies them // to each span in a trace
func AddTagsToTracePayloads(tracePayloads []*pb.TracePayload, tags string) {
	tagMap := map[string]string{}
	tl := strings.Split(tags, ",")
	service := ""
	env := ""
	for _, tag := range tl {
		values := strings.SplitN(tag, ":", 2)
		if len(values) < 2 {
			continue
		}
		tag := values[0]
		value := values[1]
		if strings.ToLower(tag) == "service" {
			service = value
		} else if strings.ToLower(tag) == "env" {
			env = value
		} else {
			tagMap[tag] = value
		}
	}
	serviceLookup := map[string]string{}
	if service != "" {
		serviceLookup = buildServiceLookup(tracePayloads, service)
	}
	for _, tracePayload := range tracePayloads {
		if env != "" {
			tracePayload.Env = env
		}
		for _, trace := range tracePayload.Traces {
			for _, span := range trace.Spans {
				if value, ok := span.Meta["inferred_span.inherit_lambda"]; ok && value == "False" {
					continue
				}
				if serviceLookup[span.Service] != "" {
					span.Service = serviceLookup[span.Service]
				}
				for tag, value := range tagMap {
					span.Meta[tag] = value
				}
				if serviceLookup[span.Service] != "" && span.Meta["service"] != "" {
					span.Meta["service"] = serviceLookup[span.Service]
				}
			}
		}
	}
}
func AddTagsToTracePayloads ( tracePayloads [ ] * pb . TracePayload , tags string ) { tagMap := map [ string ] string { } tl := strings . Split ( tags , " " ) service := " " env := " " for _ , tag := range tl { values := strings . SplitN ( tag , " " , 2 ) if len ( values ) < 2 { continue } tag := values [ 0 ] value := values [ 1 ] if strings . ToLower ( tag ) == " " { service = value } else if strings . ToLower ( tag ) == " " { env = value } else { tagMap [ tag ] = value } } serviceLookup := map [ string ] string { } if service != " " { serviceLookup = buildServiceLookup ( tracePayloads , service ) } for _ , tracePayload := range tracePayloads { if env != " " { tracePayload . Env = env } for _ , trace := range tracePayload . Traces { for _ , span := range trace . Spans { if value , ok := span . Meta [ " " ] ; ok && value == " " { continue } if serviceLookup [ span . Service ] != " " { span . Service = serviceLookup [ span . Service ] } for tag , value := range tagMap { span . Meta [ tag ] = value } if serviceLookup [ span . Service ] != " " && span . Meta [ " " ] != " " { span . Meta [ " " ] = serviceLookup [ span . Service ] } } } } }
AddTagsToTracePayloads takes a single string of tags, eg 'a:b,c:d', and applies them
to each span in a trace
AddTagsToTracePayloads takes a single string of tags eg ' a : b c : d ' and applies them to each span in a trace
// do not add tags from Lambda function if it's an inferred span and // it does not belong to the AWS Lambda service