-
Non-Product Related Assistance
Request for existing cases, user IDs, Portal navigation support and more
Request for existing cases, user IDs, Portal navigation support and more
The setup procedure involves the following changes which are described in the following:
Open telemetry JS libraries 2.x are supported starting with xotel-agent-ext-js 2.0.0.
{
"dependencies": {
"@sap/xotel-agent-ext-js": "https://73555000100200018064.npmsrv.cdn.repositories.cloud.sap/@sap/xotel-agent-ext-js/-/xotel-agent-ext-js-2.0.4.tgz",
},
}
For deployment, the below environment parameters needs to be configured. OTEL_RESOURCE_ATTRIBUTES not required anymore as of xotel-agent-ext-js version 1.5.23.
SAP_CALM_SERVICE_NAME = <name of your application>
SAP_CALM_SERVICE_TYPE = SAP_CP_CF
For example in mta.yaml this can look like this:
modules:
- name: <service module name>
properties:
SAP_CALM_SERVICE_NAME: <application name>
SAP_CALM_SERVICE_TYPE: SAP_CP_CF
Parameters to be replaced:
If you are using an mta application make sure that node modules and the package-lock.json are included in your mtar:
modules:
- name: <your service module>
type: nodejs
path: gen/srv
build-parameters:
builder: npm
ignore:
# - node_modules
# - package-lock.json
In some cases your mta build setup might copy the built resources to specific folder, e.g. gen/srv. If the node_modules and package-lock.json are not present in this folder we need to tell the mbt command to add these as well:
build-parameters:
before-all:
- builder: custom
commands:
- npm install --production
- ...
- npm install --prefix ./gen/srv
Instrumentation Settings
The following environment variables can be set to configure the behavior of the instrumentation:
| Name | Description |
|---|---|
| SAP_CALM_DCI_AGG_THRESHOLD | Optional - Threshold in ms spans to be aggregated (default: 100, i.e. all spans with a response time lower than 100ms will be aggregated and grouped by action, request, user, span type and span kind) |
| SAP_CALM_DCI_AGG_USER | Optional - Specify whether user ids shall be aggregated spans (default: true) |
| CALM_OTEL_AGENT_EXT_TRACER_CONFIG='{"urlNormalizerPatterns":["odata","(?<=v)\\d+"]}' | The value of the variable is a JSON string. The value for urlNormalizerPatterns is an array of regular expressions. Every match will be replaced by *. |
Require the tracer via node arguments in the mta.yaml file:
modules:
- name: <your srv module>
type: nodejs
properties:
NODE_ARGS: -r @sap/xotel-agent-ext-js
In the package.json file of your project modify the start script to pick up the required tracer.
For regular node.js applications:
{
"scripts": {
"start": "node ${NODE_ARGS} <your main file name>.js"
}
}
For CAP based applications with @sap/cds >= 7:
{
"scripts": {
"start": "node ${NODE_ARGS} ./node_modules/.bin/cds-serve"
}
}
Add the following dependencies in package.json:
{
"dependencies": {
"cf-nodejs-logging-support": "7.5.5-beta.1",
"@sap/opentelemetry-exporter-for-sap-cloud-logging": "0.7.0"
},
}
Auto configuration (@sap/xotel-agent-ext-js version >= 1.5.30)
Require the xotel-agent-ext-js via node arguments in the mta.yaml file:
modules:
- name: <your srv module>
type: nodejs
properties:
NODE_ARGS: -r @sap/xotel-agent-ext-js
Add the following dependencies in package.json:
{
"dependencies": {
"@sap/xotel-agent-ext-js": "https://73555000100200018064.npmsrv.cdn.repositories.cloud.sap/@sap/xotel-agent-ext-js/-/xotel-agent-ext-js-2.0.4.tgz",
"@cap-js/telemetry": "2.0.1",
"@sap/cds": "^9"
},
"cds": {
"requires": {
"telemetry": {
"logging": {
"processor": {
"module": "@sap/xotel-agent-ext-js",
"class": "ExmLogProcessor"
},
"exporter": {
"module": "@opentelemetry/exporter-logs-otlp-grpc",
"class": "OTLPLogExporter"
}
}
}
}
}
}
Here is an example of how to log an error to be collected by Exception Monitoring:
const cds = require ('@sap/cds')
const LOG = cds.log('cds.log')
// logging an error
LOG.error('NodeJs error message')
try {
// Code throwing an Error
} catch (e) {
// logging an error with details
LOG.error('NodeJs error message', e)
}
Logging
Log levels can be specified via the the SAP_CALM_DCI_LOG_LEVEL environment variable, e.g.
SAP_CALM_DCI_LOG_LEVEL=debug
Log level of OpenTelemetry's diagnostics logger can set via the OTEL_LOG_LEVEL environment variable, e.g.
OTEL_LOG_LEVEL=info
If you want to disable the auto-instrumentation (e.g. in case of an emergency) you can do this by
SAP_CALM_INSTRUMENTATION_ENABLED=false
The following variables can also be be set and are effective after restarting the application:
Tracing
If you only want to disable the tracing auto-instrumentation you can set.
SAP_CALM_TRACING_ENABLED=false
Metrics
If you only want to disable the metrics auto-instrumentation you can set.
SAP_CALM_METRICS_ENABLED=false
Logs
If you only want to disable the logs auto instrumentation you can set.
SAP_CALM_LOGS_ENABLED=false