Skip to content

Commit 15253c0

Browse files
test: Fix long running benchmark test and add shimmer.subscribers benchmark test (#3349)
1 parent 4f12499 commit 15253c0

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

test/benchmark/Readme.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ node ./bin/run-bench.js --filename=your-desired-filename
2727

2828
Our benchmark tests now send metrics to New Relic through the OTLP metrics endpoint.
2929

30-
You must provide a `NEW_RELIC_LICENSE_KEY` (specifically a production user license key) in order for the benchmark metrics to be sent. One way to do this is with a `.env`:
30+
You must provide a `NEW_RELIC_LICENSE_KEY` (specifically an ingest license key) in order for the benchmark metrics to be sent. One way to do this is with a `.env`:
3131

3232
```zsh
33+
# Starting at node-newrelic (root directory)
3334
cd bin
3435
touch .env
35-
# NEW_RELIC_LICENSE_KEY=YOUR_PROD_LICENSE_KEY
36+
# Fill out NEW_RELIC_LICENSE_KEY=YOUR_INGEST_LICENSE_KEY
37+
# If you are sending metrics to production instead of staging (default), also include: NEW_RELIC_METRICS_HOST=otlp.nr-data.net
3638
node --env-file .env ./run-bench.js
3739
```
3840

39-
The metrics are displayed in [Node Agent Benchmark Test Metrics](https://staging.onenr.io/0ERPpA6ZPRW).
41+
The metrics are displayed in [Node Agent Benchmark Test Metrics](https://staging.onenr.io/0ERPpA6ZPRW) (staging).

test/benchmark/shimmer/instrumentation.bench.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
const benchmark = require('../../lib/benchmark')
99
const shimmer = require('../../../lib/shimmer')
1010

11-
const suite = benchmark.createBenchmark({ name: 'shimmer wrapping', delay: 0.01 })
11+
const suite = benchmark.createBenchmark({ name: 'shimmer wrapping' })
1212

1313
suite.add({
1414
name: 'shimmer.registerHooks()',
1515
agent: true,
1616
fn: function (agent) {
1717
return shimmer.registerHooks(agent)
18+
},
19+
after: function() {
20+
return shimmer.removeHooks()
1821
}
1922
})
2023

@@ -30,6 +33,9 @@ suite.add({
3033
agent: true,
3134
fn: function (agent) {
3235
return shimmer.bootstrapInstrumentation(agent)
36+
},
37+
after: function() {
38+
return shimmer.removeHooks()
3339
}
3440
})
3541

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2025 New Relic Corporation. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
'use strict'
7+
8+
const benchmark = require('../../lib/benchmark')
9+
const shimmer = require('../../../lib/shimmer')
10+
11+
const suite = benchmark.createBenchmark({ name: 'shimmer subscribers' })
12+
13+
suite.add({
14+
name: 'shimmer.setupSubscribers()',
15+
agent: true,
16+
fn: function (agent) {
17+
return shimmer.setupSubscribers(agent)
18+
},
19+
})
20+
21+
suite.run()

0 commit comments

Comments
 (0)