File tree Expand file tree Collapse file tree
packages/dd-trace/test/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,6 +162,33 @@ describe('Config', () => {
162162 } )
163163 } )
164164
165+ describe ( 'property surface' , ( ) => {
166+ // Mirror of the runtime-only fields in `ConfigProperties` (config-types.d.ts).
167+ const INTERNAL_RUNTIME_PROPERTIES = [
168+ 'commitSHA' ,
169+ 'debug' ,
170+ 'isServiceNameInferred' ,
171+ 'repositoryUrl' ,
172+ 'sampler' ,
173+ 'stableConfig' ,
174+ ]
175+
176+ it ( 'does not expose own properties beyond supported-configurations.json and index.d.ts' , ( ) => {
177+ // Top-level segment only: nested defaults (e.g. `foo.bar`) live as `foo` on the instance.
178+ const known = new Set ( Object . keys ( defaults ) . map ( name => name . split ( '.' , 1 ) [ 0 ] ) )
179+ for ( const name of INTERNAL_RUNTIME_PROPERTIES ) {
180+ known . add ( name )
181+ }
182+
183+ const config = getConfig ( )
184+ const unknownConfigurations = Object . keys ( config ) . filter ( name => ! known . has ( name ) )
185+
186+ assert . deepStrictEqual ( unknownConfigurations , [ ] , 'Unknown Config properties detected.\n' +
187+ 'Add it to supported-configurations.json (or index.d.ts), if it truly is a Config property.\n' +
188+ 'Otherwise, remove / handle elsewhere. This reports telemetry about unrecognized properties.' )
189+ } )
190+ } )
191+
165192 it ( 'should initialize its own logging config based off the loggers config' , ( ) => {
166193 process . env . DD_TRACE_DEBUG = 'true'
167194 process . env . DD_TRACE_LOG_LEVEL = 'error'
You can’t perform that action at this time.
0 commit comments