-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(serverless-collector): added service name detection (#1468)
- Loading branch information
Showing
5 changed files
with
61 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* (c) Copyright IBM Corp. 2024 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
get name() { | ||
return require('./name'); | ||
} | ||
}; |
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,30 @@ | ||
/* | ||
* (c) Copyright IBM Corp. 2024 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const instanaCore = require('@instana/core'); | ||
|
||
// NOTE: | ||
// The service name will be "localhost" because the serverless collector does not support | ||
// metrics. Metrics contain the package.json name. AFAIK there is currently | ||
// no way to connect metrics with spans for **agentless non serverless** environments. | ||
// https://jsw.ibm.com/browse/INSTA-3607 | ||
module.exports = (config, logger) => { | ||
if (process.env.INSTANA_SERVICE_NAME) { | ||
return process.env.INSTANA_SERVICE_NAME; | ||
} | ||
|
||
return new Promise(resolve => { | ||
instanaCore.util.applicationUnderMonitoring.getMainPackageJsonStartingAtMainModule(config, (err, packageJson) => { | ||
if (err) { | ||
logger.debug('Failed to determine main package.json.', err); | ||
return resolve(); | ||
} | ||
|
||
logger.debug(`Found main package.json: ${packageJson.name}`); | ||
resolve(packageJson.name); | ||
}); | ||
}); | ||
}; |
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
'use strict'; | ||
|
||
// 30 = info | ||
let minLevel = 30; | ||
|
||
module.exports = exports = { | ||
|