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
Added OpenTelemetry instrumentation to Ghost backend #20144
base: main
Are you sure you want to change the base?
Conversation
7573224
to
9ba1396
Compare
c3264b4
to
6192a0a
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #20144 +/- ##
==========================================
+ Coverage 73.02% 73.29% +0.27%
==========================================
Files 1264 1265 +1
Lines 73780 74314 +534
Branches 9825 9868 +43
==========================================
+ Hits 53876 54467 +591
+ Misses 19103 19047 -56
+ Partials 801 800 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Does @opentelemetry/instrumentation-knex
not work in place of this?
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.
It picks up the queries, but it doesn't include spans for the acquire
piece. That said, this is pretty ugly and doesn't seem to scale well, so I think we might just have to accept what we get with @opentelemetry/instrumentation-knex
as good enough — leaning towards tearing this out at this point.
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