Skip to content

Commit af641d6

Browse files
authored
fix(llmobs): tagger reads propogated mlApp and sessionId from registry tags (#5102)
* wip * get rid of unecessary test
1 parent 435109b commit af641d6

3 files changed

Lines changed: 8 additions & 45 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ class LLMObsTagger {
6060
if (modelName) this._setTag(span, MODEL_NAME, modelName)
6161
if (modelProvider) this._setTag(span, MODEL_PROVIDER, modelProvider)
6262

63-
sessionId = sessionId || parent?.context()._tags[SESSION_ID]
63+
sessionId = sessionId || registry.get(parent)?.[SESSION_ID]
6464
if (sessionId) this._setTag(span, SESSION_ID, sessionId)
6565

66-
if (!mlApp) mlApp = parent?.context()._tags[ML_APP] || this._config.llmobs.mlApp
66+
if (!mlApp) mlApp = registry.get(parent)?.[ML_APP] || this._config.llmobs.mlApp
6767
this._setTag(span, ML_APP, mlApp)
6868

6969
const parentId =

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -177,45 +177,6 @@ describe('end to end sdk integration tests', () => {
177177
check(expected, llmobsSpans)
178178
})
179179

180-
it('instruments and uninstruments as needed', () => {
181-
payloadGenerator = function () {
182-
llmobs.disable()
183-
llmobs.trace({ kind: 'agent', name: 'llmobsParent' }, () => {
184-
llmobs.annotate({ inputData: 'hello', outputData: 'world' })
185-
llmobs.enable({ mlApp: 'test1' })
186-
llmobs.trace({ kind: 'workflow', name: 'child1' }, () => {
187-
llmobs.disable()
188-
llmobs.trace({ kind: 'workflow', name: 'child2' }, () => {
189-
llmobs.enable({ mlApp: 'test2' })
190-
llmobs.trace({ kind: 'workflow', name: 'child3' }, () => {})
191-
})
192-
})
193-
})
194-
}
195-
196-
const { spans, llmobsSpans } = run(payloadGenerator)
197-
expect(spans).to.have.lengthOf(4)
198-
expect(llmobsSpans).to.have.lengthOf(2)
199-
200-
const expected = [
201-
expectedLLMObsNonLLMSpanEvent({
202-
span: spans[1],
203-
spanKind: 'workflow',
204-
tags: { ...tags, ml_app: 'test1' },
205-
name: 'child1'
206-
}),
207-
expectedLLMObsNonLLMSpanEvent({
208-
span: spans[3],
209-
spanKind: 'workflow',
210-
tags: { ...tags, ml_app: 'test2' },
211-
name: 'child3',
212-
parentId: spans[1].context().toSpanId()
213-
})
214-
]
215-
216-
check(expected, llmobsSpans)
217-
})
218-
219180
it('submits evaluations', () => {
220181
sinon.stub(Date, 'now').returns(1234567890)
221182
payloadGenerator = function () {

packages/dd-trace/test/llmobs/tagger.spec.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,16 @@ describe('tagger', () => {
111111
const parentSpan = {
112112
context () {
113113
return {
114-
_tags: {
115-
'_ml_obs.meta.ml_app': 'my-ml-app',
116-
'_ml_obs.session_id': 'my-session'
117-
},
118114
toSpanId () { return '5678' }
119115
}
120116
}
121117
}
118+
119+
Tagger.tagMap.set(parentSpan, {
120+
'_ml_obs.meta.ml_app': 'my-ml-app',
121+
'_ml_obs.session_id': 'my-session'
122+
})
123+
122124
tagger.registerLLMObsSpan(span, { kind: 'llm', parent: parentSpan })
123125

124126
expect(Tagger.tagMap.get(span)).to.deep.equal({

0 commit comments

Comments
 (0)