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

MDC mechanism #31

Open
feyman2016 opened this issue Dec 21, 2017 · 2 comments
Open

MDC mechanism #31

feyman2016 opened this issue Dec 21, 2017 · 2 comments

Comments

@feyman2016
Copy link

Is there a MDC machenism in this client?
For example,Spring Cloud Sleuth outputs logs like this:
If we outputting logs (probably using MDC) with the trace-id and span-id and parsing those when inserting into elasticsearch, it’s pretty easy to search elasticsearch for a given trace ID, and the Zipkin UI already has an integration that I can setup a link to your kibana with the search for the trace ID from the trace view

@basvanbeek
Copy link
Member

Closest thing to MDC in Go would be a combination of structured logging for which I'd recommend Go kit's Logger package: https://github.com/go-kit/kit/tree/master/log and then using the Go standard library context package context. Go has no thread local storage so you'd be passing a context object holding your logger (holding upstream contextual key/pairs) to each function you call (Go idiom: first parameter should be context)

Zipkin-go allows you to place spans in and pull spans from context using zipkin.NewContext() and zipkin.SpanFromContext() so standard library context becomes your vehicle for propagating spans and loggers through your application.

If you've pulled a span from go context you can retrieve the trace identifiers using span.Context() which holds SpanContext (span identifiers and flags).

I think it's worth an example / blog post.

@basvanbeek basvanbeek changed the title MDC machenism MDC mechanism Dec 23, 2017
@jcchavezs
Copy link
Contributor

Hi @feyman2016, not sure what library for mdc in go you use but I have been working and using this library which supports a feature called providers that allows user to plug functions like this one that injects the traceID and spanID in the logs.

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

No branches or pull requests

3 participants