feat: support batched traces
This commit is contained in:
22
processor.go
22
processor.go
@@ -89,15 +89,27 @@ func (tp *LogSamplerProcessor) Capabilities() consumer.Capabilities {
|
||||
}
|
||||
|
||||
/**
|
||||
* For each trace, record the trace id in a buffer.
|
||||
* Every trace's trace id that is processed by the processor is being remembered.
|
||||
*/
|
||||
func (tp *LogSamplerProcessor) ConsumeTraces(ctx context.Context, td ptrace.Traces) error {
|
||||
traceId := td.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).TraceID()
|
||||
for i := range td.ResourceSpans().Len() {
|
||||
resourceSpans := td.ResourceSpans().At(i)
|
||||
|
||||
if !traceId.IsEmpty() {
|
||||
tp.traceIdTtlMap.Add(hex.EncodeToString(traceId[:]))
|
||||
for j := range resourceSpans.ScopeSpans().Len() {
|
||||
scopeSpans := resourceSpans.ScopeSpans().At(j)
|
||||
|
||||
tp.logger.Debug("Trace added to buffer", zap.String("traceId", hex.EncodeToString(traceId[:])))
|
||||
for k := range scopeSpans.Spans().Len() {
|
||||
span := scopeSpans.Spans().At(k)
|
||||
traceId := span.TraceID()
|
||||
|
||||
if !traceId.IsEmpty() {
|
||||
traceIdStr := hex.EncodeToString(traceId[:])
|
||||
tp.traceIdTtlMap.Add(traceIdStr)
|
||||
|
||||
tp.logger.Debug("Trace added to buffer", zap.String("traceId", traceIdStr))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tp.nextTracesConsumer.ConsumeTraces(ctx, td)
|
||||
|
||||
Reference in New Issue
Block a user