Skip to content

Commit e9493e1

Browse files
authored
feat(llmobs): add source:otel tag to evaluations when DD_TRACE_OTEL_ENABLED is set (#7113)
* feat: * Sam comments
1 parent 86b4f71 commit e9493e1

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

packages/dd-trace/src/llmobs/sdk.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,11 @@ class LLMObs extends NoopLLMObs {
410410
}
411411
}
412412

413+
// When OTel tracing is enabled, add source:otel tag to allow backend to wait for OTel span conversion
414+
if (isTrue(getEnvironmentVariable('DD_TRACE_OTEL_ENABLED'))) {
415+
evaluationTags.source = 'otel'
416+
}
417+
413418
const payload = {
414419
span_id: spanId,
415420
trace_id: traceId,

packages/dd-trace/test/llmobs/sdk/index.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,29 @@ describe('sdk', () => {
12581258
value: 'it is super toxic!'
12591259
}), { message: 'value must be a boolean for a boolean metric' })
12601260
})
1261+
1262+
describe('with DD_TRACE_OTEL_ENABLED set', () => {
1263+
before(() => {
1264+
process.env.DD_TRACE_OTEL_ENABLED = 'true'
1265+
})
1266+
1267+
after(() => {
1268+
delete process.env.DD_TRACE_OTEL_ENABLED
1269+
})
1270+
1271+
it('adds source:otel tag', () => {
1272+
llmobs.submitEvaluation(spanCtx, {
1273+
mlApp: 'test',
1274+
timestampMs: 1234,
1275+
label: 'test',
1276+
metricType: 'score',
1277+
value: 0.6
1278+
})
1279+
1280+
const evalMetric = LLMObsEvalMetricsWriter.prototype.append.getCall(0).args[0]
1281+
assert.ok(evalMetric.tags.includes('source:otel'), 'Expected source:otel tag to be present')
1282+
})
1283+
})
12611284
})
12621285

12631286
describe('flush', () => {

0 commit comments

Comments
 (0)