Skip to content

Example for using tracing extension and messagesΒ #209

@liamwh

Description

@liamwh

Is your feature request related to a problem? Please describe.

I am investigating how we could leverage CloudEvents within my org, but am uncertain how we can include tracing information in a CloudEvent so that traces can be followed across service boundaries and correlated by Jaeger / Tempo.

For example:
One service is written in Rust, and it leverages the tracing crate. The functions are leveraging the instrument macro and with tracing configured as seen here. We'd like to publish a CloudEvent externally to the application (Kafa for example), and we see that we should use this extension extension API, but there no examples how to use it.

Describe the solution you'd like

An example added to the /examples folder where an event is published that includes tracing information according to the CloudEvents distributed tracing spec whilst using the tracing crate, the most prominent tracing crate for Rust.

   let example_event = cloudevents::EventBuilderV10::new()
        .id(Ulid::new())
        .source(SOURCE_NAME)
        .ty(EXAMPLE_EVENT_TYPE)
        .time(chrono::Utc::now())
        .subject(example_object.id)
        .data(
            mime::APPLICATION_OCTET_STREAM.to_string(),
            bincode::serialize(&example_object)?,
        )
        .extension("traceparent", bincode::serialize(&WHAT_GOES_HERE)) // <-- How to get values as required by traceparent here?
        .build()?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions