Skip to content

Propagate OpenTelemetry context to Go SDK tasks #70165

Description

@viiccwen

Description

Go SDK tasks executed through the bundle gRPC path do not receive the task instance's OpenTelemetry context carrier. This breaks trace continuity at the Go task boundary, even though the bundle protobuf schema already provides an otel_context field.

Use case/motivation

Teams instrumenting Go SDK tasks and their downstream API calls need those spans to continue the trace created for the Airflow task instance. Without the remote parent context, Go task spans begin unrelated traces, making an end-to-end task execution difficult to observe and diagnose.

The expected behaviour is that the bundle gRPC client forwards string-valued carrier entries, the bundle server reconstructs the carrier, and the Go task extracts the W3C Trace Context into its context.Context. Task instrumentation and downstream calls can then inherit the remote parent span. Non-string carrier values should be ignored, consistently with Airflow's Python tracing path.

Related issues

tiBuilder := proto.TaskInstance_builder{
Id: proto.UUID_builder{Value: ptr(workload.TI.Id.String())}.Build(),
DagId: &workload.TI.DagId,
RunId: &workload.TI.RunId,
TaskId: &workload.TI.TaskId,
Hostname: workload.TI.Hostname,
TryNumber: ptr((int32)(workload.TI.TryNumber)),
// TODO: OtelContext support!
// OtelContext: map[string]string{},
}

workload := api.ExecuteTaskWorkload{
Token: executeTask.GetToken(),
TI: bundlev1.TaskInstance{
DagId: ti.GetDagId(),
Id: id,
RunId: ti.GetRunId(),
TaskId: ti.GetTaskId(),
TryNumber: int(ti.GetTryNumber()),
// TODO: support otel context carrier
// ContextCarrier: (map[string]any)(ti.GetOtelContext()),
},

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions