Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

getCurrentContextId() returns null when not sampling #1025

@naartjie

Description

@naartjie

I am trying to use LogEntry.trace as a correlation identifier to tie different log messages together. I wasn't sure if this would be a good idea, but I got some confirmation from here:

A non-sampled trace value is still useful as a request correlation identifier.

Being able to click on "Show matching entries" in the log view seems like a really useful thing to have:

Screenshot 2019-05-13 at 20 33 18

The Bunyan logging wrapper uses the agent.getCurrentContextId(). The problem is that getCurrentContextId() only seems to return a value if the current request is being sampled, and null otherwise.

Is this intended? Would it be possible to still return a traceId from getCurrentContextId() or perhaps expose another function to do this, for the sake of logging the trace id, to be able to correlate log entries.

Metadata

Metadata

Assignees

Labels

api: cloudtraceIssues related to the googleapis/cloud-trace-nodejs API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions