Skip to content

feat: whether to ignore the log API under tracing and record it as event to otel event #216

Open
@ShyunnY

Description

@ShyunnY

Feature Request

Motivation

I'm new to the tracing-opentelemetry crate, and I'm glad to see that this library can be connected to tracing! I had an idea while using it: in the current implementation of tracing-opentelemetry, the content of the log api (info!/warn!/error!...) in the Span scope is attached to the Span as an otel Event.

let mut builder_updates = None;
event.record(&mut SpanEventVisitor {
event_builder: &mut otel_event,
span_builder_updates: &mut builder_updates,
sem_conv_config: self.sem_conv_config,
});

Consider a problem: sometimes users do not want to attach log records to the Span as an otel event, but get the span of the current context through the Span::current() provided by tracing, and then manually set some operations.

#[instrument]
async fn do_something(username: String) {
    info!("just record some logs. Do not attach these logs to the Event!");

    let span = Span::current();
    span.record("username", &username);
}

Proposal

So should we consider adding a feature or configuration to ignore the events recorded in the log? If there is a better way, I hope you can tell me. Thank you.

Alternatives

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