Skip to content

Commit b7356c7

Browse files
authored
Merge branch 'main' into anmarchenko-fix-known-tests-pagination
2 parents 72e3a9e + 8b52c4a commit b7356c7

6 files changed

Lines changed: 503 additions & 36 deletions

File tree

ddtrace/tracer/spancontext_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,3 +1598,53 @@ func TestFromGenericCtxSamplingDecision(t *testing.T) {
15981598
"drop() after keep() should be a no-op — the trace stays rescued")
15991599
})
16001600
}
1601+
1602+
// TestChildInheritsUpdatedParentService verifies that when a parent span's service
1603+
// is changed via SetTag after creation, a subsequently-started child inherits the
1604+
// updated service name from context.inherited.
1605+
func TestChildInheritsUpdatedParentService(t *testing.T) {
1606+
trc, _, _, stop, err := startTestTracer(t, WithService("global-svc"))
1607+
require.NoError(t, err)
1608+
defer stop()
1609+
1610+
parent := trc.StartSpan("parent", ServiceName("original-svc"))
1611+
defer parent.Finish()
1612+
parent.SetTag(ext.ServiceName, "updated-svc")
1613+
1614+
child := trc.StartSpan("child", ChildOf(parent.Context()))
1615+
defer child.Finish()
1616+
1617+
assert.Equal(t, "updated-svc", child.service)
1618+
}
1619+
1620+
// TestExtractedContextOriginMarkedOnFirstChildOnly verifies that origin from an
1621+
// extracted remote context is set on the first local child span only. The condition
1622+
// context.trace.root == nil must be true for remote contexts and false for local ones.
1623+
func TestExtractedContextOriginMarkedOnFirstChildOnly(t *testing.T) {
1624+
trc, _, _, stop, err := startTestTracer(t)
1625+
require.NoError(t, err)
1626+
defer stop()
1627+
1628+
// Simulate a remote extracted context with an origin.
1629+
// +checklocksignore — initialization time, not yet shared.
1630+
remoteCtx := &SpanContext{
1631+
traceID: traceIDFrom64Bits(42),
1632+
spanID: 99,
1633+
origin: "synthetics",
1634+
}
1635+
remoteCtx.trace = newTrace() // trace.root is nil — no local spans yet
1636+
1637+
child := trc.StartSpan("local-op", ChildOf(remoteCtx))
1638+
defer child.Finish()
1639+
1640+
origin, ok := child.meta.Get(keyOrigin)
1641+
assert.True(t, ok, "first local span from remote context should have origin marked")
1642+
assert.Equal(t, "synthetics", origin)
1643+
1644+
// Grandchild: parent.Context().trace.root is now non-nil, so origin must not be set.
1645+
grandchild := trc.StartSpan("grandchild", ChildOf(child.Context()))
1646+
defer grandchild.Finish()
1647+
1648+
_, hasOrigin := grandchild.meta.Get(keyOrigin)
1649+
assert.False(t, hasOrigin, "grandchild should not have origin — it is not the first local span")
1650+
}

ddtrace/tracer/sqlcomment_test.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ import (
1919
"github.com/stretchr/testify/require"
2020
)
2121

22+
type sqlCommentStringer string
23+
24+
func (s sqlCommentStringer) String() string {
25+
return string(s)
26+
}
27+
2228
func TestSQLCommentCarrier(t *testing.T) {
2329
testCases := []struct {
2430
name string
@@ -353,6 +359,61 @@ func FuzzSpanContextFromTraceComment(f *testing.F) {
353359
})
354360
}
355361

362+
// TestSQLCommentUsesUpdatedInheritedTags verifies that when env, version, and
363+
// peer.service are set on a span after creation, SQLCommentCarrier.Inject reads
364+
// the updated values from context.inherited rather than stale initial values.
365+
func TestSQLCommentUsesUpdatedInheritedTags(t *testing.T) {
366+
trc, err := newTracer(WithService("my-svc"))
367+
require.NoError(t, err)
368+
defer globalconfig.SetServiceName("")
369+
defer trc.Stop()
370+
371+
span := trc.StartSpan("op")
372+
defer span.Finish()
373+
374+
span.SetTag(ext.Environment, "staging")
375+
span.SetTag(ext.Version, "2.0")
376+
span.SetTag(ext.PeerService, "peer-svc")
377+
378+
carrier := SQLCommentCarrier{
379+
Query: "SELECT 1",
380+
Mode: DBMPropagationModeService,
381+
DBServiceName: "mydb",
382+
}
383+
err = carrier.Inject(span.Context())
384+
require.NoError(t, err)
385+
386+
assert.Contains(t, carrier.Query, "dde='staging'")
387+
assert.Contains(t, carrier.Query, "ddpv='2.0'")
388+
assert.Contains(t, carrier.Query, "ddprs='peer-svc'")
389+
}
390+
391+
func TestSQLCommentUsesConvertedInheritedTags(t *testing.T) {
392+
trc, err := newTracer(WithService("my-svc"))
393+
require.NoError(t, err)
394+
defer globalconfig.SetServiceName("")
395+
defer trc.Stop()
396+
397+
span := trc.StartSpan("op")
398+
defer span.Finish()
399+
400+
span.SetTag(ext.Environment, []byte("staging"))
401+
span.SetTag(ext.Version, sqlCommentStringer("2.0"))
402+
span.SetTag(ext.PeerService, true)
403+
404+
carrier := SQLCommentCarrier{
405+
Query: "SELECT 1",
406+
Mode: DBMPropagationModeService,
407+
DBServiceName: "mydb",
408+
}
409+
err = carrier.Inject(span.Context())
410+
require.NoError(t, err)
411+
412+
assert.Contains(t, carrier.Query, "dde='staging'")
413+
assert.Contains(t, carrier.Query, "ddpv='2.0'")
414+
assert.Contains(t, carrier.Query, "ddprs='true'")
415+
}
416+
356417
func BenchmarkSQLCommentInjection(b *testing.B) {
357418
tracer, spanCtx, carrier := setupBenchmark()
358419
defer tracer.Stop()

ddtrace/tracer/textmap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,7 @@ func TestEnvVars(t *testing.T) {
19501950
err = tracer.Inject(s.Context(), headers)
19511951
assert.NoError(err)
19521952
assert.Equal(tc.tid.value, sctx.traceID.value)
1953-
assert.Equal(tc.out[0], sctx.span.parentID)
1953+
assert.Equal(tc.out[0], s.parentID)
19541954
assert.Equal(tc.out[1], sctx.spanID)
19551955

19561956
checkSameElements(assert, tc.outMap[traceparentHeader], headers[traceparentHeader])

internal/llmobs/transport/dne.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ type ExperimentEvalMetricEvent struct {
151151
Error *ErrorMessage `json:"error,omitempty"`
152152
Tags []string `json:"tags,omitempty"`
153153
ExperimentID string `json:"experiment_id,omitempty"`
154+
155+
// Reasoning is a free-form explanation for the evaluation result
156+
// (e.g. an LLM judge's reasoning paragraph).
157+
Reasoning string `json:"reasoning,omitempty"`
158+
// Assessment is an optional categorical assessment of the result.
159+
// Conventional values are "pass" and "fail".
160+
Assessment string `json:"assessment,omitempty"`
161+
// EvalMetricMetadata is arbitrary structured metadata about this
162+
// specific evaluation. Distinct from span metadata.
163+
EvalMetricMetadata map[string]any `json:"eval_metric_metadata,omitempty"`
154164
}
155165

156166
type (

0 commit comments

Comments
 (0)