gcp-structured-logger
Advanced tools
Comparing version
@@ -23,2 +23,8 @@ /// <reference types="express-serve-static-core" /> | ||
} | ||
export interface TraceContext { | ||
/** Format `projects/<PROJECT-ID>/traces/<TRACE-ID>`. */ | ||
trace: string; | ||
spanId: string; | ||
traceSampled: boolean; | ||
} | ||
/** @see https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry */ | ||
@@ -25,0 +31,0 @@ export interface LogEntry { |
{ | ||
"name": "gcp-structured-logger", | ||
"version": "1.4.8", | ||
"version": "1.4.9", | ||
"description": "Structured logger for GCP logging", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -486,3 +486,3 @@ const { format, formatWithOptions, inspect } = require('util') | ||
/** @readonly @private */ | ||
this._trace = extractTraceContext(projectId, request) | ||
this._trace = extractTraceContext(projectId, request) ?? {} | ||
} | ||
@@ -489,0 +489,0 @@ |
@@ -15,6 +15,5 @@ const { getHeader } = require('./request-properties') | ||
/** | ||
* @typedef {{ trace: string, spanId: string, traceSampled: boolean }} TraceContext | ||
* @param {string} projectId | ||
* @param {import('./StructuredLogger').Request} req | ||
* @returns {{} | TraceContext} | ||
* @returns {import('../').TraceContext | undefined} | ||
*/ | ||
@@ -45,3 +44,3 @@ function extractTraceContext(projectId, req) { | ||
// Can ignore - invalid values | ||
return {} | ||
return | ||
} | ||
@@ -48,0 +47,0 @@ return { trace: `projects/${projectId}/traces/${traceId}`, spanId: spanId.toString(16).padStart(16, '0'), traceSampled: Boolean(flagsValue & TRACE_PARENT_FLAGS.sampled) } |
42825
0.23%976
0.51%