func()

in enrichments/trace/internal/elastic/span.go [282:334]


func (s *spanEnrichmentContext) enrichSpan(
	span ptrace.Span,
	cfg config.ElasticSpanConfig,
	transactionTypeEnabled bool,
	isExitRootSpan bool,
) {
	var spanType, spanSubtype string

	if cfg.TimestampUs.Enabled {
		span.Attributes().PutInt(elasticattr.TimestampUs, getTimestampUs(span.StartTimestamp()))
	}
	if cfg.Name.Enabled {
		span.Attributes().PutStr(elasticattr.SpanName, span.Name())
	}
	if cfg.RepresentativeCount.Enabled {
		repCount := getRepresentativeCount(span.TraceState().AsRaw())
		span.Attributes().PutDouble(elasticattr.SpanRepresentativeCount, repCount)
	}
	if cfg.TypeSubtype.Enabled {
		spanType, spanSubtype = s.setSpanTypeSubtype(span)
	}
	if cfg.EventOutcome.Enabled {
		s.setEventOutcome(span)
	}
	if cfg.DurationUs.Enabled {
		span.Attributes().PutInt(elasticattr.SpanDurationUs, getDurationUs(span))
	}
	if cfg.ServiceTarget.Enabled {
		s.setServiceTarget(span)
	}
	if cfg.DestinationService.Enabled {
		s.setDestinationService(span)
	}
	if cfg.InferredSpans.Enabled {
		s.setInferredSpans(span)
	}
	if cfg.ProcessorEvent.Enabled && !isExitRootSpan {
		span.Attributes().PutStr(elasticattr.ProcessorEvent, "span")
	}
	if cfg.UserAgent.Enabled {
		s.setUserAgentIfRequired(span)
	}

	if isExitRootSpan && transactionTypeEnabled && s.typeValue == "" {
		if spanType != "" {
			transactionType := spanType
			if spanSubtype != "" {
				transactionType += "." + spanSubtype
			}
			span.Attributes().PutStr(elasticattr.TransactionType, transactionType)
		}
	}
}