Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty parent span id with set_parent for opentelemetry remote context #1564

Closed
AlexKovalevych opened this issue Sep 14, 2021 · 1 comment
Closed

Comments

@AlexKovalevych
Copy link

Bug Report

Version

/app # cargo tree | grep tracing
│ │ │ └── tracing v0.1.26
│ │ │ ├── tracing-attributes v0.1.15 (proc-macro)
│ │ │ └── tracing-core v0.1.20
│ │ ├── tracing v0.1.26 ()
│ │ └── tracing v0.1.26 (
)
│ ├── tracing v0.1.26 ()
│ └── tracing-futures v0.2.5
│ └── tracing v0.1.26 (
)
├── tracing v0.1.26 ()
├── tracing-futures v0.2.5 (
)
├── tracing-log v0.1.2
│ └── tracing-core v0.1.20 ()
├── tracing-opentelemetry v0.15.0
│ ├── tracing v0.1.26 (
)
│ ├── tracing-core v0.1.20 ()
│ ├── tracing-log v0.1.2 (
)
│ └── tracing-subscriber v0.2.22
│ ├── tracing v0.1.26 ()
│ ├── tracing-core v0.1.20 (
)
│ ├── tracing-log v0.1.2 ()
│ └── tracing-serde v0.1.2
│ └── tracing-core v0.1.20 (
)
└── tracing-subscriber v0.2.22 (*)

Platform

Linux 9aed9f20ff75 5.13.13-1-MANJARO #1 SMP PREEMPT Thu Aug 26 20:34:21 UTC 2021 x86_64 Linux

Description

parent_span_id is not set (0 value) for the root span, as result it's not connected with the rest of the application in jaeger dashboard.

E.g. (changed tracer to stdout for display purposes):

SpanData { span_context: SpanContext { trace_id: TraceId(194846708092283916411601143714302177863), span_id: SpanId(9475484197453159849), trace_flags: TraceFlags(1), is_remote: false, trace_state: TraceState(None) }, parent_span_id: SpanId(0), span_kind: Internal, name: "hello world", start_time: SystemTime { tv_sec: 1631627763, tv_nsec: 726402313 }, end_time: SystemTime { tv_sec: 1631627763, tv_nsec: 726523183 }, attributes: EvictedHashMap { map: {Key("code.lineno"): I64(89), Key("busy_ns"): I64(16600), Key("idle_ns"): I64(92760), Key("code.filepath"): String("src/common/grpc/terminology_service.rs"), Key("code.namespace"): String("common::grpc::terminology_service")}, evict_list: [Key("idle_ns"), Key("busy_ns"), Key("code.lineno"), Key("code.namespace"), Key("code.filepath")], max_len: 128, dropped_count: 0 }, events: EvictedQueue { queue: None, max_len: 128, dropped_count: 0 }, links: EvictedQueue { queue: None, max_len: 128, dropped_count: 0 }, status_code: Unset, status_message: "", resource: Some(Resource { attrs: {Key("service.name"): String("unknown_service")} }), instrumentation_lib: InstrumentationLibrary { name: "opentelemetry", version: Some("0.16.0") } }

root span is created in grpc server endpoint (using tonic server):

...
#[tonic::async_trait]
impl Terminology for TerminologyService {
    async fn batch_validate(
        &self,
        request: Request<BatchValidateCodeRequest>,
    ) -> Result<Response<BatchValidateCodeResponse>, Status> {
        let parent_context = opentelemetry::global::get_text_map_propagator(|propagator| {
            propagator.extract(&crate::tracing::MetadataMap(request.metadata()))
        });

        let span = tracing::span!(tracing::Level::INFO, "hello world");
        span.set_parent(parent_context.clone());

Expecting result: parent_span_id to be span id extracted from the grpc request metadata headers. Btw, it works if i use opentelemetry directly:

    let parent_context = opentelemetry::global::get_text_map_propagator(|propagator| {
            propagator.extract(&crate::tracing::MetadataMap(request.metadata()))
    });
    let span = global::tracer("opentelemetry-jaeger").start_with_context("hello world", parent_context);
    let tracing_context = opentelemetry::Context::current_with_span(span);
   ...
@AlexKovalevych
Copy link
Author

It looks like it was a wrong opentelemetry configuration layer from my side, everything works, will close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant