Skip to content

Commit e531090

Browse files
committed
fix: API Key Logged in Debug Output
1 parent 2e4d793 commit e531090

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict'
2+
3+
const INPUT_TYPE_IMAGE = 'input_image'
4+
const INPUT_TYPE_FILE = 'input_file'
5+
const INPUT_TYPE_TEXT = 'input_text'
6+
7+
const IMAGE_FALLBACK = '[image]'
8+
const FILE_FALLBACK = '[file]'
9+
10+
module.exports = {
11+
INPUT_TYPE_IMAGE,
12+
INPUT_TYPE_FILE,
13+
INPUT_TYPE_TEXT,
14+
IMAGE_FALLBACK,
15+
FILE_FALLBACK
16+
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ class BaseLLMObsWriter {
8686
return `${apiKey}:${site}`
8787
}
8888

89+
_getMaskedRoutingKey (routing) {
90+
const apiKey = routing?.apiKey || this._config.apiKey || ''
91+
const site = routing?.site || this._config.site || ''
92+
const maskedKey = apiKey ? `****${apiKey.slice(-4)}` : ''
93+
return `${maskedKey}:${site}`
94+
}
95+
8996
_getOrCreateBuffer (routingKey, routing) {
9097
if (!this._buffers.has(routingKey)) {
9198
this._buffers.set(routingKey, {
@@ -122,7 +129,7 @@ class BaseLLMObsWriter {
122129
return
123130
}
124131

125-
for (const [routingKey, buffer] of this._buffers) {
132+
for (const [, buffer] of this._buffers) {
126133
if (buffer.events.length === 0) continue
127134

128135
const events = buffer.events
@@ -133,7 +140,7 @@ class BaseLLMObsWriter {
133140
const options = this._getOptions(buffer.routing)
134141
const url = this._getUrlForRouting(buffer.routing)
135142

136-
log.debug('Encoded LLMObs payload for %s: %s', routingKey, payload)
143+
log.debug('Encoded LLMObs payload for %s: %s', this._getMaskedRoutingKey(buffer.routing), payload)
137144

138145
request(payload, options, (err, resp, code) => {
139146
parseResponseAndLog(err, code, events.length, url, this._eventType)

0 commit comments

Comments
 (0)