cap-js / telemetry

CDS plugin providing observability features, incl. automatic OpenTelemetry instrumentation.
https://cap.cloud.sap/docs
Apache License 2.0
8 stars 6 forks source link

Command "cds add cloud-logging --with-telemetry" adds "telemetry": "to-cloud-logging" for local development #233

Open gopalanand333 opened 4 days ago

gopalanand333 commented 4 days ago

First i would like to thank you for bringing this new capability to add cloud logging and telemetry libraries with a single command. Here's one observation that i feel can be improved.

  1. When i use the command cds add cloud-logging --with-telemetry, it adds "telemetry": "to-cloud-logging" property at cds.requires level. Running cds watch breaks the startup of application as the applications starts looking for Cloud Logging Credentials. Moving the property under production solves this "[production]": { "db": "hana", "auth": "xsuaa", "multitenancy": true, "telemetry": "to-cloud-logging" },

    1. It will be great if this can be adapted with the cds add cloud-logging --with-telemetry command.

    Also, The Indentation of Cloud logging Service in mta is wrong. The current generated code is :

     - name: incident-management-cloud-logging
        type: org.cloudfoundry.managed-service
        parameters:
          service: cloud-logging
          service-plan: standard
          config:
          ingest_otlp:
            enabled: true

    Required indentation:

    - name: incident-management-cloud-logging
      type: org.cloudfoundry.managed-service
      parameters:
        service: cloud-logging
        service-plan: standard
        config:
          ingest_otlp: # this requires one indentation 
            enabled: true
    1. After fixing and deploying the application, i am getting the following error
      2024-09-24T07:49:20.667+0000 [APP/PROC/WEB/0] STDOUT Invoking pre-start scripts.
      2024-09-24T07:49:20.917+0000 [APP/PROC/WEB/0] STDOUT Invoking start command.
      2024-09-24T07:49:21.332+0000 [APP/PROC/WEB/0] STDOUT > incident-management@1.0.0 start
      2024-09-24T07:49:21.332+0000 [APP/PROC/WEB/0] STDOUT > cds-serve
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR /home/vcap/app/node_modules/@cap-js/telemetry/lib/tracing/index.js:43
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR const { kind, root, ratio } = cds.env.requires.telemetry.tracing.sampler
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR ^
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR TypeError: Cannot destructure property 'kind' of 'cds.env.requires.telemetry.tracing.sampler' as it is undefined.
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR at _getSampler (/home/vcap/app/node_modules/@cap-js/telemetry/lib/tracing/index.js:43:11)
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR at module.exports (/home/vcap/app/node_modules/@cap-js/telemetry/lib/tracing/index.js:122:66)
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR at module.exports (/home/vcap/app/node_modules/@cap-js/telemetry/lib/index.js:36:26)
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR at Object.<anonymous> (/home/vcap/app/node_modules/@cap-js/telemetry/cds-plugin.js:12:31)
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR at Module._compile (node:internal/modules/cjs/loader:1364:14)
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR at Module.load (node:internal/modules/cjs/loader:1203:32)
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR at Module._load (node:internal/modules/cjs/loader:1019:12)
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR at Module.require (node:internal/modules/cjs/loader:1231:19)
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR at require (node:internal/modules/helpers:177:18)
      2024-09-24T07:49:21.582+0000 [APP/PROC/WEB/0] STDERR Node.js v18.20.4
      2024-09-24T07:49:21.594+0000 [APP/PROC/WEB/0] STDERR npm notice
      2024-09-24T07:49:21.594+0000 [APP/PROC/WEB/0] STDERR npm notice New minor version of npm available! 10.7.0 -> 10.8.3
      2024-09-24T07:49:21.594+0000 [APP/PROC/WEB/0] STDERR npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.3
      2024-09-24T07:49:21.594+0000 [APP/PROC/WEB/0] STDERR npm notice To update run: npm install -g npm@10.8.3
      2024-09-24T07:49:21.594+0000 [APP/PROC/WEB/0] STDERR npm notice
      2024-09-24T07:49:21.617+0000 [APP/PROC/WEB/0] STDOUT Exit status 1
      2024-09-24T07:49:21.623+0000 [CELL/SSHD/0] STDOUT Exit status 0
      2024-09-24T07:49:28.118+0000 [CELL/0] STDOUT Cell 33f1a3f2-ba19-4b38-8ea3-d7769595d920 stopping instance c4aa54d4-0586-45bc-492f-9c2b
      2024-09-24T07:49:28.118+0000 [CELL/0] STDOUT Cell 33f1a3f2-ba19-4b38-8ea3-d7769595d920 destroying container for instance c4aa54d4-0586-45bc-492f-9c2b
      2024-09-24T07:49:28.132+0000 [API/35] STDOUT Process has crashed with type: "web"
      2024-09-24T07:49:28.147+0000 [API/35] STDOUT App instance exited with guid 674110e5-6a93-443f-8660-b011b01c96d2 payload: {"instance"=>"c4aa54d4-0586-45bc-492f-9c2b", "index"=>0, "cell_id"=>"33f1a3f2-ba19-4b38-8ea3-d7769595d920", "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 1", "crash_count"=>12, "crash_timestamp"=>1727164168114639998, "version"=>"a022b9a0-f057-4e21-8952-84ac33ed6326"}
      2024-09-24T07:49:28.317+0000 [PROXY/0] STDOUT Exit status 137
      2024-09-24T07:49:30.590+0000 [CELL/0] STDOUT Cell 33f1a3f2-ba19-4b38-8ea3-d7769595d920 successfully destroyed container for instance c4aa54d4-0586-45bc-492f-9c2b