Skip to content

Commit

Permalink
Add auth data to logging exporter
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
jpkrohling committed Jul 30, 2021
1 parent 56526b3 commit 4db983c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion exporter/loggingexporter/logging_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configauth"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/internal/otlptext"
Expand All @@ -38,7 +39,19 @@ type loggingExporter struct {
}

func (s *loggingExporter) pushTraces(_ context.Context, td pdata.Traces) error {
s.logger.Info("TracesExporter", zap.Int("#spans", td.SpanCount()))
fields := []zap.Field{
zap.Int("#spans", td.SpanCount()),
}

ac := configauth.ExtractPDataContext(td.ResourceSpans().At(0).PDataContext())
if ac != nil {
fields = append(fields, zap.String("sub", ac.Subject()))
fields = append(fields, zap.Strings("groups", ac.Groups()))
} else {
fields = append(fields, zap.String("auth", "none"))
}

s.logger.Info("TracesExporter", fields...)

if !s.debug {
return nil
Expand Down

0 comments on commit 4db983c

Please sign in to comment.