Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@
/packages/dd-trace/test/tagger.spec.js @DataDog/apm-sdk-capabilities-js
/packages/dd-trace/test/tracer.spec.js @DataDog/apm-sdk-capabilities-js

/scripts/generate-config-types.js @DataDog/apm-sdk-capabilities-js

# Feature Flagging
/integration-tests/openfeature/ @DataDog/feature-flagging
/packages/dd-trace/src/openfeature/ @DataDog/feature-flagging
Expand Down
7 changes: 7 additions & 0 deletions packages/dd-trace/src/config/config-base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ConfigProperties } from './config-types'

declare class ConfigBase {}

interface ConfigBase extends ConfigProperties {}

export = ConfigBase
5 changes: 5 additions & 0 deletions packages/dd-trace/src/config/config-base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict'

class ConfigBase {}

module.exports = ConfigBase
78 changes: 78 additions & 0 deletions packages/dd-trace/src/config/config-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import type { GeneratedConfig } from './generated-config-types'

type PayloadTaggingRules = ReturnType<typeof import('../payload-tagging/config').appendRules> | []

export interface ConfigProperties extends GeneratedConfig {
cloudPayloadTagging: GeneratedConfig['cloudPayloadTagging'] & {
requestsEnabled: boolean
responsesEnabled: boolean
rules: PayloadTaggingRules
}
commitSHA: string | undefined
debug: boolean
gcpPubSubPushSubscriptionEnabled: boolean
instrumentationSource: 'manual' | 'ssi'
isAzureFunction: boolean
isCiVisibility: boolean
isGCPFunction: boolean
isServiceNameInferred: boolean
isServiceUserProvided: boolean
logger: import('../../../../index').TracerOptions['logger'] | undefined
lookup: NonNullable<import('../../../../index').TracerOptions['lookup']>
readonly parsedDdTags: Record<string, string>
plugins: boolean
repositoryUrl: string | undefined
rules: import('../../../../index').SamplingRule[]
sampler: {
rateLimit: number
rules: import('../../../../index').SamplingRule[]
sampleRate: number | undefined
spanSamplingRules: import('../../../../index').SpanSamplingRule[] | undefined
}
stableConfig: {
fleetEntries: Record<string, string>
localEntries: Record<string, string>
warnings: string[] | undefined
}
tracePropagationStyle: GeneratedConfig['tracePropagationStyle']
}

type Primitive = bigint | boolean | null | number | string | symbol | undefined
type Terminal = Date | Function | Primitive | RegExp | URL

type KnownStringKeys<T> = Extract<{
[K in keyof T]:
K extends string
? string extends K
? never
: K
: never
}[keyof T], string>

type NestedConfigPath<T> = [NonNullable<T>] extends [Terminal]
? never
: [NonNullable<T>] extends [readonly unknown[]]
? never
: [NonNullable<T>] extends [object]
? ConfigPathFor<NonNullable<T>>
: never

type ConfigPathFor<T> = {
[K in KnownStringKeys<T>]:
| K
| (NestedConfigPath<T[K]> extends never ? never : `${K}.${NestedConfigPath<T[K]>}`)
}[KnownStringKeys<T>]

type ConfigPathValueFor<T, TPath extends string> =
TPath extends `${infer TKey}.${infer TRest}`
? TKey extends KnownStringKeys<T>
? ConfigPathValueFor<NonNullable<T[TKey]>, TRest>
: never
: TPath extends KnownStringKeys<T>
? T[TPath]
: never

export type ConfigKey = KnownStringKeys<ConfigProperties>
export type ConfigPath = ConfigPathFor<ConfigProperties>
export type ConfigPathValue<TPath extends ConfigPath> = ConfigPathValueFor<ConfigProperties, TPath>
export type ConfigDefaults = Partial<{ [TPath in ConfigPath]: ConfigPathValue<TPath> }>
Loading
Loading