-
Notifications
You must be signed in to change notification settings - Fork 130
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
What are you really trying to do?
Get OpenTelemetry trace_id
and span_id
fields on Workflow logs.
Describe the bug
The tracing fields from OpenTelemetry (trace_id
and span_id
) is not appearing on Workflow logs specifically.
It works on Client and Activities.
Calling worflow.log.error
:
{"label":"workflow","level":"error","message":"hello","namespace":"default","runId":"add5d842-ca36-4fee-8e51-624d7b2bb58c","sdkComponent":"workflow","taskQueue":"interceptors-opentelemetry-example","timestamp":1716328238734,"workflowId":"otel-example-0","workflowType":"example"}
Calling activity.log.error
{"activityId":"1","activityType":"greet","attempt":1,"isLocal":false,"label":"activity","level":"error","message":"alskjdbnkajsdbnkjandsjk","namespace":"default","sdkComponent":"activity","span_id":"10036d093b04a315","taskQueue":"interceptors-opentelemetry-example","taskToken":"CiRjYmI4ODI1My0wOWMyLTRiMzMtOWI3YS05MTQ5ODFhMzdjM2USDm90ZWwtZXhhbXBsZS0wGiRhZGQ1ZDg0Mi1jYTM2LTRmZWUtOGU1MS02MjRkN2IyYmI1OGMgBSgBMgExQgVncmVldEoICAEQxo5AGAE=","timestamp":1716328238737,"trace_flags":"01","trace_id":"f2731bb716c062624923e55b29f8fcec","workflowId":"otel-example-0","workflowRunId":"add5d842-ca36-4fee-8e51-624d7b2bb58c","workflowType":"example"}
Which gives "span_id":"10036d093b04a315"
and "trace_id":"f2731bb716c062624923e55b29f8fcec"
.
Minimal Reproduction
- From
interceptors-opentelemetry
sample: https://github.com/temporalio/samples-typescript/tree/main/interceptors-opentelemetry - Enable OpenTelemetry Auto Instrumentation for JS for
winston
(https://opentelemetry.io/docs/languages/js/automatic/)
export OTEL_NODE_RESOURCE_DETECTORS="env,host,os,serviceinstance"
export OTEL_SERVICE_NAME="client"
export NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"
export OTEL_NODE_ENABLED_INSTRUMENTATIONS="winston,http"
- Enable
custom-logger
using https://github.com/temporalio/samples-typescript/tree/main/custom-logger - Log on Workflow
import * as workflow from "@temporalio/workflow"
// A workflow that simply calls an activity
export async function example(name: string): Promise<string> {
workflow.log.error("hello");
return await greet(name);
}
- Log on Activity
import * as activity from "@temporalio/activity"
export async function greet(name: string): Promise<string> {
activity.log.error("alskjdbnkajsdbnkjandsjk")
return `Hello, ${name}!`;
}
- Call client to execute workflow (
npm run workflow
)
Environment/Versions
- OS and processor: M2 Mac
- Temporal Version:
❯ temporal --version
temporal version 0.12.0 (server 1.23.0) (ui 2.26.2)
- Are you using Docker or Kubernetes or building Temporal from source? No
Additional context
- The trace_id and span_id are generated but they doesn't appear on logs and are being reported to newrelic correctly, because they appear on distributed tracing.
From ConsoleSpanExporter
{
resource: { attributes: { 'service.name': 'interceptors-sample-worker' } },
traceId: 'd498bbf00762a58fc78c022804644789', <<<<<<<<<<
parentId: '38b7d260146c73e6', <<<<<<<<
traceState: undefined,
name: 'RunWorkflow:example',
id: 'aaa81665fd7d1198',
kind: 0,
timestamp: 1716328235467000,
duration: 46000,
attributes: {
...
{
resource: { attributes: { 'service.name': 'interceptors-sample-worker' } },
traceId: 'd498bbf00762a58fc78c022804644789',
parentId: 'aaa81665fd7d1198',
traceState: undefined,
name: 'StartActivity:greet',
id: 'aec76af986522d29',
kind: 0,
- I think is a problem with
winston
+opentelemetry
on workflow context only, because it only occurs on Workflows... everywhere else is working. - I put the code here https://github.com/lucaskatayama/temporal-otel
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request