Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Added a script that generates Dashboard json for reporting on libraries by version #2267

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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