Closed dschnare closed 9 months ago
Hi @dschnare, Thank you for reporting the issue. I was able to repro the issue and I have sent out PRs to address the two concerns mentioned above:
LoggingWinston.LOGGING_SAMPLED_KEY
expecting boolean value: https://github.com/googleapis/nodejs-logging-winston/pull/830
Environment details
@google-cloud/logging-winston
version: 5.3.0Steps to reproduce
Create a simple logger
Use logger in a simple express app.
app.get('/hello', (req, res) => { logger.info('hello called', { stuff: 'yep' }) res.status(200).json({ message: 'hello' }) })
The code that expects
timestamp
to be a Date is withinLoggingCommon
:An additional issue is that the key
LoggingWinston.LOGGING_SAMPLED_KEY
should be expected to be a boolean, but theLoggingCommon
class expects it to be a string like"1"
. In OpenTelemetry this is stored in the traceFlags of the span context as a number, not a string. And typically we can convert to boolean viaspan.spanContext().traceFlags === OpenTelemetry.TraceFlags.SAMPLED
. It's really odd to have this documented as needing to be a boolean but in the code it expects a string.As a remedy I had to set this key to
String(span.spanContext().traceFlags)
.