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

Add debug-level message on error for Jaeger Exporter #1964

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion exporter/jaegerexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"

jaegerproto "github.com/jaegertracing/jaeger/proto-gen/api_v2"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"

Expand All @@ -32,7 +33,7 @@ import (
// newTraceExporter returns a new Jaeger gRPC exporter.
// The exporter name is the name to be used in the observability of the exporter.
// The collectorEndpoint should be of the form "hostname:14250" (a gRPC target).
func newTraceExporter(cfg *Config) (component.TraceExporter, error) {
func newTraceExporter(cfg *Config, logger *zap.Logger) (component.TraceExporter, error) {

opts, err := cfg.GRPCClientSettings.ToDialOptions()
if err != nil {
Expand All @@ -46,6 +47,7 @@ func newTraceExporter(cfg *Config) (component.TraceExporter, error) {

collectorServiceClient := jaegerproto.NewCollectorServiceClient(client)
s := &protoGRPCSender{
logger: logger,
client: collectorServiceClient,
metadata: metadata.New(cfg.GRPCClientSettings.Headers),
waitForReady: cfg.WaitForReady,
Expand All @@ -64,6 +66,7 @@ func newTraceExporter(cfg *Config) (component.TraceExporter, error) {
// protoGRPCSender forwards spans encoded in the jaeger proto
// format, to a grpc server.
type protoGRPCSender struct {
logger *zap.Logger
client jaegerproto.CollectorServiceClient
metadata metadata.MD
waitForReady bool
Expand All @@ -89,6 +92,7 @@ func (s *protoGRPCSender) pushTraceData(
ctx,
&jaegerproto.PostSpansRequest{Batch: *batch}, grpc.WaitForReady(s.waitForReady))
if err != nil {
s.logger.Debug("failed to push trace data to Jaeger", zap.Error(err))
return td.SpanCount() - sentSpans, fmt.Errorf("failed to push trace data via Jaeger exporter: %w", err)
}
sentSpans += len(batch.Spans)
Expand Down
3 changes: 2 additions & 1 deletion exporter/jaegerexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

Expand Down Expand Up @@ -154,7 +155,7 @@ func TestNew(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := newTraceExporter(&tt.args.config)
got, err := newTraceExporter(&tt.args.config, zap.NewNop())
if (err != nil) != tt.wantErr {
t.Errorf("newTraceExporter() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down
4 changes: 2 additions & 2 deletions exporter/jaegerexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func createDefaultConfig() configmodels.Exporter {

func createTraceExporter(
_ context.Context,
_ component.ExporterCreateParams,
params component.ExporterCreateParams,
config configmodels.Exporter,
) (component.TraceExporter, error) {

Expand All @@ -68,7 +68,7 @@ func createTraceExporter(
return nil, err
}

exp, err := newTraceExporter(expCfg)
exp, err := newTraceExporter(expCfg, params.Logger)
if err != nil {
return nil, err
}
Expand Down