Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: DataDog/dd-trace-go
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.60.0
Choose a base ref
...
head repository: DataDog/dd-trace-go
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.60.1
Choose a head ref
  • 16 commits
  • 17 files changed
  • 8 contributors

Commits on Feb 5, 2024

  1. Copy the full SHA
    8c6930a View commit details
  2. Copy the full SHA
    2a9b414 View commit details
  3. Copy the full SHA
    bfad2b1 View commit details
  4. Copy the full SHA
    3689dc5 View commit details
  5. Copy the full SHA
    92ad226 View commit details
  6. Copy the full SHA
    f8310a9 View commit details
  7. ddtrace/opentelemetry: refactor OTel API tests (#2503)

    Co-authored-by: Katie Hockman <katie.hockman@datadoghq.com>
    Co-authored-by: Dario Castañé <dario.castane@datadoghq.com>
    3 people committed Feb 5, 2024
    Copy the full SHA
    75491a7 View commit details
  8. Copy the full SHA
    f43fa21 View commit details
  9. internal/version: v1.60.1

    darccio committed Feb 5, 2024
    Copy the full SHA
    ef922de View commit details
  10. Copy the full SHA
    23ff1bd View commit details
  11. Copy the full SHA
    ac77773 View commit details
  12. Revert "[data streams] Track high watermark offsets (#2511)"

    This reverts commit bfad2b1.
    darccio committed Feb 5, 2024
    Copy the full SHA
    9244140 View commit details
  13. Copy the full SHA
    66ca6cc View commit details
  14. Copy the full SHA
    0dc6947 View commit details

Commits on Feb 6, 2024

  1. Copy the full SHA
    0910bfc View commit details

Commits on Feb 7, 2024

  1. internal/version: v1.60.1

    darccio committed Feb 7, 2024
    Copy the full SHA
    6acc14d View commit details
19 changes: 1 addition & 18 deletions contrib/internal/httptrace/config_test.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
package httptrace

import (
"os"
"testing"

"github.com/stretchr/testify/require"
@@ -50,28 +49,12 @@ func TestConfig(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
defer cleanEnv()()
for k, v := range tc.env {
os.Setenv(k, v)
t.Setenv(k, v)
}
c := newConfig()
require.Equal(t, tc.cfg.queryStringRegexp, c.queryStringRegexp)
require.Equal(t, tc.cfg.queryString, c.queryString)
})
}
}

func cleanEnv() func() {
env := map[string]string{
envQueryStringDisabled: os.Getenv(envQueryStringDisabled),
envQueryStringRegexp: os.Getenv(envQueryStringRegexp),
}
for k := range env {
os.Unsetenv(k)
}
return func() {
for k, v := range env {
os.Setenv(k, v)
}
}
}
20 changes: 9 additions & 11 deletions ddtrace/opentelemetry/otel_test.go
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ import (
"context"
"net/http"
"net/http/httptest"
"strings"
"testing"

"github.com/stretchr/testify/assert"
@@ -23,6 +22,7 @@ import (
)

func TestHttpDistributedTrace(t *testing.T) {
assert := assert.New(t)
tp, payloads, cleanup := mockTracerProvider(t)
defer cleanup()
otel.SetTracerProvider(tp)
@@ -33,11 +33,10 @@ func TestHttpDistributedTrace(t *testing.T) {

w := otelhttp.NewHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
receivedSpan := oteltrace.SpanFromContext(r.Context())
assert.Equal(t, rootSpan.SpanContext().TraceID(), receivedSpan.SpanContext().TraceID())
assert.Equal(rootSpan.SpanContext().TraceID(), receivedSpan.SpanContext().TraceID())
}), "testOperation")
testServer := httptest.NewServer(w)
defer testServer.Close()

c := http.Client{Transport: otelhttp.NewTransport(nil)}
req, err := http.NewRequestWithContext(sctx, http.MethodGet, testServer.URL, nil)
require.NoError(t, err)
@@ -47,12 +46,11 @@ func TestHttpDistributedTrace(t *testing.T) {
rootSpan.End()

p := <-payloads
numSpans := strings.Count(p, "\"span_id\"")
assert.Equal(t, 3, numSpans)
assert.Contains(t, p, `"name":"internal"`)
assert.Contains(t, p, `"name":"server.request`)
assert.Contains(t, p, `"name":"client.request"`)
assert.Contains(t, p, `"resource":"testRootSpan"`)
assert.Contains(t, p, `"resource":"testOperation"`)
assert.Contains(t, p, `"resource":"HTTP GET"`)
assert.Len(p, 2)
assert.Equal("server.request", p[0][0]["name"])
assert.Equal("internal", p[1][0]["name"])
assert.Equal("client.request", p[1][1]["name"])
assert.Equal("testOperation", p[0][0]["resource"])
assert.Equal("testRootSpan", p[1][0]["resource"])
assert.Equal("HTTP GET", p[1][1]["resource"])
}
12 changes: 11 additions & 1 deletion ddtrace/opentelemetry/span.go
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import (
"errors"
"strconv"
"strings"
"sync"

"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext"
@@ -25,7 +26,8 @@ import (
var _ oteltrace.Span = (*span)(nil)

type span struct {
noop.Span // https://pkg.go.dev/go.opentelemetry.io/otel/trace#hdr-API_Implementations
noop.Span // https://pkg.go.dev/go.opentelemetry.io/otel/trace#hdr-API_Implementations
mu sync.RWMutex `msg:"-"` // all fields are protected by this RWMutex
DD tracer.Span
finished bool
attributes map[string]interface{}
@@ -38,10 +40,14 @@ type span struct {
func (s *span) TracerProvider() oteltrace.TracerProvider { return s.oteltracer.provider }

func (s *span) SetName(name string) {
s.mu.Lock()
defer s.mu.Unlock()
s.attributes[ext.SpanName] = strings.ToLower(name)
}

func (s *span) End(options ...oteltrace.SpanEndOption) {
s.mu.Lock()
defer s.mu.Unlock()
if s.finished {
return
}
@@ -157,6 +163,8 @@ type statusInfo struct {
// value before (OK > Error > Unset), the code will not be changed.
// The code and description are set once when the span is finished.
func (s *span) SetStatus(code otelcodes.Code, description string) {
s.mu.Lock()
defer s.mu.Unlock()
if code >= s.statusInfo.code {
s.statusInfo = statusInfo{code, description}
}
@@ -175,6 +183,8 @@ func (s *span) SetStatus(code otelcodes.Code, description string) {
// The list of reserved tags might be extended in the future.
// Any other non-reserved tags will be set as provided.
func (s *span) SetAttributes(kv ...attribute.KeyValue) {
s.mu.Lock()
defer s.mu.Unlock()
for _, kv := range kv {
if k, v := toReservedAttributes(string(kv.Key), kv.Value); k != "" {
s.attributes[k] = v
Loading