Sample logs consistently with trace sampling#6814
Sample logs consistently with trace sampling#6814jeanbisutti wants to merge 1 commit intoopen-telemetry:mainfrom
Conversation
|
@jack-berg @jkwatson cc @trask Would you agree to try to add this feature as experimental to this repository (perhaps with a different implementation)? If the answer is yes, we could iterate in this repo:
Or would you recommend a different approach? |
| severityText, | ||
| body, | ||
| attributes)); | ||
| SpanContext spanContext = Span.fromContext(context).getSpanContext(); |
There was a problem hiding this comment.
This whole thing needs to be configurable.
For an approach consistent with tracing (which I think is a good baseline to consider), we need a new LogSampler interface analagous to Sampler.
The key should sample method might have a contract like:
boolean shouldSample(
Context context,
Severity severity,
Value<?> body,
Attributes attributes);
Notes:
- Pass individual components of LogRecord instead of
SdkReadWriteLogRecordso we can avoid allocations ifshouldSamplereturns false. Also for consistency with tracing. - Omit resource, scope arguments for consistency with tracing
- Omit timestamp, observed timesamp arguments for consistency with tracing
- Omit severityText because it mostly duplicates severity
- Return a boolean instead of the
SamplingResultreturned by tracing because log sampling is less complicated that trace sampling
With an interface like this, we could have built in samplers for common use cases. I.e. we could have a "trace based" sampler that retains logs if the span in context is sampled.
|
I believe this is resolved now with the trace based sampling option from #7529. If I'm misunderstanding and please re-open. |
The goal is to be able to sample logs consistently with trace sampling.