Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sabrenner committed Oct 29, 2024
1 parent 05533cb commit 9ac9172
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 54 deletions.
10 changes: 0 additions & 10 deletions packages/dd-trace/src/llmobs/channels.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,9 @@ module.exports = {
OUTPUT_MESSAGES: '_ml_obs.meta.output.messages',
OUTPUT_VALUE: '_ml_obs.meta.output.value',

EVP_PROXY_AGENT_BASE_PATH: 'evp_proxy/v2',
EVP_PROXY_AGENT_ENDPOINT: 'evp_proxy/v2/api/v2/llmobs',
EVP_SUBDOMAIN_HEADER_NAME: 'X-Datadog-EVP-Subdomain',
EVP_SUBDOMAIN_HEADER_VALUE: 'llmobs-intake',
AGENTLESS_SPANS_ENDPOINT: '/api/v2/llmobs',
AGENTLESS_EVALULATIONS_ENDPOINT: '/api/intake/llm-obs/v1/eval-metric',

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

DROPPED_IO_COLLECTION_ERROR: 'dropped_io',
DROPPED_VALUE_TEXT: "[This value has been dropped because this span's size exceeds the 1MB size limit.]",
UNSERIALIZABLE_VALUE_TEXT: 'Unserializable value',

INPUT_TOKENS_METRIC_KEY: 'input_tokens',
OUTPUT_TOKENS_METRIC_KEY: 'output_tokens',
TOTAL_TOKENS_METRIC_KEY: 'total_tokens'
TOTAL_TOKENS_METRIC_KEY: 'total_tokens',

DROPPED_IO_COLLECTION_ERROR: 'dropped_io'
}
6 changes: 6 additions & 0 deletions packages/dd-trace/src/llmobs/constants/text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict'

module.exports = {
DROPPED_VALUE_TEXT: "[This value has been dropped because this span's size exceeds the 1MB size limit.]",
UNSERIALIZABLE_VALUE_TEXT: 'Unserializable value'
}
13 changes: 13 additions & 0 deletions packages/dd-trace/src/llmobs/constants/writers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

module.exports = {
EVP_PROXY_AGENT_BASE_PATH: 'evp_proxy/v2',
EVP_PROXY_AGENT_ENDPOINT: 'evp_proxy/v2/api/v2/llmobs',
EVP_SUBDOMAIN_HEADER_NAME: 'X-Datadog-EVP-Subdomain',
EVP_SUBDOMAIN_HEADER_VALUE: 'llmobs-intake',
AGENTLESS_SPANS_ENDPOINT: '/api/v2/llmobs',
AGENTLESS_EVALULATIONS_ENDPOINT: '/api/intake/llm-obs/v1/eval-metric',

EVP_PAYLOAD_SIZE_LIMIT: 5 << 20, // 5MB (actual limit is 5.1MB)
EVP_EVENT_SIZE_LIMIT: (1 << 20) - 1024 // 999KB (actual limit is 1MB)
}
14 changes: 7 additions & 7 deletions packages/dd-trace/src/llmobs/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict'

const log = require('../log')
const { PROPAGATED_PARENT_ID_KEY } = require('./constants')
const { PROPAGATED_PARENT_ID_KEY } = require('./constants/tags')
const { storage } = require('../../../datadog-core')

const LLMObsSpanProcessor = require('./span_processor')

const {
injectCh,
spanProcessCh,
evalMetricAppendCh,
flushCh
} = require('./channels')
const { channel } = require('dc-polyfill')
const spanProcessCh = channel('dd-trace:span:process')
const evalMetricAppendCh = channel('llmobs:eval-metric:append')
const flushCh = channel('llmobs:writers:flush')
const injectCh = channel('dd-trace:span:inject')

const LLMObsAgentlessSpanWriter = require('./writers/spans/agentless')
const LLMObsAgentProxySpanWriter = require('./writers/spans/agentProxy')
const LLMObsEvalMetricsWriter = require('./writers/evaluations')
Expand Down
6 changes: 4 additions & 2 deletions packages/dd-trace/src/llmobs/sdk.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { SPAN_KIND, OUTPUT_VALUE } = require('./constants')
const { SPAN_KIND, OUTPUT_VALUE } = require('./constants/tags')

const {
getFunctionArguments,
Expand All @@ -19,7 +19,9 @@ const logger = require('../log')
const LLMObsTagger = require('./tagger')

// communicating with writer
const { flushCh, evalMetricAppendCh } = require('./channels')
const { channel } = require('dc-polyfill')
const evalMetricAppendCh = channel('llmobs:eval-metric:append')
const flushCh = channel('llmobs:writers:flush')
const NoopLLMObs = require('./noop')

class LLMObs extends NoopLLMObs {
Expand Down
6 changes: 3 additions & 3 deletions packages/dd-trace/src/llmobs/span_processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const {
TAGS,
PARENT_ID_KEY,
SESSION_ID,
NAME,
UNSERIALIZABLE_VALUE_TEXT
} = require('./constants')
NAME
} = require('./constants/tags')
const { UNSERIALIZABLE_VALUE_TEXT } = require('./constants/text')

const {
ERROR_MESSAGE,
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/llmobs/tagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const {
INPUT_TOKENS_METRIC_KEY,
OUTPUT_TOKENS_METRIC_KEY,
TOTAL_TOKENS_METRIC_KEY
} = require('./constants')
} = require('./constants/tags')

// global registry of LLMObs spans
// maps LLMObs spans to their annotations
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/llmobs/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { SPAN_KINDS } = require('./constants')
const { SPAN_KINDS } = require('./constants/tags')

function encodeUnicode (str) {
if (!str) return str
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/llmobs/writers/evaluations.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { AGENTLESS_EVALULATIONS_ENDPOINT } = require('../constants')
const { AGENTLESS_EVALULATIONS_ENDPOINT } = require('../constants/writers')
const BaseWriter = require('./base')

class LLMObsEvalMetricsWriter extends BaseWriter {
Expand Down
6 changes: 5 additions & 1 deletion packages/dd-trace/src/llmobs/writers/spans/agentProxy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
'use strict'

const { EVP_SUBDOMAIN_HEADER_NAME, EVP_SUBDOMAIN_HEADER_VALUE, EVP_PROXY_AGENT_ENDPOINT } = require('../../constants')
const {
EVP_SUBDOMAIN_HEADER_NAME,
EVP_SUBDOMAIN_HEADER_VALUE,
EVP_PROXY_AGENT_ENDPOINT
} = require('../../constants/writers')
const LLMObsBaseSpanWriter = require('./base')

class LLMObsAgentProxySpanWriter extends LLMObsBaseSpanWriter {
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/llmobs/writers/spans/agentless.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { AGENTLESS_SPANS_ENDPOINT } = require('../../constants')
const { AGENTLESS_SPANS_ENDPOINT } = require('../../constants/writers')
const LLMObsBaseSpanWriter = require('./base')

class LLMObsAgentlessSpanWriter extends LLMObsBaseSpanWriter {
Expand Down
9 changes: 3 additions & 6 deletions packages/dd-trace/src/llmobs/writers/spans/base.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
'use strict'

const {
EVP_EVENT_SIZE_LIMIT,
EVP_PAYLOAD_SIZE_LIMIT,
DROPPED_VALUE_TEXT,
DROPPED_IO_COLLECTION_ERROR
} = require('../../constants')
const { EVP_EVENT_SIZE_LIMIT, EVP_PAYLOAD_SIZE_LIMIT } = require('../../constants/writers')
const { DROPPED_VALUE_TEXT } = require('../../constants/text')
const { DROPPED_IO_COLLECTION_ERROR } = require('../../constants/tags')
const BaseWriter = require('../base')
const logger = require('../../../log')

Expand Down
13 changes: 7 additions & 6 deletions packages/dd-trace/test/llmobs/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict'

const proxyquire = require('proxyquire')
const {
injectCh,
evalMetricAppendCh,
spanProcessCh,
flushCh
} = require('../../src/llmobs/channels')

const { channel } = require('dc-polyfill')
const spanProcessCh = channel('dd-trace:span:process')
const evalMetricAppendCh = channel('llmobs:eval-metric:append')
const flushCh = channel('llmobs:writers:flush')
const injectCh = channel('dd-trace:span:inject')

const LLMObsEvalMetricsWriter = require('../../src/llmobs/writers/evaluations')

const config = {
Expand Down

0 comments on commit 9ac9172

Please sign in to comment.