Skip to content

Commit

Permalink
runDB: add otel span for holding a database connection (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-martin authored Sep 20, 2024
1 parent 3b99f3a commit 3594ea5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
14 changes: 13 additions & 1 deletion freckle-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
## [_Unreleased_](https://github.com/freckle/freckle-app/compare/freckle-app-v1.20.2.0...main)
## [_Unreleased_](https://github.com/freckle/freckle-app/compare/freckle-app-v1.20.2.1...main)

## [v1.20.2.1](https://github.com/freckle/freckle-app/compare/freckle-app-v1.20.2.0...freckle-app-v1.20.2.1)

Adds an OpenTelemetry span called "runSqlPool" within each "runDB" span.

- `runDB` covers the entire action, from the time it requests a connection
from the pool to the time it returns the connection to the pool.
- The new `runSqlPool` span covers the actions taken while _holding_ a
connection. This span doesn't start until a connection is obtained.

This makes the trace more explicitly reflect situations where a thread was
blocked by an exhausted connection pool.

## [v1.20.2.0](https://github.com/freckle/freckle-app/compare/freckle-app-v1.20.1.2...freckle-app-v1.20.2.0)

Expand Down
2 changes: 1 addition & 1 deletion freckle-app/freckle-app.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.22
-- see: https://github.com/sol/hpack

name: freckle-app
version: 1.20.2.0
version: 1.20.2.1
synopsis: Haskell application toolkit used at Freckle
description: Please see README.md
category: Utils
Expand Down
6 changes: 5 additions & 1 deletion freckle-app/library/Freckle/App/Database.hs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ runDB action = do
}
Stats.withGauge Stats.dbEnqueuedAndProcessing $
inSpan "runDB" (clientSpanArguments {Trace.attributes = dbAttributes}) $
runSqlPoolWithExtensibleHooks action pool Nothing hooks'
runSqlPoolWithExtensibleHooks
(inSpan "runSqlPool" defaultSpanArguments action)
pool
Nothing
hooks'
where
dbAttributes = HashMap.fromList [("service.name", "database")]

Expand Down
2 changes: 1 addition & 1 deletion freckle-app/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: freckle-app
version: 1.20.2.0
version: 1.20.2.1
maintainer: Freckle Education
category: Utils
github: freckle/freckle-app
Expand Down

0 comments on commit 3594ea5

Please sign in to comment.