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

Move logger context population so it can be reused by YARPC #155

Merged
merged 2 commits into from Jan 10, 2017
Merged

Conversation

madhuravi
Copy link
Contributor

No description provided.

@madhuravi
Copy link
Contributor Author

@sectioneight

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 92.041% when pulling fc780e1 on trace into 10317c9 on master.

@madhuravi madhuravi changed the title Moved logger context population so it can be reused by YARPC Move logger context population so it can be reused by YARPC Jan 10, 2017
@@ -23,6 +23,9 @@ package fxcontext
import (
gcontext "context"

"github.com/opentracing/opentracing-go"
"github.com/uber/jaeger-client-go"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these go below fx imports

// Note that opentracing.Tracer does not expose the tracer id
// We only inject tracing information for jaeger.Tracer
if jSpanCtx, ok := span.Context().(jaeger.SpanContext); ok {
traceLogger := c.Logger().With(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use the non-sugared version here for perf in the tight loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ulog.Logger With has some sentry magic. It adds the fields to sentry as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we should fix that. People should be able to add zap Fields directly and still get the same Sentry benefits. Particularly in a path like this (on the per-request loop) where we know the fields ahead of time, we really shouldn't be incurring the overhead of the interface{} conversion since we know it's expensive.

In other words, this should be something like:

traceLogger := c.Logger().Typed().With(
  zap.StringField("traceID", traceID),
  zap.StringField("spanID", spanID),
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GFM-278

@ascandella
Copy link
Contributor

Let's also add some documentation to read me/godoc about this behavior so people don't have to dig through code to discover it

@madhuravi
Copy link
Contributor Author

@sectioneight Do you mean documentation to uhttp or context? Use for WithContextAwareLogger is only within UberFx. And for http, users will not have to set anything. It should just work. Do we want to just say that this is a thing we have with the http module and you can expect to see it in the logs?

@ascandella
Copy link
Contributor

@madhuravi I meant that although it does "just work", we should document somewhere that we're auto-inserting trace/span IDs into the logs and the format they're in, where they come from, and why you might want to use them.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 92.041% when pulling fca5908 on trace into 10317c9 on master.

@madhuravi madhuravi merged commit 302d324 into master Jan 10, 2017
@madhuravi madhuravi deleted the trace branch January 10, 2017 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants