Skip to content

Commit 7209b4f

Browse files
authored
chore: use generated config types as much as possible (#7955)
This adds the now auto generated config types to as many consumers as possible. Types should now always be correct. There could be additional consumers that would also profit, this is just a best effort approach for adding them to the consumers. The plugin_manager tests were rewritten to reflect the actual config changes properly.
1 parent a89b832 commit 7209b4f

24 files changed

Lines changed: 122 additions & 47 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ class AIGuard extends NoopAIGuard {
5757
#maxContentSize
5858
#meta
5959

60+
/**
61+
* @param {import('../tracer')} tracer - Tracer instance
62+
* @param {import('../config/config-base')} config - Tracer configuration
63+
*/
6064
constructor (tracer, config) {
6165
super()
6266

packages/dd-trace/src/appsec/blocking.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ function getBlockingAction (actions) {
164164
return actions?.redirect_request || actions?.block_request
165165
}
166166

167+
/**
168+
* @param {import('../config/config-base')} config - Tracer configuration
169+
*/
167170
function setTemplates (config) {
168171
templateHtml = config.appsec.blockedTemplateHtml || blockedTemplates.html
169172

packages/dd-trace/src/appsec/sdk/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class EventTrackingV2 {
2626
}
2727

2828
class AppsecSdk {
29+
/**
30+
* @param {import('../../tracer')} tracer - Tracer instance
31+
* @param {import('../../config/config-base')} config - Tracer configuration
32+
*/
2933
constructor (tracer, config) {
3034
this._tracer = tracer
3135
if (config) {

packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ class TestApiManualPlugin extends CiPlugin {
5454
})
5555
}
5656

57+
/**
58+
* @param {import('../../config/config-base')} config - Tracer configuration
59+
* @param {boolean} shouldGetEnvironmentData - Whether to get environment data
60+
*/
5761
configure (config, shouldGetEnvironmentData) {
5862
this._config = config
5963
super.configure(config, shouldGetEnvironmentData)

packages/dd-trace/src/crashtracking/crashtracker.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class Crashtracker {
2323
}
2424
}
2525

26+
/**
27+
* @param {import('../config/config-base')} config - Tracer configuration
28+
*/
2629
start (config) {
2730
if (this.#started) return this.configure(config)
2831

@@ -35,7 +38,7 @@ class Crashtracker {
3538
this.#getMetadata(config)
3639
)
3740
} catch (e) {
38-
log.error('Error initialising crashtracker', e)
41+
log.error('Error initializing crashtracker', e)
3942
}
4043
}
4144

@@ -49,6 +52,9 @@ class Crashtracker {
4952
}
5053

5154
// TODO: Send only configured values when defaults are fixed.
55+
/**
56+
* @param {import('../config/config-base')} config - Tracer configuration
57+
*/
5258
#getConfig (config) {
5359
const url = getAgentUrl(config)
5460

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function start (config, rcInstance) {
147147
* Sends the new configuration to the worker thread via the config channel.
148148
* Does nothing if the worker is not started.
149149
*
150-
* @param {Config} config - The updated tracer configuration object
150+
* @param {import('../config/config-base')} config - The updated tracer configuration object
151151
*/
152152
function configure (config) {
153153
if (configChannel === null) return

packages/dd-trace/src/heap_snapshots.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ function getName (destination) {
4545
}
4646

4747
module.exports = {
48+
/**
49+
* @param {import('./config/config-base')} config - Tracer configuration
50+
*/
4851
async start (config) {
4952
const destination = config.heapSnapshot.destination
5053

packages/dd-trace/src/opentelemetry/logs/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const OtlpHttpLogExporter = require('./otlp_http_log_exporter')
3333

3434
/**
3535
* Initializes OpenTelemetry Logs support
36-
* @param {Config} config - Tracer configuration instance
36+
* @param {import('../../config/config-base')} config - Tracer configuration instance
3737
*/
3838
function initializeOpenTelemetryLogs (config) {
3939
// Build resource attributes

packages/dd-trace/src/opentelemetry/metrics/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const OtlpHttpMetricExporter = require('./otlp_http_metric_exporter')
3535

3636
/**
3737
* Initializes OpenTelemetry Metrics support
38-
* @param {Config} config - Tracer configuration instance
38+
* @param {import('../../config/config-base')} config - Tracer configuration instance
3939
*/
4040
function initializeOpenTelemetryMetrics (config) {
4141
const resourceAttributes = {

packages/dd-trace/src/payload-tagging/config/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
const aws = require('./aws.json')
44
const sdks = { aws }
55

6+
/** @typedef {Record<string, { request: string[], response: string[], expand: string[] }>} SDKRules */
67
/**
78
* Builds rules per service for a given SDK, appending user-provided rules.
89
*
9-
* @param {Record<string, { request: string[], response: string[], expand: string[] }>} sdk
10+
* @param {SDKRules} sdk
1011
* @param {string[]} requestInput
1112
* @param {string[]} responseInput
12-
* @returns {Record<string, { request: string[], response: string[], expand: string[] }>}
13+
* @returns {SDKRules}
1314
*/
1415
function getSDKRules (sdk, requestInput, responseInput) {
15-
const sdkServiceRules = {}
16+
const sdkServiceRules = /** @type {SDKRules} */ ({})
1617
for (const [service, serviceRules] of Object.entries(sdk)) {
1718
sdkServiceRules[service] = {
1819
// Make a copy. Otherwise calling the function multiple times would append
@@ -31,10 +32,10 @@ function getSDKRules (sdk, requestInput, responseInput) {
3132
*
3233
* @param {string[]} [requestInput=[]]
3334
* @param {string[]} [responseInput=[]]
34-
* @returns {Record<string, Record<string, { request: string[], response: string[], expand: string[] }>>}
35+
* @returns {Record<string, SDKRules>}
3536
*/
3637
function appendRules (requestInput = [], responseInput = []) {
37-
const sdkRules = {}
38+
const sdkRules = /** @type {Record<string, SDKRules>} */ ({})
3839
for (const [name, sdk] of Object.entries(sdks)) {
3940
sdkRules[name] = getSDKRules(sdk, requestInput, responseInput)
4041
}

0 commit comments

Comments
 (0)