Skip to content

Commit 1f4d857

Browse files
authored
chore: update dependencies & dependabot & less cache lookups (#6041)
* chore: update lru-cache, less lookups, dependabot ignore update This updates the lru-cache to the latest version that supports Node.js 18. The version above is ignored in dependabot. It also ignores path-to-regexp, since that has to stay aligned with the one used in express.js v4. Express itself is updated as dev dependencies. That way we should notice earlier in case more things break. The cache lookups got a bit optimized to not have to check multiple times if an entry exists or not. * chore: outcommend alternative in docker-compose Only one should be used per port.
1 parent e7cf286 commit 1f4d857

File tree

12 files changed

+205
-254
lines changed

12 files changed

+205
-254
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ updates:
3131
- dependency-name: "jest-docblock"
3232
# 30.0.0 onwards only supports Node.js 18.14.x and above
3333
update-types: ["version-update:semver-major"]
34+
# The path-to-regexp version has to be the same as used in express v4.
35+
# Consider vendoring it instead.
36+
- dependency-name: "path-to-regexp"
37+
- dependency-name: "lru-cache"
38+
# 11.0.0 onwards only supports Node.js 20 and above
39+
update-types: ["version-update:semver-major"]
3440
groups:
3541
dev-minor-and-patch-dependencies:
3642
dependency-type: "development"

.github/workflows/platform.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ jobs:
296296
version: ${{ matrix.version }}
297297
- uses: ./.github/actions/install
298298
- run: yarn add --ignore-scripts mocha@10 # Use older mocha to support old Node.js versions
299+
- run: yarn add --ignore-scripts express@4 # Use older express to support old Node.js versions
299300
- run: node node_modules/.bin/mocha --colors --timeout 30000 integration-tests/init.spec.js
300301

301302
integration-guardrails-unsupported:

docker-compose.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ services:
165165

166166
# Use this for local development when making new VCR cassettes to persist to the test agent
167167
# Do not use the above testagent service if using this one.
168-
testagent-vcr:
169-
image: ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.24.1
170-
ports:
171-
- "127.0.0.1:9126:9126"
172-
environment:
173-
- LOG_LEVEL=DEBUG
174-
- TRACE_LANGUAGE=javascript
175-
- ENABLED_CHECKS=trace_stall,meta_tracer_version_header,trace_count_header,trace_peer_service
176-
- PORT=9126
177-
volumes:
178-
- ${VCR_CASSETTES_PATH:-/tmp/empty-vcr}:/vcr-cassettes:delegated
168+
# testagent-vcr:
169+
# image: ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.24.1
170+
# ports:
171+
# - "127.0.0.1:9126:9126"
172+
# environment:
173+
# - LOG_LEVEL=DEBUG
174+
# - TRACE_LANGUAGE=javascript
175+
# - ENABLED_CHECKS=trace_stall,meta_tracer_version_header,trace_count_header,trace_peer_service
176+
# - PORT=9126
177+
# volumes:
178+
# - ${VCR_CASSETTES_PATH:-/tmp/empty-vcr}:/vcr-cassettes:delegated

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,18 @@
9797
"@opentelemetry/core": "^1.14.0",
9898
"crypto-randomuuid": "^1.0.0",
9999
"dc-polyfill": "^0.1.9",
100-
"ignore": "^5.2.4",
100+
"ignore": "^7.0.5",
101101
"import-in-the-middle": "^1.14.2",
102102
"istanbul-lib-coverage": "^3.2.2",
103103
"jest-docblock": "^29.7.0",
104104
"jsonpath-plus": "^10.3.0",
105105
"koalas": "^1.0.2",
106-
"limiter": "^1.1.5",
106+
"limiter": "^3.0.0",
107107
"lodash.sortby": "^4.7.0",
108-
"lru-cache": "^7.18.3",
108+
"lru-cache": "^10.4.3",
109109
"module-details-from-path": "^1.0.4",
110110
"mutexify": "^1.4.0",
111-
"opentracing": ">=0.12.1",
111+
"opentracing": ">=0.14.7",
112112
"path-to-regexp": "^0.1.12",
113113
"pprof-format": "^2.1.0",
114114
"protobufjs": "^7.5.3",
@@ -138,7 +138,7 @@
138138
"eslint-plugin-n": "^17.20.0",
139139
"eslint-plugin-promise": "^7.2.1",
140140
"eslint-plugin-unicorn": "^59.0.1",
141-
"express": "^4.21.2",
141+
"express": "^5.1.0",
142142
"get-port": "^5.1.1",
143143
"glob": "^7.2.3",
144144
"globals": "^15.15.0",

packages/dd-trace/src/appsec/iast/overhead-controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const LRUCache = require('lru-cache')
3+
const { LRUCache } = require('lru-cache')
44
const web = require('../../plugins/util/web')
55
const vulnerabilities = require('./vulnerabilities')
66

packages/dd-trace/src/appsec/iast/vulnerability-reporter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const LRU = require('lru-cache')
3+
const { LRUCache } = require('lru-cache')
44
const vulnerabilitiesFormatter = require('./vulnerabilities-formatter')
55
const { IAST_ENABLED_TAG_KEY, IAST_JSON_TAG_KEY } = require('./tags')
66
const { keepTrace } = require('../../priority_sampler')
@@ -10,7 +10,7 @@ const { ASM } = require('../../standalone/product')
1010

1111
const VULNERABILITIES_KEY = 'vulnerabilities'
1212
const VULNERABILITY_HASHES_MAX_SIZE = 1000
13-
const VULNERABILITY_HASHES = new LRU({ max: VULNERABILITY_HASHES_MAX_SIZE })
13+
const VULNERABILITY_HASHES = new LRUCache({ max: VULNERABILITY_HASHES_MAX_SIZE })
1414
const RESET_VULNERABILITY_CACHE_INTERVAL = 60 * 60 * 1000 // 1 hour
1515

1616
let tracer

packages/dd-trace/src/datastreams/pathway.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
// this inconsistency is ok because hashes do not need to be consistent across services
44
const crypto = require('crypto')
55
const { encodeVarint, decodeVarint } = require('./encoding')
6-
const LRUCache = require('lru-cache')
6+
const { LRUCache } = require('lru-cache')
77
const log = require('../log')
88
const pick = require('../../../datadog-core/src/utils/src/pick')
99

10-
const options = { max: 500 }
11-
const cache = new LRUCache(options)
10+
const cache = new LRUCache({ max: 500 })
1211

1312
const CONTEXT_PROPAGATION_KEY = 'dd-pathway-ctx'
1413
const CONTEXT_PROPAGATION_KEY_BASE64 = 'dd-pathway-ctx-base64'
@@ -24,15 +23,16 @@ function computeHash (service, env, edgeTags, parentHash) {
2423
edgeTags.sort()
2524
const hashableEdgeTags = edgeTags.filter(item => item !== 'manual_checkpoint:true')
2625

27-
const key = `${service}${env}` + hashableEdgeTags.join('') + parentHash.toString()
28-
if (cache.get(key)) {
29-
return cache.get(key)
26+
const key = `${service}${env}${hashableEdgeTags.join('')}${parentHash}`
27+
let value = cache.get(key)
28+
if (value) {
29+
return value
3030
}
3131
const currentHash = shaHash(`${service}${env}` + hashableEdgeTags.join(''))
3232
const buf = Buffer.concat([currentHash, parentHash], 16)
33-
const val = shaHash(buf.toString())
34-
cache.set(key, val)
35-
return val
33+
value = shaHash(buf.toString())
34+
cache.set(key, value)
35+
return value
3636
}
3737

3838
function encodePathwayContext (dataStreamsContext) {

packages/dd-trace/src/datastreams/processor.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,14 @@ class StatsBucket {
7878
return this._backlogs
7979
}
8080

81-
forCheckpoint (checkpoint) {
82-
const key = checkpoint.hash
83-
if (!this._checkpoints.has(key)) {
84-
this._checkpoints.set(
85-
key, new StatsPoint(checkpoint.hash, checkpoint.parentHash, checkpoint.edgeTags)
86-
)
81+
forCheckpoint ({ hash, parentHash, edgeTags }) {
82+
let checkpoint = this._checkpoints.get(hash)
83+
if (!checkpoint) {
84+
checkpoint = new StatsPoint(hash, parentHash, edgeTags)
85+
this._checkpoints.set(hash, checkpoint)
8786
}
8887

89-
return this._checkpoints.get(key)
88+
return checkpoint
9089
}
9190

9291
/**

packages/dd-trace/src/datastreams/schemas/schema_builder.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const LRUCache = require('lru-cache')
1+
const { LRUCache } = require('lru-cache')
22
const { fnv64 } = require('../fnv')
33
const { Schema } = require('./schema')
44

@@ -25,10 +25,12 @@ class SchemaBuilder {
2525
}
2626

2727
static getSchema (schemaName, iterator, builder) {
28-
if (!CACHE.has(schemaName)) {
29-
CACHE.set(schemaName, (builder ?? new SchemaBuilder(iterator)).build())
28+
let entry = CACHE.get(schemaName)
29+
if (!entry) {
30+
entry = (builder ?? new SchemaBuilder(iterator)).build()
31+
CACHE.set(schemaName, entry)
3032
}
31-
return CACHE.get(schemaName)
33+
return entry
3234
}
3335

3436
build () {

packages/dd-trace/src/rate_limiter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const limiter = require('limiter')
55
class RateLimiter {
66
constructor (rateLimit, interval = 'second') {
77
this._rateLimit = Number.parseInt(rateLimit)
8-
this._limiter = new limiter.RateLimiter(this._rateLimit, interval)
8+
this._limiter = new limiter.RateLimiter({ tokensPerInterval: this._rateLimit, interval })
99
this._tokensRequested = 0
1010
this._prevIntervalTokens = 0
1111
this._prevTokensRequested = 0

0 commit comments

Comments
 (0)