Skip to content

Commit

Permalink
chore: Added a script that generates Dashboard json for reporting on …
Browse files Browse the repository at this point in the history
…libraries by version (#2267)
  • Loading branch information
bizob2828 authored Jun 12, 2024
1 parent 8bbc8d2 commit d2877c1
Show file tree
Hide file tree
Showing 4 changed files with 1,902 additions and 0 deletions.
71 changes: 71 additions & 0 deletions dashboards/constants.js
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
}
49 changes: 49 additions & 0 deletions dashboards/generate-library-usage.js
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()
Loading

0 comments on commit d2877c1

Please sign in to comment.