Skip to content

Add special "void span" to discard all child spans #2738

Closed
@andrewbanchich

Description

@andrewbanchich

Feature Request

Add a special "void span" where all spans created within it are noops / removed.

Motivation

I am working on a way to ensure sensitive data is not accidentally logged by creating a wrapper type, which provides a map() method for users to work with the underlying secret. However, it is possible for a user to pass a function to map() which is instrumented with a span.

I would like to be able to change it to something like

fn map<U, F>(self, f: F) -> Secret<U>
    where
        F: FnOnce(T) -> U,
    {
        let void_span = void!();
        let _enter = void_span.enter();

        Self::new(f(x))
    }

to ensure nothing is logged.

Proposal

Alternatives

There are several approaches to redacting sensitive data, but it is usually necessary to have some section of the code need to work with that data directly. It would be nice to be able to minimize the scope of where that occurs, as well as ensure that no logging happens there.

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