-
Notifications
You must be signed in to change notification settings - Fork 604
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
Add trace ID to log metadata when available #2574
Add trace ID to log metadata when available #2574
Conversation
db4035f
to
1b374f6
Compare
cc052c7
to
67ce8c3
Compare
67ce8c3
to
254349f
Compare
254349f
to
0de66c1
Compare
@matthewloring and @ofrobots could you take a look at this when you get a chance? The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -133,8 +140,6 @@ LoggingBunyan.prototype.formatEntry_ = function(record) { | |||
); | |||
} | |||
|
|||
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.
* request, and to store as an intermediate value on the log entry before it | ||
* gets written to the Stackdriver logging API. | ||
*/ | ||
var LOGGING_TRACE_KEY = 'logging.googleapis.com/trace'; |
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.
* @google-cloud/trace-agent library in the LogEntry.trace field format of: | ||
* "projects/[PROJECT-ID]/traces/[TRACE-ID]". | ||
*/ | ||
function getCurrentTraceFromAgent() { |
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>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for being patient on this!
@stephenplusplus Is this good to land from your POV? |
This makes the
logging-bunyan
andlogging-winston
libraries add theLogEntry.trace
field based on the current trace context of the@google-cloud/trace-agent
library when available.Users can override that default
LogEntry.trace
assignment by specifying alogging.googleapis.com/trace
field in the Winston entry metadata or Bunyan structured log entry. That naming makes logging backward-compatible for anyone who might happen to already use atrace
field 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
getWriterProjectId
function that googleapis/cloud-trace-nodejs#548 adds tocloud-trace-nodejs
.