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

[CI Visibility] Add support for CI Visibility mode in ddtrace #2739

3 changes: 1 addition & 2 deletions ddtrace/tracer/civisibility_payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import (
)

func newCiVisibilityEventsList(n int) []*ciVisibilityEvent {
itoa := map[int]string{0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5"}
list := make([]*ciVisibilityEvent, n)
for i := 0; i < n; i++ {
s := newBasicSpan("span.list." + itoa[i%5+1])
s := newBasicSpan("span.list." + strconv.Itoa(i%5+1))
s.Start = fixedTime
list[i] = getCiVisibilityEvent(s)
}
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/civisibility_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

func TestCiVisibilityTransport(t *testing.T) {
t.Run("agentless", func(t *testing.T) { runTransportTest(t, true) })
t.Run("agentbased", func(t *testing.T) { runTransportTest(t, true) })
t.Run("agentbased", func(t *testing.T) { runTransportTest(t, false) })
}

func runTransportTest(t *testing.T, agentless bool) {
Expand Down
10 changes: 5 additions & 5 deletions ddtrace/tracer/civisibility_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var _ traceWriter = (*ciVisibilityTraceWriter)(nil)
// to the Datadog backend. It manages the payload size and flushes the data when necessary.
type ciVisibilityTraceWriter struct {
dianashevchenko marked this conversation as resolved.
Show resolved Hide resolved
config *config // Configuration for the tracer.
payload *ciVisibilityPayload // Encodes and buffers traces in msgpack format.
payload *ciVisibilityPayload // Encodes and buffers events in msgpack format.
climit chan struct{} // Limits the number of concurrent outgoing connections.
wg sync.WaitGroup // Waits for all uploads to finish.
}
Expand Down Expand Up @@ -104,16 +104,16 @@ func (w *ciVisibilityTraceWriter) flush() {
var err error
for attempt := 0; attempt <= w.config.sendRetries; attempt++ {
size, count = p.size(), p.itemCount()
log.Debug("Sending payload: size: %d traces: %d\n", size, count)
log.Debug("Sending payload: size: %d events: %d\n", size, count)
_, err = w.config.transport.send(p.payload)
if err == nil {
log.Debug("sent traces after %d attempts", attempt+1)
log.Debug("sent events after %d attempts", attempt+1)
return
}
log.Error("failure sending traces (attempt %d), will retry: %v", attempt+1, err)
log.Error("failure sending events (attempt %d), will retry: %v", attempt+1, err)
p.reset()
time.Sleep(time.Millisecond)
}
log.Error("lost %d traces: %v", count, err)
log.Error("lost %d events: %v", count, err)
}(oldp)
}
2 changes: 1 addition & 1 deletion ddtrace/tracer/civisibility_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ package tracer
import (
"errors"
"fmt"
"github.com/tinylib/msgp/msgp"
"io"
"strings"
"testing"

"github.com/stretchr/testify/assert"
"github.com/tinylib/msgp/msgp"
)

func TestCIVisibilityImplementsTraceWriter(t *testing.T) {
Expand Down
Loading