Add trace ID to log metadata when available#2574
Add trace ID to log metadata when available#2574stephenplusplus merged 2 commits intogoogleapis:masterfrom draffensperger:trace-ids-in-logs
Conversation
|
@matthewloring and @ofrobots could you take a look at this when you get a chance? The |
matthewloring
left a comment
There was a problem hiding this comment.
The use of the trace agent looks good. Duplicating the qualified trace ID logic in winston and bunyan separately does seem clunky but if the update -> release -> bump dependency flow is too cumbersome then this is fine.
| ); | ||
| } | ||
|
|
||
| record = extend({}, record); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * Key to use in the Bunyan payload to allow users to indicate a trace for the | ||
| * request, and to store as an intermediate value on the log entry before it | ||
| * gets written to the Stackdriver logging API. | ||
| */ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * Gets the current fully qualified trace ID when available from the | ||
| * @google-cloud/trace-agent library in the LogEntry.trace field format of: | ||
| * "projects/[PROJECT-ID]/traces/[TRACE-ID]". | ||
| */ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Sgtm
…On Fri, Sep 8, 2017 at 6:07 AM Dave Raffensperger ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In packages/logging-winston/src/index.js
<#2574 (comment)>
:
> @@ -126,6 +131,30 @@ winston.transports.StackdriverLogging = LoggingWinston;
util.inherits(LoggingWinston, winston.Transport);
/**
+ * Gets the current fully qualified trace ID when available from the
+ * @google-cloud/trace-agent library in the LogEntry.trace field format of:
+ * "projects/[PROJECT-ID]/traces/[TRACE-ID]".
+ */
+function getCurrentTraceFromAgent() {
@ofrobots <https://github.com/ofrobots>, are you OK with keeping the
getCurrentTraceFromAgent duplicated in both logging-winston and
logging-bunyan for now?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2574 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAE0qf0N9VVd0Th_l1CQt2XbjkbCIyt3ks5sgTwggaJpZM4PH1nM>
.
|
ofrobots
left a comment
There was a problem hiding this comment.
LGTM. Thanks for being patient on this!
|
@stephenplusplus Is this good to land from your POV? |
This makes the
logging-bunyanandlogging-winstonlibraries add theLogEntry.tracefield based on the current trace context of the@google-cloud/trace-agentlibrary when available.Users can override that default
LogEntry.traceassignment by specifying alogging.googleapis.com/tracefield in the Winston entry metadata or Bunyan structured log entry. That naming makes logging backward-compatible for anyone who might happen to already use atracefield in their logs and it the follows the similar behavior for the Stackdriver logging agent, see https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud/blob/91835bb12b728ba88f63c38008e539a047d216a6/lib/fluent/plugin/out_google_cloud.rb#L105.This will make use of the
getWriterProjectIdfunction that googleapis/cloud-trace-nodejs#548 adds tocloud-trace-nodejs.