Skip to content

trace and span IDs are invalid (zero) #44

@aharbis

Description

@aharbis

The TraceId returned by telemetry::get_trace_id is invalid (zero). This is also the case for the SpanId. I suspect it's something to do with the integration between tracing and opentelemetry (in src/telemetry.go):

///  Fetch an opentelemetry::trace::TraceId as hex through the full tracing stack
pub fn get_trace_id() -> TraceId {
    use opentelemetry::trace::TraceContextExt as _; // opentelemetry::Context -> opentelemetry::trace::Span
    use tracing_opentelemetry::OpenTelemetrySpanExt as _; // tracing::Span to opentelemetry::Context

    tracing::Span::current()
        .context()
        .span()
        .span_context()
        .trace_id()
}

Running locally against my Kubernetes cluster, with the lorem example doc created, the trace_id value is always zero:

2023-03-06T03:00:22.530885Z INFO reconciling object{object.ref=Document.v1.kube.rs/lorem.default object.reason=object updated}:reconcile{trace_id=00000000000000000000000000000000}: controller::controller: Reconciling Document "lorem" in default

Adding a getter and Field for span_id shows similar:

2023-03-06T04:12:32.778508Z INFO reconciling object{object.ref=Document.v1.kube.rs/lorem.default object.reason=object updated}:reconcile{trace_id=00000000000000000000000000000000 span_id=0000000000000000}: controller::controller: Reconciling Document "lorem" in default

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions