Skip to content

Commit

Permalink
fix: provide tracerProvider and meterProvider explicitly (#215)
Browse files Browse the repository at this point in the history
closes #216
  • Loading branch information
sjvans authored Aug 9, 2024
1 parent f4c6418 commit 286d24b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## Version 1.0.1 - 2024-08-10

### Fixed

- Explicitly pass own providers when registering instrumentations (the global providers may be influenced by, for example, Dynatrace OneAgent)

## Version 1.0.0 - 2024-08-08

### Added
Expand Down
11 changes: 8 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ module.exports = function () {
/*
* setup tracing
*/
tracing(resource)
const tracerProvider = tracing(resource)

/*
* setup metrics
*/
metrics(resource)
const meterProvider = metrics(resource)

/*
* register instrumentations
*/
registerInstrumentations({ instrumentations: _getInstrumentations() })
registerInstrumentations({
tracerProvider,
meterProvider,
// loggerProvider,
instrumentations: _getInstrumentations()
})
}
2 changes: 2 additions & 0 deletions lib/metrics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,6 @@ module.exports = resource => {
*/
require('./db-pool')()
require('./host')()

return meterProvider
}
4 changes: 3 additions & 1 deletion lib/tracing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,12 @@ module.exports = resource => {
})

/*
* add CAP instrumentations
* add tracing
*/
require('./cds')()
// REVISIT: we should be able to remove okra instrumentation entirely, but keep behind feature flag for now
if (process.env.TRACE_OKRA) require('./okra')()
require('./cloud_sdk')()

return tracerProvider
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cap-js/telemetry",
"version": "1.0.0",
"version": "1.0.1",
"description": "CDS plugin providing observability features, incl. automatic OpenTelemetry instrumentation.",
"repository": "cap-js/telemetry",
"author": "SAP SE (https://www.sap.com)",
Expand All @@ -18,6 +18,7 @@
"dependencies": {
"@opentelemetry/api": "^1.9",
"@opentelemetry/core": "^1.25",
"@opentelemetry/instrumentation": "^0.52",
"@opentelemetry/instrumentation-http": "^0.52",
"@opentelemetry/resources": "^1.25",
"@opentelemetry/sdk-metrics": "^1.25",
Expand All @@ -38,7 +39,6 @@
"@opentelemetry/exporter-trace-otlp-grpc": "^0.52.1",
"@opentelemetry/exporter-trace-otlp-proto": "^0.52.1",
"@opentelemetry/host-metrics": "^0.35.0",
"@opentelemetry/instrumentation": "^0.52.1",
"@opentelemetry/instrumentation-runtime-node": "^0.6.0",
"@sap/cds-mtxs": "^2.0.5",
"axios": "^1.6.7",
Expand Down

0 comments on commit 286d24b

Please sign in to comment.