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

Automatic integration with OpenTelemetry #786

Open
domdomegg opened this issue Mar 2, 2023 · 2 comments
Open

Automatic integration with OpenTelemetry #786

domdomegg opened this issue Mar 2, 2023 · 2 comments
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. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@domdomegg
Copy link

Is your feature request related to a problem? Please describe.

When setting up my tracing and logging following the Google Cloud documentation in the recommended way for Node.js, they don't appear to integrate with each other.

The docs recommend using OpenTelemetry for traces, and this seems to be a nice standards-based way to collect trace data:

Describe the solution you'd like

The logging library works out of the box with OpenTelemetry, set up in the way recommended by the Google Cloud documentation.

There's straightforward docs which guide the user on how to set up logging and tracing, such that logs go to Google Cloud Logging and traces go to Google Cloud Trace and they integrate with each other.

Additional context

OpenTelemetry was previously mentioned in #597, but I couldn't quite follow what that was requesting. The docs from the PR suggest one might have to override certain properties to get tracing working - this should work out of the box.

@domdomegg domdomegg added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Mar 2, 2023
@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/nodejs-logging-winston API. label Mar 2, 2023
@losalex losalex assigned losalex and unassigned daniel-sanche Mar 7, 2023
@losalex losalex added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p3 Desirable enhancement or fix. May not be included in next release. labels Jun 22, 2023
@losalex losalex removed their assignment Jul 3, 2023
@dschnare
Copy link

Yeah I found this too. I had to use the special keys on the info object.

image

I have also found that I have a big problem with timestamps of the log entry not being within the span. I have a transporter that writes to the console and another transporter that integrates with Cloud Logging. The console reports timestamps of each log entry such that each log occurs within the span. However, in Cloud Logging the timestamps are inflated by around 200ms so they are pushed outside the span, so when you click the "View Logs" link from Cloud Trace, no log entries are ever found, and no dots are shown on the span bar in the timeline. It's so frustrating. I can "remedy" the situation by adding an artificial delay just before responding to the HTTP request by say 500ms.

@Apokalypt
Copy link

Apokalypt commented Feb 22, 2024

@dschnare Did you find any solutions ? I'm facing the same issue regarding the delay visible in the timestamps

EDIT: I just found a solution when looking on the code of nodejs-logging-winston. To be sure that the timestamp is "valid" you need to provide it in the metadata (make sure it's an instance of Date)

    const date = new Date();
    logger.info(`test log - ${date.toISOString()}`, {
        [LoggingWinston.LOGGING_TRACE_KEY]: `projects/${'mod-glitch-dev'}/traces/${span.spanContext().traceId}`,
        [LoggingWinston.LOGGING_SPAN_KEY]: span.spanContext().spanId,
        timestamp: date
    });

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. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

5 participants