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

Skip recording Span fields when not requested #2881

Open
wants to merge 1 commit into
base: v0.1.x
Choose a base branch
from

Conversation

Swatinem
Copy link
Contributor

In particular for the Json formatter, one can disable output of spans, in which case it is not necessary to record all of the span fields, as that is potentially expensive.

Motivation

Creating Spans is a lot more frequent than capturing Events (in particular with #[instrument]).
In some profiling I have done, it shows that the overhead of tracing is quite high, in particular recording of all the Span fields.

Solution

There is already a mechanism to disable outputting all the spans of Events, at least for the Json formatter. However that was still recording all the fields, even though they are never being used. This will now skip that.

In particular for the `Json` formatter, one can disable output of spans, in which case it is not necessary to record all of the span fields, as that is potentially expensive.
@Swatinem Swatinem requested review from hawkw and a team as code owners February 15, 2024 09:53
@mladedav
Copy link
Contributor

Hi, why isn't not setting the fields on the span sufficient? Either by not naming them or using #[instrument(skip_all)].

Do you want your json logs to contain only the name of the span while other subscribers such as otel contains all the fields? Or am I missing the intended use case?

@Swatinem
Copy link
Contributor Author

Do you want your json logs to contain only the name of the span while other subscribers such as otel contains all the fields?

Yes pretty much. I have another subscriber / layer which should record all the fields, but I don’t care to see them in the JSON output.

@hwrdtm
Copy link

hwrdtm commented Aug 2, 2024

+1 we are needing to reduce the overhead in some of our testing environments, where we aren't interested so much in the span details and fields and are only wanting the log events, but because the log events are nested within span events, the log events show up with all of the fields of the contextual span it is in.

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

Successfully merging this pull request may close these issues.

3 participants