MCPcopy
hub / github.com/grafana/tempo / logSpan

Function logSpan

modules/distributor/distributor.go:893–912  ·  view source on GitHub ↗
(s *v1.Span, allAttributes bool, logger log.Logger)

Source from the content-addressed store, hash-verified

891}
892
893func logSpan(s *v1.Span, allAttributes bool, logger log.Logger) {
894 if allAttributes {
895 for _, a := range s.GetAttributes() {
896 logger = log.With(
897 logger,
898 "span_"+strutil.SanitizeLabelName(a.GetKey()),
899 util.StringifyAnyValue(a.GetValue()))
900 }
901
902 latencySeconds := float64(s.GetEndTimeUnixNano()-s.GetStartTimeUnixNano()) / float64(time.Second.Nanoseconds())
903 logger = log.With(
904 logger,
905 "span_name", s.Name,
906 "span_duration_seconds", latencySeconds,
907 "span_kind", s.GetKind().String(),
908 "span_status", s.GetStatus().GetCode().String())
909 }
910
911 level.Info(logger).Log("spanid", hex.EncodeToString(s.SpanId), "traceid", hex.EncodeToString(s.TraceId))
912}
913
914// startEndFromSpan returns a unix epoch timestamp in seconds for the start and end of a span
915func startEndFromSpan(span *v1.Span) (uint32, uint32) {

Callers 1

logSpansFunction · 0.85

Calls 12

StringifyAnyValueFunction · 0.92
GetKeyMethod · 0.80
GetEndTimeUnixNanoMethod · 0.80
GetKindMethod · 0.80
GetCodeMethod · 0.80
EncodeToStringMethod · 0.80
LogMethod · 0.65
GetAttributesMethod · 0.45
GetValueMethod · 0.45
GetStartTimeUnixNanoMethod · 0.45
StringMethod · 0.45
GetStatusMethod · 0.45

Tested by

no test coverage detected