Skip to content

Commit 3686699

Browse files
authored
chore(llmobs): update config type to generated types (#7965)
1 parent 70baebd commit 3686699

7 files changed

Lines changed: 24 additions & 9 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ let spanWriter
4343
/** @type {LLMObsEvalMetricsWriter | null} */
4444
let evalWriter
4545

46-
/** @type {import('../config')} */
46+
/** @type {import('../config/config-base')} */
4747
let globalTracerConfig
4848

49+
/**
50+
* @param {@type import('../config/config-base')} config
51+
*/
4952
function enable (config) {
5053
globalTracerConfig = config
5154

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class LLMObs extends NoopLLMObs {
3737
constructor (tracer, llmobsModule, config) {
3838
super(tracer)
3939

40+
/** @type {import('../config/config-base')} */
4041
this._config = config
42+
4143
this._llmobsModule = llmobsModule
4244
this._tagger = new LLMObsTagger(config)
4345
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class LLMObservabilitySpan {
4949
}
5050

5151
class LLMObsSpanProcessor {
52-
/** @type {import('../config')} */
52+
/** @type {import('../config/config-base')} */
5353
#config
5454

5555
/** @type {((span: LLMObservabilitySpan) => LLMObservabilitySpan | null) | null} */

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ const { storage } = require('./storage')
4747
const registry = new WeakMap()
4848

4949
class LLMObsTagger {
50+
/** @type {import('../config/config-base')} */
51+
#config
52+
5053
constructor (config, softFail = false) {
51-
this._config = config
54+
this.#config = config
5255

5356
this.softFail = softFail
5457
}
@@ -72,15 +75,15 @@ class LLMObsTagger {
7275
integration,
7376
_decorator,
7477
} = {}) {
75-
if (!this._config.llmobs.enabled) return
78+
if (!this.#config.llmobs.enabled) return
7679
if (!kind) return // do not register it in the map if it doesn't have an llmobs span kind
7780

7881
const spanMlApp =
7982
mlApp ||
8083
registry.get(parent)?.[ML_APP] ||
8184
span.context()._trace.tags[PROPAGATED_ML_APP_KEY] ||
82-
this._config.llmobs.mlApp ||
83-
this._config.service // this should always have a default
85+
this.#config.llmobs.mlApp ||
86+
this.#config.service // this should always have a default
8487

8588
if (!spanMlApp) {
8689
throw new Error(
@@ -624,7 +627,7 @@ class LLMObsTagger {
624627
}
625628

626629
_register (span) {
627-
if (!this._config.llmobs.enabled) return
630+
if (!this.#config.llmobs.enabled) return
628631
if (registry.has(span)) {
629632
this.#handleFailure(`LLMObs Span "${span._name}" already registered.`)
630633
return
@@ -634,7 +637,7 @@ class LLMObsTagger {
634637
}
635638

636639
_setTag (span, key, value) {
637-
if (!this._config.llmobs.enabled) return
640+
if (!this.#config.llmobs.enabled) return
638641
if (!registry.has(span)) {
639642
this.#handleFailure(`Span "${span._name}" must be an LLMObs generated span.`)
640643
return

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class BaseLLMObsWriter {
4545
/** @type {LLMObsBuffer} */
4646
this._buffer = new LLMObsBuffer({ events: [], size: 0, isDefault: true })
4747

48+
/** @type {import('../../config/config-base')} */
4849
this._config = config
50+
4951
this._endpoint = endpoint
5052
this._baseEndpoint = endpoint // should not be unset
5153
this._intake = intake

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const telemetry = require('../telemetry')
66
const { fetchAgentInfo } = require('../../agent/info')
77
const { getAgentUrl } = require('../../agent/url')
88

9+
/**
10+
* @param {import('../../config/config-base')} config
11+
*/
912
function setAgentStrategy (config, setWritersAgentlessValue) {
1013
const agentlessEnabled = config.llmobs.agentlessEnabled
1114

packages/dd-trace/src/plugins/plugin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,16 @@ module.exports = class Plugin {
7272
* Create a new plugin instance.
7373
*
7474
* @param {object} tracer Tracer instance or wrapper containing it under `_tracer`.
75-
* @param {object} tracerConfig Global tracer configuration object.
75+
* @param {import('../config/config-base')} tracerConfig Global tracer configuration object.
7676
*/
7777
constructor (tracer, tracerConfig) {
7878
this._subscriptions = []
7979
this._bindings = []
8080
this._enabled = false
8181
this._tracer = tracer
8282
this.config = {} // plugin-specific configuration, unset until .configure() is called
83+
84+
/** @type {import('../config/config-base')} */
8385
this._tracerConfig = tracerConfig // global tracer configuration
8486
}
8587

0 commit comments

Comments
 (0)