Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log span name when logging received spans in distributors #1788

Closed
suraciii opened this issue Oct 9, 2022 · 2 comments · Fixed by #1790
Closed

Log span name when logging received spans in distributors #1788

suraciii opened this issue Oct 9, 2022 · 2 comments · Fixed by #1790

Comments

@suraciii
Copy link
Contributor

suraciii commented Oct 9, 2022

Is your feature request related to a problem? Please describe.

Currently distributor does not write span names into logs when logging spans by enabling log_received_spans, even with include_all_attributes on.

Describe the solution you'd like

Add span name into log context when logging span with all attributes.

For example:

// modules/distributor/distributor.go:581
func logSpanWithAllAttributes(s *v1.Span, logger log.Logger) {
	for _, a := range s.GetAttributes() {
		logger = log.With(
			logger,
			"span_"+strutil.SanitizeLabelName(a.GetKey()),
			tempo_util.StringifyAnyValue(a.GetValue()))
	}

	latencySeconds := float64(s.GetEndTimeUnixNano()-s.GetStartTimeUnixNano()) / float64(time.Second.Nanoseconds())
	logger = log.With(
		logger,
+        	"span_name", s.Name,
		"span_duration_seconds", latencySeconds,
		"span_kind", s.GetKind().String(),
		"span_status", s.GetStatus().GetCode().String())

	level.Info(logger).Log("msg", "received", "spanid", hex.EncodeToString(s.SpanId), "traceid", hex.EncodeToString(s.TraceId))
}

Additional context
We're using span logs with Loki as a workaround for search traces, so span names in logs could improve the search efficiency.

@joe-elliott
Copy link
Member

+1 to this addition. please submit a PR if you can.

if you are unable to i can do it.

@suraciii
Copy link
Contributor Author

@joe-elliott PR opened :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants