Skip to content

Commit

Permalink
fix: remaining instances
Browse files Browse the repository at this point in the history
  • Loading branch information
amychisholm03 committed Sep 10, 2024
1 parent f82ece5 commit 3017697
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 44 deletions.
4 changes: 2 additions & 2 deletions test/integration/collector-remote-method.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const url = require('url')
const collector = require('../lib/fake-collector')
const RemoteMethod = require('../../lib/collector/remote-method')
const NAMES = require('../../lib/metrics/names')
require('../lib/metrics_helper')
const { assertMetricValues } = require('../lib/metrics_helper')
const { instrumentMockedAgent, unloadAgent } = require('../lib/agent_helper')
const { SSL_HOST } = require('../lib/agent_helper')

Expand Down Expand Up @@ -176,7 +176,7 @@ tap.test('record data usage supportability metrics', (t) => {
method.invoke(payload, resolve)
})

t.assertMetricValues(
assertMetricValues(
{
metrics: agent.metrics
},
Expand Down
12 changes: 6 additions & 6 deletions test/integration/instrumentation/fetch.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ tap.test('fetch', { skip: semver.lte(process.version, '18.0.0') }, function (t)
})
t.equal(status, 200)

t.assertSegments(tx.trace.root, [`External/${HOST}/post`], { exact: false })
metrics.assertSegments(tx.trace.root, [`External/${HOST}/post`], { exact: false })
tx.end()
t.end()
})
Expand Down Expand Up @@ -152,7 +152,7 @@ tap.test('fetch', { skip: semver.lte(process.version, '18.0.0') }, function (t)
const [{ status }, { status: status2 }] = await Promise.all([req1, req2])
t.equal(status, 200)
t.equal(status2, 200)
t.assertSegments(tx.trace.root, [`External/${HOST}/post`, `External/${HOST}/put`], {
metrics.assertSegments(tx.trace.root, [`External/${HOST}/post`, `External/${HOST}/put`], {
exact: false
})
tx.end()
Expand All @@ -168,7 +168,7 @@ tap.test('fetch', { skip: semver.lte(process.version, '18.0.0') }, function (t)
})
} catch (err) {
t.equal(err.message, 'fetch failed')
t.assertSegments(tx.trace.root, ['External/invalidurl/foo'], { exact: false })
metrics.assertSegments(tx.trace.root, ['External/invalidurl/foo'], { exact: false })
t.equal(tx.exceptions.length, 1)
tx.end()
t.end()
Expand All @@ -188,7 +188,7 @@ tap.test('fetch', { skip: semver.lte(process.version, '18.0.0') }, function (t)
}, 100)
await req
} catch (err) {
t.assertSegments(tx.trace.root, [`External/${HOST}/delay/1000`], { exact: false })
metrics.assertSegments(tx.trace.root, [`External/${HOST}/delay/1000`], { exact: false })
t.equal(tx.exceptions.length, 1)
t.equal(tx.exceptions[0].error.name, 'AbortError')
tx.end()
Expand All @@ -215,7 +215,7 @@ tap.test('fetch', { skip: semver.lte(process.version, '18.0.0') }, function (t)
try {
await req
} catch (error) {
t.assertSegments(transaction.trace.root, [`External/localhost:${port}/`], {
metrics.assertSegments(transaction.trace.root, [`External/localhost:${port}/`], {
exact: false
})

Expand All @@ -236,7 +236,7 @@ tap.test('fetch', { skip: semver.lte(process.version, '18.0.0') }, function (t)
helper.runInTransaction(agent, async (tx) => {
const { status } = await fetch(`${REQUEST_URL}/status/400`)
t.equal(status, 400)
t.assertSegments(tx.trace.root, [`External/${HOST}/status/400`], { exact: false })
metrics.assertSegments(tx.trace.root, [`External/${HOST}/status/400`], { exact: false })
tx.end()
t.end()
})
Expand Down
24 changes: 12 additions & 12 deletions test/versioned/amqplib/amqp-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ function verifySubscribe(t, tx, exchange, routingKey) {
]
}

t.assertSegments(tx.trace.root, segments)
metrics.assertSegments(tx.trace.root, segments)

t.assertMetrics(
metrics.assertMetrics(
tx.metrics,
[[{ name: 'MessageBroker/RabbitMQ/Exchange/Produce/Named/' + exchange }]],
false,
Expand Down Expand Up @@ -108,7 +108,7 @@ function verifyDistributedTrace(t, produceTransaction, consumeTransaction) {

function verifyConsumeTransaction(t, tx, exchange, queue, routingKey) {
t.doesNotThrow(function () {
t.assertMetrics(
metrics.assertMetrics(
tx.metrics,
[
[{ name: 'OtherTransaction/Message/RabbitMQ/Exchange/Named/' + exchange }],
Expand Down Expand Up @@ -147,9 +147,9 @@ function verifyConsumeTransaction(t, tx, exchange, queue, routingKey) {
}

function verifySendToQueue(t, tx) {
t.assertSegments(tx.trace.root, ['MessageBroker/RabbitMQ/Exchange/Produce/Named/Default'])
metrics.assertSegments(tx.trace.root, ['MessageBroker/RabbitMQ/Exchange/Produce/Named/Default'])

t.assertMetrics(
metrics.assertMetrics(
tx.metrics,
[[{ name: 'MessageBroker/RabbitMQ/Exchange/Produce/Named/Default' }]],
false,
Expand Down Expand Up @@ -211,9 +211,9 @@ function verifyProduce(t, tx, exchangeName, routingKey) {
]
}

t.assertSegments(tx.trace.root, segments, 'should have expected segments')
metrics.assertSegments(tx.trace.root, segments, 'should have expected segments')

t.assertMetrics(
metrics.assertMetrics(
tx.metrics,
[[{ name: 'MessageBroker/RabbitMQ/Exchange/Produce/Named/' + exchangeName }]],
false,
Expand All @@ -240,11 +240,11 @@ function verifyGet({ t, tx, exchangeName, routingKey, queue, assertAttr }) {
const produceName = 'MessageBroker/RabbitMQ/Exchange/Produce/Named/' + exchangeName
const consumeName = 'MessageBroker/RabbitMQ/Exchange/Consume/Named/' + queue
if (isCallback) {
t.assertSegments(tx.trace.root, [produceName, consumeName, ['Callback: <anonymous>']])
metrics.assertSegments(tx.trace.root, [produceName, consumeName, ['Callback: <anonymous>']])
} else {
t.assertSegments(tx.trace.root, [produceName, consumeName])
metrics.assertSegments(tx.trace.root, [produceName, consumeName])
}
t.assertMetrics(tx.metrics, [[{ name: produceName }], [{ name: consumeName }]], false, false)
metrics.assertMetrics(tx.metrics, [[{ name: produceName }], [{ name: consumeName }]], false, false)

Check failure on line 247 in test/versioned/amqplib/amqp-utils.js

View workflow job for this annotation

GitHub Actions / lint (lts/*)

Replace `tx.metrics,·[[{·name:·produceName·}],·[{·name:·consumeName·}]],·false,·false` with `⏎····tx.metrics,⏎····[[{·name:·produceName·}],·[{·name:·consumeName·}]],⏎····false,⏎····false⏎··`
if (assertAttr) {
const segment = metrics.findSegment(tx.trace.root, consumeName)
const attributes = segment.getAttributes()
Expand Down Expand Up @@ -294,9 +294,9 @@ function verifyPurge(t, tx) {
]
}

t.assertSegments(tx.trace.root, segments, 'should have expected segments')
metrics.assertSegments(tx.trace.root, segments, 'should have expected segments')

t.assertMetrics(tx.metrics, [[{ name: 'MessageBroker/RabbitMQ/Queue/Purge/Temp' }]], false, false)
metrics.assertMetrics(tx.metrics, [[{ name: 'MessageBroker/RabbitMQ/Queue/Purge/Temp' }]], false, false)

Check failure on line 299 in test/versioned/amqplib/amqp-utils.js

View workflow job for this annotation

GitHub Actions / lint (lts/*)

Replace `tx.metrics,·[[{·name:·'MessageBroker/RabbitMQ/Queue/Purge/Temp'·}]],·false,·false` with `⏎····tx.metrics,⏎····[[{·name:·'MessageBroker/RabbitMQ/Queue/Purge/Temp'·}]],⏎····false,⏎····false⏎··`
}

function verifyTransaction(t, tx, msg) {
Expand Down
4 changes: 2 additions & 2 deletions test/versioned/express/segments.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ function runTest(t, options, callback) {
}

function checkSegments(t, segments, expected, opts) {
t.assertSegments(segments, expected, opts)
assertSegments(segments, expected, opts)

Check failure on line 901 in test/versioned/express/segments.tap.js

View workflow job for this annotation

GitHub Actions / lint (lts/*)

'assertSegments' is not defined
}

function checkMetrics(t, metrics, expected, path) {
Expand All @@ -923,5 +923,5 @@ function checkMetrics(t, metrics, expected, path) {
expectedAll.push([{ name: metric, scope: 'WebTransaction/Expressjs/GET/' + path }])
}

t.assertMetrics(metrics, expectedAll, false, false)
metrics.assertMetrics(metrics, expectedAll, false, false)
}
5 changes: 3 additions & 2 deletions test/versioned/kafkajs/kafka.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'use strict'

const tap = require('tap')
const { assertSegments } = require('../../lib/metrics_helper')
const helper = require('../../lib/agent_helper')
const params = require('../../lib/params')
const { removeModules } = require('../../lib/cache-buster')
Expand Down Expand Up @@ -301,7 +302,7 @@ tap.test('consume inside of a transaction', async (t) => {
agent.on('transactionFinished', (tx) => {
txCount++
if (tx.name === expectedName) {
t.assertSegments(tx.trace.root, [`${SEGMENT_PREFIX}subscribe`, `${SEGMENT_PREFIX}run`], {
assertSegments(tx.trace.root, [`${SEGMENT_PREFIX}subscribe`, `${SEGMENT_PREFIX}run`], {
exact: false
})
} else {
Expand Down Expand Up @@ -349,7 +350,7 @@ tap.test('consume batch inside of a transaction', async (t) => {

const txPromise = new Promise((resolve) => {
agent.on('transactionFinished', (tx) => {
t.assertSegments(tx.trace.root, [`${SEGMENT_PREFIX}subscribe`, `${SEGMENT_PREFIX}run`], {
assertSegments(tx.trace.root, [`${SEGMENT_PREFIX}subscribe`, `${SEGMENT_PREFIX}run`], {
exact: false
})
resolve()
Expand Down
2 changes: 1 addition & 1 deletion test/versioned/kafkajs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ utils.waitForConsumersToJoinGroup = ({ consumer, maxWait = 10000 }) =>
*/
utils.verifyConsumeTransaction = ({ t, tx, topic, clientId }) => {
const expectedName = `OtherTransaction/Message/Kafka/Topic/Consume/Named/${topic}`
t.assertMetrics(
metrics.assertMetrics(
tx.metrics,
[
[{ name: expectedName }],
Expand Down
14 changes: 7 additions & 7 deletions test/versioned/koa/koa-route.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

const tap = require('tap')
const helper = require('../../lib/agent_helper')
require('../../lib/metrics_helper')
const { assertSegments } = require('../../lib/metrics_helper')
const { run } = require('./utils')

tap.test('koa-route instrumentation', function (t) {
Expand All @@ -30,7 +30,7 @@ tap.test('koa-route instrumentation', function (t) {
})
app.use(first)
agent.on('transactionFinished', function (tx) {
t.assertSegments(tx.trace.root, [
assertSegments(tx.trace.root, [
'WebTransaction/WebFrameworkUri/Koa/GET//resource',
['Nodejs/Middleware/Koa/firstMiddleware//resource']
])
Expand All @@ -56,7 +56,7 @@ tap.test('koa-route instrumentation', function (t) {
app.use(first)
app.use(second)
agent.on('transactionFinished', function (tx) {
t.assertSegments(tx.trace.root, [
assertSegments(tx.trace.root, [
'WebTransaction/WebFrameworkUri/Koa/GET//:second',
[
'Nodejs/Middleware/Koa/firstMiddleware//:first',
Expand Down Expand Up @@ -86,7 +86,7 @@ tap.test('koa-route instrumentation', function (t) {
app.use(first)
app.use(second)
agent.on('transactionFinished', function (tx) {
t.assertSegments(tx.trace.root, [
assertSegments(tx.trace.root, [
'WebTransaction/WebFrameworkUri/Koa/GET//:first',
[
'Nodejs/Middleware/Koa/firstMiddleware//:first',
Expand Down Expand Up @@ -115,7 +115,7 @@ tap.test('koa-route instrumentation', function (t) {
app.use(first)
app.use(second)
agent.on('transactionFinished', function (tx) {
t.assertSegments(tx.trace.root, [
assertSegments(tx.trace.root, [
'WebTransaction/WebFrameworkUri/Koa/GET//:first',
['Nodejs/Middleware/Koa/firstMiddleware//:first']
])
Expand All @@ -140,7 +140,7 @@ tap.test('koa-route instrumentation', function (t) {
app.use(first)
app.use(second)
agent.on('transactionFinished', function (tx) {
t.assertSegments(tx.trace.root, [
assertSegments(tx.trace.root, [
'WebTransaction/WebFrameworkUri/Koa/GET//:second',
[
'Nodejs/Middleware/Koa/firstMiddleware//:first',
Expand Down Expand Up @@ -173,7 +173,7 @@ tap.test('koa-route instrumentation', function (t) {
app.use(second)
app.use(third)
agent.on('transactionFinished', function (tx) {
t.assertSegments(tx.trace.root, [
assertSegments(tx.trace.root, [
'WebTransaction/WebFrameworkUri/Koa/GET//resource',
[
'Nodejs/Middleware/Koa/firstMiddleware',
Expand Down
4 changes: 2 additions & 2 deletions test/versioned/prisma/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict'
const utils = module.exports
const { findSegment, getMetricHostName } = require('../../lib/metrics_helper')
const { findSegment, getMetricHostName, assertSegments } = require('../../lib/metrics_helper')
const { DB, PRISMA } = require('../../../lib/metrics/names')
const params = require('../../lib/params')
const expectedUpsertMetrics = {
Expand Down Expand Up @@ -59,7 +59,7 @@ function verifyTraces(t, agent, transaction) {
t.ok(trace, 'trace should exist')
t.ok(trace.root, 'root element should exist')

t.assertSegments(trace.root, [findMany, update, update, findMany], { exact: true })
assertSegments(trace.root, [findMany, update, update, findMany], { exact: true })
const findManySegment = findSegment(trace.root, findMany)
t.ok(findManySegment.timer.hrDuration, 'findMany segment should have ended')
const updateSegment = findSegment(trace.root, update)
Expand Down
20 changes: 10 additions & 10 deletions test/versioned/undici/requests.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ tap.test('Undici request tests', (t) => {
})
t.equal(statusCode, 200)

t.assertSegments(tx.trace.root, [`External/${HOST}/post`], { exact: false })
metrics.assertSegments(tx.trace.root, [`External/${HOST}/post`], { exact: false })
tx.end()
t.end()
})
Expand Down Expand Up @@ -124,7 +124,7 @@ tap.test('Undici request tests', (t) => {

await client.request({ path: '/', method: 'GET' })

t.assertSegments(transaction.trace.root, [`External/localhost:${port}/`], {
metrics.assertSegments(transaction.trace.root, [`External/localhost:${port}/`], {
exact: false
})

Expand Down Expand Up @@ -206,7 +206,7 @@ tap.test('Undici request tests', (t) => {
const [{ statusCode }, { statusCode: statusCode2 }] = await Promise.all([req1, req2])
t.equal(statusCode, 200)
t.equal(statusCode2, 200)
t.assertSegments(tx.trace.root, [`External/${HOST}/post`, `External/${HOST}/put`], {
metrics.assertSegments(tx.trace.root, [`External/${HOST}/post`, `External/${HOST}/put`], {
exact: false
})
tx.end()
Expand All @@ -223,7 +223,7 @@ tap.test('Undici request tests', (t) => {
})
} catch (err) {
t.ok(err)
t.assertSegments(tx.trace.root, ['External/invalidurl/foo'], { exact: false })
metrics.assertSegments(tx.trace.root, ['External/invalidurl/foo'], { exact: false })
t.equal(tx.exceptions.length, 1)
tx.end()
t.end()
Expand All @@ -244,7 +244,7 @@ tap.test('Undici request tests', (t) => {
}, 100)
await req
} catch (err) {
t.assertSegments(tx.trace.root, [`External/${HOST}/delay/1000`], { exact: false })
metrics.assertSegments(tx.trace.root, [`External/${HOST}/delay/1000`], { exact: false })
t.equal(tx.exceptions.length, 1)
const expectedErrMsg = semver.gte(pkgVersion, '6.3.0')
? 'This operation was aborted'
Expand Down Expand Up @@ -274,7 +274,7 @@ tap.test('Undici request tests', (t) => {
try {
await req
} catch (error) {
t.assertSegments(transaction.trace.root, [`External/localhost:${port}/`], {
metrics.assertSegments(transaction.trace.root, [`External/localhost:${port}/`], {
exact: false
})

Expand All @@ -298,7 +298,7 @@ tap.test('Undici request tests', (t) => {
method: 'GET'
})
t.equal(statusCode, 400)
t.assertSegments(tx.trace.root, [`External/${HOST}/status/400`], { exact: false })
metrics.assertSegments(tx.trace.root, [`External/${HOST}/status/400`], { exact: false })
tx.end()
t.end()
})
Expand All @@ -308,7 +308,7 @@ tap.test('Undici request tests', (t) => {
helper.runInTransaction(agent, async (tx) => {
const res = await undici.fetch(REQUEST_URL)
t.equal(res.status, 200)
t.assertSegments(tx.trace.root, [`External/${HOST}/`], { exact: false })
metrics.assertSegments(tx.trace.root, [`External/${HOST}/`], { exact: false })
tx.end()
t.end()
})
Expand All @@ -331,7 +331,7 @@ tap.test('Undici request tests', (t) => {
})
}
)
t.assertSegments(tx.trace.root, [`External/${HOST}/get`], { exact: false })
metrics.assertSegments(tx.trace.root, [`External/${HOST}/get`], { exact: false })
tx.end()
t.end()
})
Expand Down Expand Up @@ -367,7 +367,7 @@ tap.test('Undici request tests', (t) => {
}),
(err) => {
t.error(err)
t.assertSegments(tx.trace.root, [`External/${HOST}/get`], { exact: false })
metrics.assertSegments(tx.trace.root, [`External/${HOST}/get`], { exact: false })
tx.end()
t.end()
}
Expand Down

0 comments on commit 3017697

Please sign in to comment.