-
Notifications
You must be signed in to change notification settings - Fork 13
[stash] improve tracing #450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7d7a672
3fdad54
a785be4
419698e
b8f5c0c
f623a7f
89c985e
8c7303f
247dc62
65c7dc3
1950431
b889be6
1a6e866
171cdfd
1583096
035dddf
dab6eef
4dc17e2
f7288bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,4 +135,5 @@ dist | |
| # test | ||
| test/msg-box | ||
| test/bookshop/gen | ||
| test/bookshop/.cdsrc.json | ||
|
|
||
| .claude/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ const { registerInstrumentations } = require('@opentelemetry/instrumentation') | |
| const tracing = require('./tracing') | ||
| const metrics = require('./metrics') | ||
| const logging = require('./logging') | ||
| const { getDiagLogLevel, getResource, _require } = require('./utils') | ||
| const { getDiagLogLevel, getResource, hasDependency, _require } = require('./utils') | ||
|
|
||
| function _getInstrumentations() { | ||
| const _instrumentations = cds.env.requires.telemetry.instrumentations | ||
|
|
@@ -36,6 +36,33 @@ function _getInstrumentations() { | |
| } | ||
| } | ||
|
|
||
| // if @opentelemetry/instrumentation-host-metrics is in project's dependencies but not in cds.env.requires.telemetry.instrumentations, add it automatically | ||
| if ( | ||
| !Object.keys(_instrumentations).includes('instrumentation-host-metrics') && | ||
| !Object.values(_instrumentations).find(i => i?.module === '@opentelemetry/instrumentation-host-metrics') | ||
| ) { | ||
| try { | ||
| const pkg = require(require('path').join(cds.root, 'package')) | ||
| if (Object.keys(pkg.dependencies).includes('@opentelemetry/instrumentation-host-metrics')) { | ||
| _instrumentations['instrumentation-host-metrics'] = { | ||
| class: 'HostMetricsInstrumentation', | ||
| module: '@opentelemetry/instrumentation-host-metrics' | ||
| } | ||
| } | ||
| } catch (err) { | ||
| LOG._debug && LOG.debug('Failed to automatically add @opentelemetry/instrumentation-host-metrics:', err) | ||
| } | ||
| } | ||
|
|
||
| // by default, all `system.*` metrics shall be ignored | ||
| const host_metrics = Object.values(_instrumentations).find( | ||
| i => i?.module === '@opentelemetry/instrumentation-host-metrics' | ||
| ) | ||
| if (host_metrics && !host_metrics.config?.metricGroups && !process.env.HOST_METRICS_RETAIN_SYSTEM) { | ||
| host_metrics.config ??= {} | ||
| host_metrics.config.metricGroups = ['process.cpu', 'process.memory'] | ||
| } | ||
|
|
||
| const instrumentations = [] | ||
| for (const each of Object.values(_instrumentations)) { | ||
| if (!each) continue //> could be falsy | ||
|
|
@@ -62,34 +89,32 @@ function _getInstrumentations() { | |
| return instrumentations | ||
| } | ||
|
|
||
| module.exports = function () { | ||
| function setup_standalone() { | ||
| // set logger and propagate log level | ||
| diag.setLogger(cds.log('telemetry'), getDiagLogLevel()) | ||
|
|
||
| // create resource | ||
| const resource = getResource() | ||
|
|
||
| /* | ||
| * setup tracing | ||
| */ | ||
| // setup tracing, metrics, and logging | ||
| const tracerProvider = tracing(resource) | ||
|
|
||
| /* | ||
| * setup metrics | ||
| */ | ||
| const meterProvider = metrics(resource) | ||
|
|
||
| /* | ||
| * setup logging | ||
| */ | ||
| const loggerProvider = cds.env.requires.telemetry.logging ? logging(resource) : undefined | ||
|
|
||
| /* | ||
| * register instrumentations | ||
| */ | ||
| // register instrumentations | ||
| registerInstrumentations({ | ||
| tracerProvider, | ||
| meterProvider, | ||
| loggerProvider, | ||
| instrumentations: _getInstrumentations() | ||
| }) | ||
| } | ||
|
|
||
| function setup_with_calm() { | ||
| // setup tracing, metrics, and logging | ||
| tracing() | ||
| metrics() | ||
| if (cds.env.requires.telemetry.logging) logging() | ||
| } | ||
|
Comment on lines
+113
to
+118
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Please provide feedback on the review comment by checking the appropriate box:
|
||
|
|
||
| module.exports = hasDependency('@sap/xotel-agent-ext-js') ? setup_with_calm : setup_standalone | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The
actions/checkout@v6.0.3reference is invalid — the latest major release is v4. This will cause the workflow to fail with a "not found" error.Double-check suggestion before committing. Edit this comment for amendments.
Please provide feedback on the review comment by checking the appropriate box: