@@ -28,14 +28,6 @@ describe('Config', () => {
2828 const BLOCKED_TEMPLATE_GRAPHQL_PATH = require . resolve ( './fixtures/config/appsec-blocked-graphql-template.json' )
2929 const BLOCKED_TEMPLATE_GRAPHQL = readFileSync ( BLOCKED_TEMPLATE_GRAPHQL_PATH , { encoding : 'utf8' } )
3030 const DD_GIT_PROPERTIES_FILE = require . resolve ( './fixtures/config/git.properties' )
31- const CONFIG_NORM_RULES_PATH = require . resolve ( './fixtures/telemetry/config_norm_rules.json' )
32- const CONFIG_NORM_RULES = readFileSync ( CONFIG_NORM_RULES_PATH , { encoding : 'utf8' } )
33- const CONFIG_PREFIX_BLOCK_LIST_PATH = require . resolve ( './fixtures/telemetry/config_prefix_block_list.json' )
34- const CONFIG_PREFIX_BLOCK_LIST = readFileSync ( CONFIG_PREFIX_BLOCK_LIST_PATH , { encoding : 'utf8' } )
35- const CONFIG_AGGREGATION_LIST_PATH = require . resolve ( './fixtures/telemetry/config_aggregation_list.json' )
36- const CONFIG_AGGREGATION_LIST = readFileSync ( CONFIG_AGGREGATION_LIST_PATH , { encoding : 'utf8' } )
37- const NODEJS_CONFIG_RULES_PATH = require . resolve ( './fixtures/telemetry/nodejs_config_rules.json' )
38- const NODEJS_CONFIG_RULES = readFileSync ( NODEJS_CONFIG_RULES_PATH , { encoding : 'utf8' } )
3931
4032 function reloadLoggerAndConfig ( ) {
4133 log = proxyquire ( '../src/log' , { } )
@@ -2314,76 +2306,5 @@ describe('Config', () => {
23142306 expect ( taggingConfig ) . to . have . property ( 'responsesEnabled' , true )
23152307 expect ( taggingConfig ) . to . have . property ( 'maxDepth' , 7 )
23162308 } )
2317-
2318- it ( 'config_norm_rules completeness' , ( ) => {
2319- // ⚠️ Did this test just fail? Read here! ⚠️
2320- //
2321- // Some files are manually copied from dd-go from/to the following paths
2322- // from: https://github.com/DataDog/dd-go/blob/prod/trace/apps/tracer-telemetry-intake/telemetry-payload/static/
2323- // to: packages/dd-trace/test/fixtures/telemetry/
2324- // files:
2325- // - config_norm_rules.json
2326- // - config_prefix_block_list.json
2327- // - config_aggregation_list.json
2328- // - nodejs_config_rules.json
2329- //
2330- // If this test fails, it means that a telemetry key was found in config.js that does not
2331- // exist in any of the files listed above in dd-go
2332- // The impact is that telemetry will not be reported to the Datadog backend won't be unusable
2333- //
2334- // To fix this, you must update dd-go to either
2335- // 1) Add an exact config key to match config_norm_rules.json
2336- // 2) Add a prefix that matches the config keys to config_prefix_block_list.json
2337- // 3) Add a prefix rule that fits an existing prefix to config_aggregation_list.json
2338- // 4) (Discouraged) Add a language-specific rule to nodejs_config_rules.json
2339- //
2340- // Once dd-go is updated, you can copy over the files to this repo and merge them in as part of your changes
2341-
2342- function getKeysInDotNotation ( obj , parentKey = '' ) {
2343- const keys = [ ]
2344-
2345- for ( const key in obj ) {
2346- if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) {
2347- const fullKey = parentKey ? `${ parentKey } .${ key } ` : key
2348-
2349- if ( typeof obj [ key ] === 'object' && obj [ key ] !== null && ! Array . isArray ( obj [ key ] ) ) {
2350- keys . push ( ...getKeysInDotNotation ( obj [ key ] , fullKey ) )
2351- } else {
2352- keys . push ( fullKey )
2353- }
2354- }
2355- }
2356-
2357- return keys
2358- }
2359-
2360- const config = new Config ( )
2361-
2362- const libraryConfigKeys = getKeysInDotNotation ( config ) . sort ( )
2363-
2364- const nodejsConfigRules = JSON . parse ( NODEJS_CONFIG_RULES )
2365- const configNormRules = JSON . parse ( CONFIG_NORM_RULES )
2366- const configPrefixBlockList = JSON . parse ( CONFIG_PREFIX_BLOCK_LIST )
2367- const configAggregationList = JSON . parse ( CONFIG_AGGREGATION_LIST )
2368-
2369- const allowedConfigKeys = [
2370- ...Object . keys ( configNormRules ) ,
2371- ...Object . keys ( nodejsConfigRules . normalization_rules )
2372- ]
2373- const blockedConfigKeyPrefixes = [ ...configPrefixBlockList , ...nodejsConfigRules . prefix_block_list ]
2374- const configAggregationPrefixes = [
2375- ...Object . keys ( configAggregationList ) ,
2376- ...Object . keys ( nodejsConfigRules . reduce_rules )
2377- ]
2378-
2379- const missingConfigKeys = libraryConfigKeys . filter ( key => {
2380- const isAllowed = allowedConfigKeys . includes ( key )
2381- const isBlocked = blockedConfigKeyPrefixes . some ( prefix => key . startsWith ( prefix ) )
2382- const isReduced = configAggregationPrefixes . some ( prefix => key . startsWith ( prefix ) )
2383- return ! isAllowed && ! isBlocked && ! isReduced
2384- } )
2385-
2386- expect ( missingConfigKeys ) . to . be . empty
2387- } )
23882309 } )
23892310} )
0 commit comments