-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Added producer and consumer metrics to kafkajs instrumentation (…
- Loading branch information
1 parent
09636a4
commit 41c1cc6
Showing
6 changed files
with
207 additions
and
115 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
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
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
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,17 @@ | ||
/* | ||
* Copyright 2024 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict' | ||
|
||
module.exports = recordLinkingMetrics | ||
|
||
function recordLinkingMetrics({ agent, brokers, topic, producer = true }) { | ||
const kind = producer === true ? 'Produce' : 'Consume' | ||
for (const broker of brokers) { | ||
agent.metrics | ||
.getOrCreateMetric(`MessageBroker/Kafka/Nodes/${broker}/${kind}/Named/${topic}`) | ||
.incrementCallCount() | ||
} | ||
} |
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,21 @@ | ||
/* | ||
* Copyright 2024 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict' | ||
|
||
const { KAFKA } = require('../../metrics/names') | ||
|
||
module.exports = recordMethodMetric | ||
|
||
/** | ||
* Convenience method for logging the tracking metrics for producer and consumer | ||
* | ||
* @param {object} params to function | ||
* @param {Agent} params.agent instance of agent | ||
* @param {string} params.name name of function getting instrumented | ||
*/ | ||
function recordMethodMetric({ agent, name }) { | ||
agent.metrics.getOrCreateMetric(`${KAFKA.PREFIX}/${name}`).incrementCallCount() | ||
} |
Oops, something went wrong.