Skip to content

Commit

Permalink
ddtrace/tracer: adding log.Debug to ci visibility types.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyredondo committed Sep 9, 2024
1 parent f39843b commit 11fe7ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ddtrace/tracer/civisibility_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/tinylib/msgp/msgp"
"gopkg.in/DataDog/dd-trace-go.v1/internal/globalconfig"
"gopkg.in/DataDog/dd-trace-go.v1/internal/log"
"gopkg.in/DataDog/dd-trace-go.v1/internal/version"
)

Expand Down Expand Up @@ -46,6 +47,7 @@ func (p *ciVisibilityPayload) push(event *ciVisibilityEvent) error {
//
// A pointer to a newly initialized civisibilitypayload instance.
func newCiVisibilityPayload() *ciVisibilityPayload {
log.Debug("ciVisibilityPayload: creating payload instance")
return &ciVisibilityPayload{newPayload()}
}

Expand All @@ -61,6 +63,7 @@ func newCiVisibilityPayload() *ciVisibilityPayload {
// A pointer to a bytes.Buffer containing the encoded CI Visibility payload.
// An error if reading from the buffer or encoding the payload fails.
func (p *ciVisibilityPayload) getBuffer(config *config) (*bytes.Buffer, error) {
log.Debug("ciVisibilityPayload: .getBuffer (count: %v)", p.itemCount())

/*
The Payload format in the CI Visibility protocol is like this:
Expand Down
3 changes: 3 additions & 0 deletions ddtrace/tracer/civisibility_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func newCiVisibilityTransport(config *config) *ciVisibilityTransport {
testCycleURL = fmt.Sprintf("%s/%s/%s", config.agentURL.String(), EvpProxyPath, TestCyclePath)
}

log.Debug("ciVisibilityTransport: creating transport instance [agentless: %v, testcycleurl: %v]", agentlessEnabled, testCycleURL)

return &ciVisibilityTransport{
config: config,
testCycleURLPath: testCycleURL,
Expand Down Expand Up @@ -157,6 +159,7 @@ func (t *ciVisibilityTransport) send(p *payload) (body io.ReadCloser, err error)
req.Header.Set("Content-Encoding", "gzip")
}

log.Debug("ciVisibilityTransport: sending transport request: %v bytes", buffer.Len())
response, err := t.config.httpClient.Do(req)
if err != nil {
return nil, err
Expand Down
11 changes: 6 additions & 5 deletions ddtrace/tracer/civisibility_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type ciVisibilityTraceWriter struct {
//
// A pointer to an initialized ciVisibilityTraceWriter.
func newCiVisibilityTraceWriter(c *config) *ciVisibilityTraceWriter {
log.Debug("ciVisibilityTraceWriter: creating trace writer instance")
return &ciVisibilityTraceWriter{
config: c,
payload: newCiVisibilityPayload(),
Expand All @@ -62,7 +63,7 @@ func (w *ciVisibilityTraceWriter) add(trace []*span) {
for _, s := range trace {
cvEvent := getCiVisibilityEvent(s)
if err := w.payload.push(cvEvent); err != nil {
log.Error("Error encoding msgpack: %v", err)
log.Error("ciVisibilityTraceWriter: Error encoding msgpack: %v", err)
}
if w.payload.size() > agentlessPayloadSizeLimit {
w.flush()
Expand Down Expand Up @@ -104,16 +105,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 events: %d\n", size, count)
log.Debug("ciVisibilityTraceWriter: sending payload: size: %d events: %d\n", size, count)
_, err = w.config.transport.send(p.payload)
if err == nil {
log.Debug("sent events after %d attempts", attempt+1)
log.Debug("ciVisibilityTraceWriter: sent events after %d attempts", attempt+1)
return
}
log.Error("failure sending events (attempt %d), will retry: %v", attempt+1, err)
log.Error("ciVisibilityTraceWriter: failure sending events (attempt %d), will retry: %v", attempt+1, err)
p.reset()
time.Sleep(time.Millisecond)
}
log.Error("lost %d events: %v", count, err)
log.Error("ciVisibilityTraceWriter: lost %d events: %v", count, err)
}(oldp)
}

0 comments on commit 11fe7ce

Please sign in to comment.