dd-trace
Version:
Datadog APM tracing client for JavaScript
37 lines (28 loc) • 1.06 kB
JavaScript
const { getEnvironmentVariable } = require('./config-helper')
function getIsGCPFunction () {
const isDeprecatedGCPFunction =
getEnvironmentVariable('FUNCTION_NAME') !== undefined &&
getEnvironmentVariable('GCP_PROJECT') !== undefined
const isNewerGCPFunction =
getEnvironmentVariable('K_SERVICE') !== undefined &&
getEnvironmentVariable('FUNCTION_TARGET') !== undefined
return isDeprecatedGCPFunction || isNewerGCPFunction
}
function getIsAzureFunction () {
const isAzureFunction =
getEnvironmentVariable('FUNCTIONS_EXTENSION_VERSION') !== undefined &&
getEnvironmentVariable('FUNCTIONS_WORKER_RUNTIME') !== undefined
return isAzureFunction
}
function isInServerlessEnvironment () {
const inAWSLambda = getEnvironmentVariable('AWS_LAMBDA_FUNCTION_NAME') !== undefined
const isGCPFunction = getIsGCPFunction()
const isAzureFunction = getIsAzureFunction()
return inAWSLambda || isGCPFunction || isAzureFunction
}
module.exports = {
getIsGCPFunction,
getIsAzureFunction,
isInServerlessEnvironment
}