Skip to content

Commit 81cfb02

Browse files
committed
chore: Added a script that generates Dashboard json for reporting on libraries by version, agent version and node.js version
1 parent 6c964b2 commit 81cfb02

File tree

4 files changed

+237
-0
lines changed

4 files changed

+237
-0
lines changed

dashboards/constants.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2024 New Relic Corporation. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
'use strict'
7+
const INSTRUMENTED_LIBRARIES = [
8+
'@apollo/gateway',
9+
'@apollo/server',
10+
'@aws-sdk/client-bedrock-runtime',
11+
'@aws-sdk/client-dynamodb',
12+
'@aws-sdk/client-sns',
13+
'@aws-sdk/client-sqs',
14+
'@aws-sdk/lib-dynamodb',
15+
'@aws-sdk/smithy-client',
16+
'@elastic/elasticsearch',
17+
'@grpc/grpc-js',
18+
'@hapi/hapi',
19+
'@hapi/vision',
20+
'@koa/router',
21+
'@langchain/core',
22+
'@nestjs/cli',
23+
'@nestjs/core',
24+
'@node-redis/client',
25+
'@prisma/client',
26+
'@redis/client',
27+
'@smithy/smithy-client',
28+
'amqplib',
29+
'apollo-server',
30+
'apollo-server-express',
31+
'apollo-server-fastify',
32+
'apollo-server-hapi',
33+
'apollo-server-koa',
34+
'apollo-server-lambda',
35+
'aws-sdk',
36+
'bluebird',
37+
'bunyan',
38+
'cassandra-driver',
39+
'connect',
40+
'director',
41+
'express',
42+
'fastify',
43+
'generic-pool',
44+
'ioredis',
45+
'kafkajs',
46+
'koa',
47+
'koa-route',
48+
'koa-router',
49+
'memcached',
50+
'mongodb',
51+
'mysql',
52+
'mysql2',
53+
'next',
54+
'openai',
55+
'pg',
56+
'pg-native',
57+
'pino',
58+
'q',
59+
'redis',
60+
'restify',
61+
'superagent',
62+
'undici',
63+
'when',
64+
'winston'
65+
]
66+
const MIN_NODE_VERSION = 16
67+
68+
module.exports = {
69+
INSTRUMENTED_LIBRARIES,
70+
MIN_NODE_VERSION
71+
}

dashboards/generate-library-usage.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2024 New Relic Corporation. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
'use strict'
7+
const fs = require('fs/promises')
8+
const { INSTRUMENTED_LIBRARIES, MIN_NODE_VERSION } = require('./constants')
9+
const { makeDashboard, makePage, makeWidget, libraryUsageQuery } = require('./utils')
10+
const REPORT_NAME = process.env.REPORT_NAME || 'library-usage.json'
11+
12+
function makeLibraryWidgets(libs) {
13+
const width = 4
14+
const height = 3
15+
let row = 1
16+
let column = 1
17+
18+
return libs.map((lib, index) => {
19+
const pos = index % height
20+
21+
// on a new row, set column to 1
22+
if (pos === 0) {
23+
column = 1
24+
// add width to column
25+
} else {
26+
column += width
27+
}
28+
29+
// start a new row
30+
if (pos === 0 && index !== 0) {
31+
row += height
32+
}
33+
const query = libraryUsageQuery({ lib, nodeVersion: MIN_NODE_VERSION })
34+
return makeWidget({ title: lib, column, row, width, height, query })
35+
})
36+
}
37+
38+
async function main() {
39+
const widgets = makeLibraryWidgets(INSTRUMENTED_LIBRARIES)
40+
const page = makePage({
41+
name: 'Instrumented Libraries',
42+
description: 'Reports usage by library, agent, and node.js versions',
43+
widgets
44+
})
45+
const dashboard = makeDashboard({ name: 'Node.js Library Usage', pages: [page] })
46+
await fs.writeFile(REPORT_NAME, JSON.stringify(dashboard))
47+
}
48+
49+
main()

0 commit comments

Comments
 (0)