How to Log spanId in Google Kubernetes Engine

2/15/2019

I am trying to log traceId and spanId in log so that I can correlate trace and log in stackdriver.

I am creating a json logs as follows: { 'logging.googleapis.com/trace': traceId, 'spanId': spanId, 'message': 'Some message', }

Now traceid is getting pushed properly in EntryLog but spanId is getting pushed inside jsonPayload.

-- Arun
gcloud
google-kubernetes-engine
node.js
stackdriver

1 Answer

2/15/2019

It is advised that you set the LogEntry span_id with the key “logging.googleapis.com/span_id” Here, because it seems you setting for only trace that is the reason you only able to push TraceID inside jsonPayload. Here is a table on Special fields in structured payloads.

-- Adebisi
Source: StackOverflow