Skip to content

Commit

Permalink
Remove the otlp trace exporter limit of SpanEvents when exporting (#2616
Browse files Browse the repository at this point in the history
)

* remove the limit of SpanEvents when exporting

* fix changelog

* Update exporters/otlp/otlptrace/internal/tracetransform/span.go

Co-authored-by: Sam Xie <xsambundy@gmail.com>

* Update exporters/otlp/otlptrace/internal/tracetransform/span.go

Co-authored-by: Sam Xie <xsambundy@gmail.com>

* Update exporters/otlp/otlptrace/internal/tracetransform/span.go

Co-authored-by: Sam Xie <xsambundy@gmail.com>

* Update CHANGELOG.md

Co-authored-by: Sam Xie <xsambundy@gmail.com>

* fix unused param

* fix changelog

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* fix unittest

* fix code format

Co-authored-by: Sam Xie <xsambundy@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
  • Loading branch information
3 people committed Feb 17, 2022
1 parent 98c2c9d commit 8297dbf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
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

0 comments on commit 8297dbf

Please sign in to comment.