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

execution_id missing in PubSub cloud function #465

Closed
techieshark opened this issue Feb 26, 2020 · 4 comments
Closed

execution_id missing in PubSub cloud function #465

techieshark opened this issue Feb 26, 2020 · 4 comments
Assignees
Labels
api: logging Issues related to the googleapis/nodejs-logging-winston API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: question Request for information or clarification. Not an issue.

Comments

@techieshark
Copy link
Contributor

techieshark commented Feb 26, 2020

Is there something this library, or the users of it, could do to get a pubsub event id to be included in the one-line summary seen in Stackdriver? As described below, I've tried to set it manually as a label, but that seems to not impact the summary line.

Environment details

  • OS: cloud-functions
  • Node.js version: 10
  • @google-cloud/logging-winston version: 3.0.5

Steps to reproduce

  1. Create pubsub cloud function which takes a context as second parameter.
  2. Log with winston to stackdriver transport (as per the docs), and try manually setting labels["execution_id"] to the event id:
 logger.debug('Starting processing pubsub message', {
    labels: {
      // Observe console.log entries to see that an event ID is the execution_id.
      // We manually populate it so we can see the group of all logs for a
      // single execution/event.
      execution_id: context.eventId,
    }
}

image

Expected: the one line (non-expanded) summary includes the execution id / event id. This is the case with console.log.

Actual: non is present. See screenshot.

@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/nodejs-logging-winston API. label Feb 26, 2020
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Feb 26, 2020
@DominicKramer DominicKramer added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed triage me I really want to be triaged. labels Feb 28, 2020
@dfdgsdfg
Copy link

@techieshark
Copy link
Contributor Author

Solution might be using firebase-functions logger instead (for cloud functions):

firebase/firebase-functions#560 (comment)

https://github.com/firebase/firebase-functions/releases/tag/v3.7.0

Adds functions.logger SDK to enable structured logging in the Node.js 10 runtime. For example:

const functions = require('firebase-functions');

functions.logger.debug('example log with structured data', {
uid: user.uid,
authorized: true,
});

Internally this just is like

console.log(`your-message-line and then ${JSON.stringify(structuredInfo)}`);

which is supposed to work on Node >= 10

I'll try this soon.

@keenan-devrel keenan-devrel added priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue. and removed type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Nov 19, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Nov 19, 2020
@0xSage
Copy link
Contributor

0xSage commented Dec 7, 2020

Hi @techieshark , a few notes that may help:

  1. Getting exec_id to show up as a Summary Field (the UI bubbles): You can manually configure summary fields yourself steps here.

  2. Getting execution_id by default: this is blocked by this upstream issue. Will follow up on it for you. After that’s in, we can work on getting everyone trace/exec ids by default, minimally for pubsub/scheduler triggered cloud functions. tracked here.

  3. Event_id is a different value than execution_id. You might run into issues by using it interchangeably as a single event_id can yield multiple execution_ids. This happens for example when your event retries the execution due to some issue.

Closing the issue here since the fix is in different repos and already tracked and tagged to this issue instance.

@0xSage 0xSage closed this as completed Dec 7, 2020
@techieshark
Copy link
Contributor Author

Thanks for the tips, @nicoleczhu! Looking forward to seeing those upstream issues resolved - would be quite helpful for our logging ux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/nodejs-logging-winston API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

6 participants