Skip to content

Commit 845c6d5

Browse files
authored
dac strip io from bedrock (#6154)
* first run at bedrock * inline tag building
1 parent c0e5a76 commit 845c6d5

File tree

2 files changed

+7
-45
lines changed

2 files changed

+7
-45
lines changed
Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const BaseAwsSdkPlugin = require('../../base')
4-
const { parseModelId, extractRequestParams, extractTextAndResponseReason } = require('./utils')
4+
const { parseModelId } = require('./utils')
55

66
const enabledOperations = new Set(['invokeModel'])
77

@@ -20,44 +20,12 @@ class BedrockRuntime extends BaseAwsSdkPlugin {
2020
generateTags (params, operation, response) {
2121
const { modelProvider, modelName } = parseModelId(params.modelId)
2222

23-
const requestParams = extractRequestParams(params, modelProvider)
24-
const textAndResponseReason = extractTextAndResponseReason(response, modelProvider, modelName)
25-
26-
const tags = buildTagsFromParams(requestParams, textAndResponseReason, modelProvider, modelName, operation)
27-
28-
return tags
29-
}
30-
}
31-
32-
function buildTagsFromParams (requestParams, textAndResponseReason, modelProvider, modelName, operation) {
33-
const tags = {}
34-
35-
// add request tags
36-
tags['resource.name'] = operation
37-
tags['aws.bedrock.request.model'] = modelName
38-
tags['aws.bedrock.request.model_provider'] = modelProvider.toLowerCase()
39-
tags['aws.bedrock.request.prompt'] = requestParams.prompt
40-
tags['aws.bedrock.request.temperature'] = requestParams.temperature
41-
tags['aws.bedrock.request.top_p'] = requestParams.topP
42-
tags['aws.bedrock.request.top_k'] = requestParams.topK
43-
tags['aws.bedrock.request.max_tokens'] = requestParams.maxTokens
44-
tags['aws.bedrock.request.stop_sequences'] = requestParams.stopSequences
45-
tags['aws.bedrock.request.input_type'] = requestParams.inputType
46-
tags['aws.bedrock.request.truncate'] = requestParams.truncate
47-
tags['aws.bedrock.request.stream'] = requestParams.stream
48-
tags['aws.bedrock.request.n'] = requestParams.n
49-
50-
// add response tags
51-
if (modelName.includes('embed')) {
52-
tags['aws.bedrock.response.embedding_length'] = textAndResponseReason.message.length
53-
}
54-
if (textAndResponseReason.choiceId) {
55-
tags['aws.bedrock.response.choices.id'] = textAndResponseReason.choiceId
23+
return {
24+
'resource.name': operation,
25+
'aws.bedrock.request.model': modelName,
26+
'aws.bedrock.request.model_provider': modelProvider.toLowerCase()
27+
}
5628
}
57-
tags['aws.bedrock.response.choices.text'] = textAndResponseReason.message
58-
tags['aws.bedrock.response.choices.finish_reason'] = textAndResponseReason.finishReason
59-
60-
return tags
6129
}
6230

6331
module.exports = BedrockRuntime

packages/datadog-plugin-aws-sdk/test/bedrockruntime.spec.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const agent = require('../../dd-trace/test/plugins/agent')
44
const nock = require('nock')
55
const { setup } = require('./spec_helpers')
6-
const { models, modelConfig } = require('./fixtures/bedrockruntime')
6+
const { models } = require('./fixtures/bedrockruntime')
77

88
const serviceName = 'bedrock-service-name-test'
99

@@ -64,12 +64,6 @@ describe('Plugin', () => {
6464
'aws.operation': 'invokeModel',
6565
'aws.bedrock.request.model': model.modelId.split('.')[1],
6666
'aws.bedrock.request.model_provider': model.provider.toLowerCase(),
67-
'aws.bedrock.request.prompt': model.userPrompt
68-
})
69-
expect(span.metrics).to.include({
70-
'aws.bedrock.request.temperature': modelConfig.temperature,
71-
'aws.bedrock.request.top_p': modelConfig.topP,
72-
'aws.bedrock.request.max_tokens': modelConfig.maxTokens
7367
})
7468
}).then(done).catch(done)
7569

0 commit comments

Comments
 (0)