Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Commit

Permalink
feat(config): add serviceNodeName
Browse files Browse the repository at this point in the history
  • Loading branch information
Qard committed Oct 31, 2019
1 parent a78803d commit 8390076
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Data sent to the APM Server as part of the metadata package:
- `agentName` - (required) The APM agent name
- `agentVersion` - (required) The APM agent version
- `serviceName` - (required) The name of the service being instrumented
- `serviceNodeName` - (optional) Unique name of the service being instrumented
- `serviceVersion` - The version of the service being instrumented
- `frameworkName` - If the service being instrumented is running a
specific framework, use this config option to log its name
Expand Down
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ function getMetadata (opts) {
version: opts.agentVersion
},
framework: undefined,
version: undefined
version: undefined,
node: undefined
},
process: {
pid: process.pid,
Expand All @@ -578,6 +579,12 @@ function getMetadata (opts) {
labels: opts.globalLabels
}

if (opts.serviceNodeName) {
payload.service.node = {
configured_name: opts.serviceNodeName
}
}

if (opts.serviceVersion) payload.service.version = opts.serviceVersion

if (opts.frameworkName || opts.frameworkVersion) {
Expand Down
6 changes: 5 additions & 1 deletion test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ test('metadata', function (t) {
agentName: 'custom-agentName',
agentVersion: 'custom-agentVersion',
serviceName: 'custom-serviceName',
serviceNodeName: 'custom-serviceNodeName',
serviceVersion: 'custom-serviceVersion',
frameworkName: 'custom-frameworkName',
frameworkVersion: 'custom-frameworkVersion',
Expand All @@ -175,7 +176,6 @@ test('metadata', function (t) {
service: {
name: 'custom-serviceName',
environment: 'production',
version: 'custom-serviceVersion',
runtime: {
name: 'node',
version: process.versions.node
Expand All @@ -190,6 +190,10 @@ test('metadata', function (t) {
framework: {
name: 'custom-frameworkName',
version: 'custom-frameworkVersion'
},
version: 'custom-serviceVersion',
node: {
configured_name: 'custom-serviceNodeName'
}
},
process: {
Expand Down

0 comments on commit 8390076

Please sign in to comment.