Add OpenTelemetry instrumentation support via enable-otel flag#7
Add OpenTelemetry instrumentation support via enable-otel flag#7tonyalaribe wants to merge 1 commit intofpringle:mainfrom
Conversation
When the flag is enabled, database operations automatically create OpenTelemetry spans using hs-opentelemetry-instrumentation-postgresql-simple. No code changes required - the same Effectful.PostgreSQL module transparently uses instrumented functions. Includes workaround for forEach bug in the upstream instrumentation package.
fpringle
left a comment
There was a problem hiding this comment.
Thanks for the contribution! Just a few questions.
I'll add some commits afterwards - the CICD should test the build both with and without opentelemetry, and the Nix overlay should include the revision you pinned in cabal.project.
| forEach q row forR = | ||
| unliftWithConn $ \conn unlift -> | ||
| #if OTEL | ||
| -- Workaround for bug in hs-opentelemetry-instrumentation-postgresql-simple |
There was a problem hiding this comment.
What bug is this? If there's a Github issue on the hs-opentelemetry repo, I can follow it and make sure to update this line when it's patched.
|
|
||
| -- Use latest hs-opentelemetry from GitHub for GHC 9.12 support | ||
| -- (Hackage version is outdated) | ||
| source-repository-package | ||
| type: git | ||
| location: https://github.com/iand675/hs-opentelemetry.git | ||
| tag: 841a8e191fba3f2c76f6e6fa10d26b644856b7ee | ||
| subdir: api | ||
| instrumentation/postgresql-simple |
There was a problem hiding this comment.
Could you elaborate on why this is needed? Will the Hackage version eventually catch up, so we'll be able to remove this?
I should probably add this to the nix overlay as well.
|
Another thought: I'm not sure about controlling the OpenTelemetry integration via a cabal flag (which are a bit fragile, and slightly difficult to control when not building directly with cabal). Before this, there was only one reasonable way to do each of the PostgreSQL operations inside the I'm going to have a go at wrapping all the PostgreSQL operations ( |
When the flag is enabled, database operations automatically create OpenTelemetry spans using hs-opentelemetry-instrumentation-postgresql-simple. No code changes required. The same Effectful.PostgreSQL module transparently uses instrumented functions.
Includes workaround for forEach bug in the upstream instrumentation package.