-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Added a script that generates Dashboard json for reporting on …
…libraries by version (#2267)
- Loading branch information
Showing
4 changed files
with
1,902 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2024 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict' | ||
const INSTRUMENTED_LIBRARIES = [ | ||
'@apollo/gateway', | ||
'@apollo/server', | ||
'@aws-sdk/client-bedrock-runtime', | ||
'@aws-sdk/client-dynamodb', | ||
'@aws-sdk/client-sns', | ||
'@aws-sdk/client-sqs', | ||
'@aws-sdk/lib-dynamodb', | ||
'@aws-sdk/smithy-client', | ||
'@elastic/elasticsearch', | ||
'@grpc/grpc-js', | ||
'@hapi/hapi', | ||
'@hapi/vision', | ||
'@koa/router', | ||
'@langchain/core', | ||
'@nestjs/cli', | ||
'@nestjs/core', | ||
'@node-redis/client', | ||
'@prisma/client', | ||
'@redis/client', | ||
'@smithy/smithy-client', | ||
'amqplib', | ||
'apollo-server', | ||
'apollo-server-express', | ||
'apollo-server-fastify', | ||
'apollo-server-hapi', | ||
'apollo-server-koa', | ||
'apollo-server-lambda', | ||
'aws-sdk', | ||
'bluebird', | ||
'bunyan', | ||
'cassandra-driver', | ||
'connect', | ||
'director', | ||
'express', | ||
'fastify', | ||
'generic-pool', | ||
'ioredis', | ||
'kafkajs', | ||
'koa', | ||
'koa-route', | ||
'koa-router', | ||
'memcached', | ||
'mongodb', | ||
'mysql', | ||
'mysql2', | ||
'next', | ||
'openai', | ||
'pg', | ||
'pg-native', | ||
'pino', | ||
'q', | ||
'redis', | ||
'restify', | ||
'superagent', | ||
'undici', | ||
'when', | ||
'winston' | ||
] | ||
const MIN_NODE_VERSION = 16 | ||
|
||
module.exports = { | ||
INSTRUMENTED_LIBRARIES, | ||
MIN_NODE_VERSION | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2024 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict' | ||
const fs = require('fs/promises') | ||
const { INSTRUMENTED_LIBRARIES, MIN_NODE_VERSION } = require('./constants') | ||
const { makeDashboard, makePage, makeWidget, libraryUsageQuery } = require('./utils') | ||
const REPORT_NAME = process.env.REPORT_NAME || 'library-usage.json' | ||
|
||
function makeLibraryWidgets(libs) { | ||
const width = 4 | ||
const height = 3 | ||
let row = 1 | ||
let column = 1 | ||
|
||
return libs.map((lib, index) => { | ||
const pos = index % height | ||
|
||
// on a new row, set column to 1 | ||
if (pos === 0) { | ||
column = 1 | ||
// add width to column | ||
} else { | ||
column += width | ||
} | ||
|
||
// start a new row | ||
if (pos === 0 && index !== 0) { | ||
row += height | ||
} | ||
const query = libraryUsageQuery({ lib, nodeVersion: MIN_NODE_VERSION }) | ||
return makeWidget({ title: lib, column, row, width, height, query }) | ||
}) | ||
} | ||
|
||
async function main() { | ||
const widgets = makeLibraryWidgets(INSTRUMENTED_LIBRARIES) | ||
const page = makePage({ | ||
name: 'Instrumented Libraries', | ||
description: 'Reports usage by library, agent, and node.js versions', | ||
widgets | ||
}) | ||
const dashboard = makeDashboard({ name: 'Node.js Library Usage', pages: [page] }) | ||
await fs.writeFile(REPORT_NAME, JSON.stringify(dashboard)) | ||
} | ||
|
||
main() |
Oops, something went wrong.