Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
This changes it to make `SamplingParameters` conform with the OpenTelemetry specification. (#1749)
- Modify `BatchSpanProcessor.ForceFlush` to abort after timeout/cancellation. (#1757)
- Improve OTLP/gRPC exporter connection errors. (#1737)
- Make `ExportSpans` in Jaeger Exporter honor context deadline. (#1773)

### Removed

Expand Down
8 changes: 7 additions & 1 deletion exporters/trace/jaeger/jaeger.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,17 @@ func (e *Exporter) ExportSpans(ctx context.Context, ss []*export.SpanSnapshot) e

for _, span := range ss {
// TODO(jbd): Handle oversized bundlers.
err := e.bundler.Add(span, 1)
err := e.bundler.AddWait(ctx, span, 1)
if err != nil {
return fmt.Errorf("failed to bundle %q: %w", span.Name, err)
}
select {
case <-ctx.Done():
return ctx.Err()
default:
}
}

return nil
}

Expand Down
61 changes: 61 additions & 0 deletions exporters/trace/jaeger/jaeger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,67 @@ func TestErrorOnExportShutdownExporter(t *testing.T) {
assert.NoError(t, e.ExportSpans(context.Background(), nil))
}

func TestExporterExportSpansHonorsCancel(t *testing.T) {
e, err := NewRawExporter(withTestCollectorEndpoint())
require.NoError(t, err)
now := time.Now()
ss := []*export.SpanSnapshot{
{
Name: "s1",
Resource: resource.NewWithAttributes(
semconv.ServiceNameKey.String("name"),
attribute.Key("r1").String("v1"),
),
StartTime: now,
EndTime: now,
},
{
Name: "s2",
Resource: resource.NewWithAttributes(
semconv.ServiceNameKey.String("name"),
attribute.Key("r2").String("v2"),
),
StartTime: now,
EndTime: now,
},
}
ctx, cancel := context.WithCancel(context.Background())
cancel()

assert.EqualError(t, e.ExportSpans(ctx, ss), context.Canceled.Error())
}

func TestExporterExportSpansHonorsTimeout(t *testing.T) {
e, err := NewRawExporter(withTestCollectorEndpoint())
require.NoError(t, err)
now := time.Now()
ss := []*export.SpanSnapshot{
{
Name: "s1",
Resource: resource.NewWithAttributes(
semconv.ServiceNameKey.String("name"),
attribute.Key("r1").String("v1"),
),
StartTime: now,
EndTime: now,
},
{
Name: "s2",
Resource: resource.NewWithAttributes(
semconv.ServiceNameKey.String("name"),
attribute.Key("r2").String("v2"),
),
StartTime: now,
EndTime: now,
},
}
ctx, cancel := context.WithTimeout(context.Background(), time.Nanosecond)
defer cancel()
<-ctx.Done()

assert.EqualError(t, e.ExportSpans(ctx, ss), context.DeadlineExceeded.Error())
}

func TestJaegerBatchList(t *testing.T) {
newString := func(value string) *string {
return &value
Expand Down