Commit graph

10 commits

Author SHA1 Message Date
Anthony Alaribe
64b3a8bc88
refactor: migrate from pg-transact to effectful-postgresql to support postgres open telemetry instrumentation (#236)
* refactor: migrate from pg-transact to effectful-postgresql

Replace pg-transact and pg-transact-effectful with effectful-postgresql for database operations. Key changes: replace DB effect with WithConnection, remove dbtToEff wrappers, use direct PG.query/PG.execute calls, update runDB to runWithConnectionPool, keep pg-entity for query building, add IOE constraint alongside WithConnection where needed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* Auto-format code with fourmolu

* chore: use effectful-postgresql fork with OpenTelemetry support

Switch to tonyalaribe/effectful-postgresql fork (instrument-pg branch) and
enable the +enable-otel flag for OpenTelemetry instrumentation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* fix: improve connection usage and error handling in BackgroundJobs

- Use PG.execute directly instead of multiple withConnection calls for
  CleanupDemoProject (more efficient connection usage)
- Handle missing project gracefully in ATRuntimeException processing
  instead of crashing with error
- Clean up unused imports (PGS, withConnection)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* fix: correct effectful-postgresql subdir path

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* fix: add proper error handling and logging for critical operations

- Log advisory lock release failures instead of silently ignoring
- Log when error update doesn't match any span (potential data issue)
- Log when span hash update count mismatches expected (data integrity)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* Auto-format code with fourmolu

* refactor: simplify single-row query handling in BackgroundJobs

* refactor: return lists from model query functions instead of Vectors

PostgreSQL-simple returns lists naturally, so wrapping results with V.fromList was wasteful. Model query functions now return lists directly, with Vector conversion happening at call sites that actually need Vectors.

* Auto-format code with fourmolu

* perf: fix N+1 query pattern and improve advisory lock handling

- Replace individual UPDATE queries in forM_ loop with batched UPDATE
  using SQL unnest to reduce O(n) DB round-trips to O(1)
- Add 5-minute statement timeout to advisory lock to prevent hangs
- Add timeout reset in finally block for cleanup
- Improve comments explaining session-level lock auto-release behavior

* refactor: replace verbose Only unwrapping with coerce

- Use coerce @[Only T] @[T] instead of map (\(Only x) -> x)
- Use coerce @(Maybe (Only T)) @(Maybe T) instead of fmap (\(Only x) -> x)
- Update GenerateOtelFacetsBatch to use Projects.ProjectId instead of Text

* Auto-format code with fourmolu

* fix: advisory lock release and remove unnecessary vector conversion

- Use query instead of execute for pg_advisory_unlock (SELECT returns result)
- Add validation for unexpected unlock results
- Remove unnecessary V.fromList/V.toList round-trip in runHourlyJob

* refactor: simplify COUNT(*) query result handling

Use inline maybe/listToMaybe instead of case expression for cleaner code.

* Auto-format code with fourmolu

* refactor: use catch instead of try/case for advisory lock cleanup

Cleaner error handling with catch pattern instead of explicit try + case Left/Right.

* Auto-format code with fourmolu

* perf: use V.mapMaybe and V.unzip3 to avoid list conversions

Direct Vector operations for batch error updates instead of
list mapMaybe + V.fromList.

* refactor: introduce DB type alias and switch to pg-transact

* Auto-format code with fourmolu

* fix errors in specs

* fix: remove duplicate import in Dashboards.hs

* fix: resolve integration test failures

- BusinessFlowsSpec: fix column names for apis.subscriptions table

- TestUtils: add test user as admin to nil UUID project

- System/Types: increase static UUID pool to prevent collisions

- AnomaliesSpec: fix test assertions for correct filter views

* fix aroundAll

* fix: resolve integration test failures

- Fix insertProjectMembers to handle empty list (prevents 'no rows supplied' error)

- Fix DashboardsSpec UUID collisions by grouping creations and adding cleanup

- Fix ManageMembersSpec: correct userID to UUID 1, update expected member count and email

- Fix ProjectsSpec: update expected project count to include demo project

* remove PG_EFFECT_MIGRATION.md

* fix: use unique team handles in bulk add teams test to avoid conflicts

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-12-22 22:32:43 +01:00
Anthony Alaribe
ba651f5040 Fix GHC 9.12 TypeAbstractions errors in test files
Replace type synonym Projects.ProjectId with UUIDId constructor
in all test files to fix "Illegal term-level use of type constructor"
errors that occur with GHC 9.12's TypeAbstractions extension.
2025-11-27 23:29:55 +01:00
Anthony Alaribe
4b4ed0252a rename project to monoscope 2025-09-14 19:55:26 +02:00
Anthony Alaribe
63d8ef3369 remove base64-bytestring 2025-09-13 21:36:57 +02:00
Anthony Alaribe
b6711269aa
Support Basic auth (For opensource users) and investigate performance issue in onboading due to returning 401 unauthenticated, causing repeated authentication checks. (#193)
* support for basic auth for open source users

* implement basic auth support

* introduce support for basic auth and support disabling the client side monitoring via monoscope-browser

* pass in the entire config to bodywrapper

* support leaving unused fields as optional

* make fmt

* add posthog

* configure external scripts via env variables

* make fmt

* fix compile errors
2025-09-12 17:06:32 +02:00
Anthony Alaribe
0ac389984a fix test compilation error due to the byte libraris. would have to remove one of the libraries soon 2025-09-05 03:18:52 +02:00
Anthony Alaribe
09e67ab30c fix api catalog related failing tests especally for anomaly 2025-09-05 02:59:16 +02:00
Anthony Alaribe
bae911eea1 fix some issues that made some tests not compile 2025-08-30 15:39:04 +02:00
Anthony Alaribe
152be7e8fd fix some issues that made tests not compile 2025-08-30 15:08:53 +02:00
Anthony Alaribe
4dd34754ff move unit tests and integration tests to their own project s they run quickly 2025-07-02 01:41:15 +02:00