Open Swatinem opened 5 months ago
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?
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.
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
Span
s is a lot more frequent than capturingEvent
s (in particular with#[instrument]
). In some profiling I have done, it shows that the overhead oftracing
is quite high, in particular recording of all theSpan
fields.Solution
There is already a mechanism to disable outputting all the spans of
Event
s, at least for theJson
formatter. However that was still recording all the fields, even though they are never being used. This will now skip that.