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

Remove the otlp trace exporter limit of SpanEvents when exporting #2616

Merged
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -22,6 +22,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

- Add event and link drop counts to the exported data from the `oltptrace` exporter. (#2601)

### Fixed

- Remove the OTLP trace exporter limit of SpanEvents when exporting. (#2616)

## [1.4.1] - 2022-02-16

### Fixed
Expand Down
14 changes: 2 additions & 12 deletions exporters/otlp/otlptrace/internal/tracetransform/span.go
Expand Up @@ -23,10 +23,6 @@ import (
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
)

const (
maxEventsPerSpan = 128
)

// Spans transforms a slice of OpenTelemetry spans into a slice of OTLP
// ResourceSpans.
func Spans(sdl []tracesdk.ReadOnlySpan) []*tracepb.ResourceSpans {
Expand Down Expand Up @@ -177,22 +173,16 @@ func spanEvents(es []tracesdk.Event) []*tracepb.Span_Event {
return nil
}

evCount := len(es)
if evCount > maxEventsPerSpan {
evCount = maxEventsPerSpan
}
events := make([]*tracepb.Span_Event, evCount)

events := make([]*tracepb.Span_Event, len(es))
// Transform message events
for i := 0; i < evCount; i++ {
for i := 0; i < len(es); i++ {
events[i] = &tracepb.Span_Event{
Name: es[i].Name,
TimeUnixNano: uint64(es[i].Time.UnixNano()),
Attributes: KeyValues(es[i].Attributes),
DroppedAttributesCount: uint32(es[i].DroppedAttributeCount),
}
}

return events
}

Expand Down
13 changes: 0 additions & 13 deletions exporters/otlp/otlptrace/internal/tracetransform/span_test.go
Expand Up @@ -15,7 +15,6 @@
package tracetransform

import (
"strconv"
"testing"
"time"

Expand Down Expand Up @@ -102,18 +101,6 @@ func TestSpanEvent(t *testing.T) {
assert.Equal(t, &tracepb.Span_Event{Name: "test 2", Attributes: KeyValues(attrs), TimeUnixNano: eventTimestamp, DroppedAttributesCount: 2}, got[1])
}

func TestExcessiveSpanEvents(t *testing.T) {
e := make([]tracesdk.Event, maxEventsPerSpan+1)
for i := 0; i < maxEventsPerSpan+1; i++ {
e[i] = tracesdk.Event{Name: strconv.Itoa(i)}
}
assert.Len(t, e, maxEventsPerSpan+1)
got := spanEvents(e)
assert.Len(t, got, maxEventsPerSpan)
// Ensure the drop order.
assert.Equal(t, strconv.Itoa(maxEventsPerSpan-1), got[len(got)-1].Name)
}

func TestNilLinks(t *testing.T) {
assert.Nil(t, links(nil))
}
Expand Down