Skip to content

Commit c589ad4

Browse files
authored
chore(llmobs): update evaluation metric api endpoint to v2 (#7511)
* use v2 api endpoint * update tests
1 parent 875e585 commit c589ad4

File tree

7 files changed

+46
-18
lines changed

7 files changed

+46
-18
lines changed

packages/dd-trace/src/llmobs/constants/writers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010

1111
EVALUATIONS_INTAKE: 'api',
1212
EVALUATIONS_EVENT_TYPE: 'evaluation_metric',
13-
EVALUATIONS_ENDPOINT: '/api/intake/llm-obs/v1/eval-metric',
13+
EVALUATIONS_ENDPOINT: '/api/intake/llm-obs/v2/eval-metric',
1414

1515
EVP_PAYLOAD_SIZE_LIMIT: 5 << 20, // 5MB (actual limit is 5.1MB)
1616
EVP_EVENT_SIZE_LIMIT: (1 << 20) - 1024, // 999KB (actual limit is 1MB)

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,12 @@ class LLMObs extends NoopLLMObs {
412412
}
413413

414414
const payload = {
415-
span_id: spanId,
416-
trace_id: traceId,
415+
join_on: {
416+
span: {
417+
span_id: spanId,
418+
trace_id: traceId,
419+
},
420+
},
417421
label,
418422
metric_type: metricType,
419423
ml_app: mlApp,

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,8 +1189,12 @@ describe('sdk', () => {
11891189
})
11901190

11911191
assert.deepStrictEqual(LLMObsEvalMetricsWriter.prototype.append.getCall(0).args[0], {
1192-
trace_id: spanCtx.traceId,
1193-
span_id: spanCtx.spanId,
1192+
join_on: {
1193+
span: {
1194+
trace_id: spanCtx.traceId,
1195+
span_id: spanCtx.spanId,
1196+
},
1197+
},
11941198
ml_app: 'test',
11951199
timestamp_ms: 1234,
11961200
label: 'test',
@@ -1241,8 +1245,12 @@ describe('sdk', () => {
12411245
const evalMetric = LLMObsEvalMetricsWriter.prototype.append.getCall(0).args[0]
12421246

12431247
assert.deepStrictEqual(evalMetric, {
1244-
span_id: '5678',
1245-
trace_id: '1234',
1248+
join_on: {
1249+
span: {
1250+
span_id: '5678',
1251+
trace_id: '1234',
1252+
},
1253+
},
12461254
label: 'has_toxicity',
12471255
metric_type: 'boolean',
12481256
ml_app: 'mlApp',

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,12 @@ describe('end to end sdk integration tests', () => {
142142
assert.equal(llmobsEvaluationMetrics.length, 1)
143143

144144
assertLlmObsEvaluationMetric(llmobsEvaluationMetrics[0], {
145-
traceId: llmobsSpans[0].trace_id,
146-
spanId: llmobsSpans[0].span_id,
145+
joinOn: {
146+
span: {
147+
traceId: llmobsSpans[0].trace_id,
148+
spanId: llmobsSpans[0].span_id,
149+
},
150+
},
147151
label: 'foo',
148152
metricType: 'categorical',
149153
mlApp: 'test',

packages/dd-trace/test/llmobs/util.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ const MOCK_NOT_NULLISH = Symbol('not-nullish')
4040
/**
4141
* @typedef {{
4242
* label: string,
43-
* traceId: string,
44-
* spanId: string,
43+
* joinOn: {
44+
* span: {
45+
* traceId: string,
46+
* spanId: string,
47+
* },
48+
* },
4549
* metricType: 'categorical' | 'score',
4650
* mlApp: string,
4751
* timestamp?: number,
@@ -279,8 +283,12 @@ function assertLlmObsSpanEvent (actual, expected) {
279283
function assertLlmObsEvaluationMetric (actual, expected) {
280284
const {
281285
label,
282-
traceId = MOCK_STRING,
283-
spanId = MOCK_STRING,
286+
joinOn = {
287+
span: {
288+
traceId: MOCK_STRING,
289+
spanId: MOCK_STRING,
290+
},
291+
},
284292
metricType,
285293
mlApp,
286294
timestamp = MOCK_NUMBER,
@@ -318,8 +326,12 @@ function assertLlmObsEvaluationMetric (actual, expected) {
318326
}
319327

320328
const expectedEvaluationMetric = {
321-
span_id: spanId,
322-
trace_id: traceId,
329+
join_on: {
330+
span: {
331+
trace_id: joinOn.span.traceId,
332+
span_id: joinOn.span.spanId,
333+
},
334+
},
323335
label,
324336
metric_type: metricType,
325337
ml_app: mlApp,

packages/dd-trace/test/llmobs/writers/evaluations.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('LLMObsEvalMetricsWriter', () => {
2929

3030
writer.flush = flush // just to stop the beforeExit flush call
3131

32-
assert.strictEqual(writer.url, 'https://api.datadoghq.com/api/intake/llm-obs/v1/eval-metric')
32+
assert.strictEqual(writer.url, 'https://api.datadoghq.com/api/intake/llm-obs/v2/eval-metric')
3333
assert.strictEqual(writer._eventType, 'evaluation_metric')
3434
})
3535

@@ -39,7 +39,7 @@ describe('LLMObsEvalMetricsWriter', () => {
3939
hostname: 'localhost',
4040
})
4141
writer.setAgentless(false)
42-
assert.strictEqual(writer.url, 'http://localhost:8126/evp_proxy/v2/api/intake/llm-obs/v1/eval-metric')
42+
assert.strictEqual(writer.url, 'http://localhost:8126/evp_proxy/v2/api/intake/llm-obs/v2/eval-metric')
4343
assert.strictEqual(writer._eventType, 'evaluation_metric')
4444
})
4545

packages/dd-trace/test/plugins/agent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ module.exports = {
473473
})
474474

475475
// LLM Observability evaluation metrics endpoint
476-
agent.post('/evp_proxy/v2/api/intake/llm-obs/v1/eval-metric', (req, res) => {
476+
agent.post('/evp_proxy/v2/api/intake/llm-obs/v2/eval-metric', (req, res) => {
477477
llmobsEvaluationMetricsRequests.push(JSON.parse(req.body))
478478
res.status(200).send()
479479
})

0 commit comments

Comments
 (0)