Propagation fails because trace ID value does not observe Cloud Logging format. #335
Labels
Content-Length: 231428 | pFad | http://github.com/GoogleCloudPlatform/opentelemetry-operations-python/issues/335
62Fetched URL: http://github.com/GoogleCloudPlatform/opentelemetry-operations-python/issues/335
Alternative Proxies:
The formatter in this sample correctly renames the OpenTelemetry field names to their GCP counterparts, however this does not address the format difference in the trace ID value. Cloud Logging is expecting
projects/{project-id}/traces/{trace-id}
, but we are only providing the raw trace ID here.We can propagate existing Cloud Logging trace ID's by including something like this:
This will attach the propagated trace ID to our logging calls correctly, however with the JsonFormatter in this sample alone the logs would not correlate properly in GCP Logs Explorer or Trace Explorer since the
projects/{project-id}/traces/
prefix is still missing from the trace ID value. We can use thelog_hook
argument on LoggingInstrumentor to modify the field value like this:(Let's pretend we queried
metadata.google.internal
or something and already setPROJECT_ID
somewhere for the sake of this example.) With this, theotelTraceID
value will first be changed to the correct format by theLoggingInstrumentor
hook, then the field is renamed tologging.googleapis.com/trace
by theJsonFormatter
in the sample, and now traces will correlate properly in Logs Explorer/Trace Explorer! Hope this helps.The text was updated successfully, but these errors were encountered: