Added OpenTelemetry instrumentation to Ghost backend #20144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds OpenTelemetry instrumentation to Ghost's backend code, which allows us to view traces similar to what we see in Sentry Performance locally.
It also refactors the
ConnectionPoolInstrumentation
(that was seeming to cause CPU utilization issues) —instead of creating so many logs and metrics and trying to pipe them into elastic, this class now simply creates spans in OpenTelemetry for the acquire and query stage of the query, so you can see both if there is contention in the pool and if the query itself is taking a long time. The new version of this instrumentation lives atghost/core/core/shared/OpenTelemetryKnexTracing.js
.Note: there is likely some opportunity to combine this file with
ghost/core/core/shared/SentryKnexTracingIntegration.js
since there is a lot of overlap in functionality, but for now this seems to work well.OpenTelemetry is enabled if
NODE_ENV === 'development'
or if it is explicitly enabled via config withopentelemetry:enabled
.It also adds a Jaeger container to Ghost's docker-compose file for viewing the traces. There's no setup required (beyond running
yarn docker:reset
to pickup the changes in the docker-compose file the first time — but this will also reset your DB so be careful). This will launch the Jaeger container, and you can view the UI to see the traces athttp://localhost:16686/search
.Example trace in Jaeger:
Todo:
OpenTelemetryKnexTracing.js
andSentryKnexTracingIntegration.js
if it makes sense