Commit graph

4,223 commits

Author SHA1 Message Date
Anthony Alaribe
d024a55a2d Improve dark mode consistency and fix UI elements
- Convert all text colors to oklch with blue saturation for consistent theming
- Update DaisyUI theme colors to use solid oklch values for better visibility
- Fix progress bar transparency issues in both light and dark modes
- Add missing SVG sprite icons: alert-circle, activity, route, routes
- Update base colors to use oklch with proper blue tint
2025-11-18 22:40:41 +01:00
Anthony Alaribe
a1a9f8a371 Adjust dark mode background colors for better contrast
Update dark mode background to 14% lightness with increased blue saturation for improved visual comfort and brand consistency.
2025-11-18 22:40:41 +01:00
github-actions[bot]
970ef2692f Auto-format code with fourmolu 2025-11-17 21:38:52 +00:00
Anthony Alaribe
b3122e8df9 add trace info to logs 2025-11-17 22:38:28 +01:00
Anthony Alaribe
3f36aeec93 Cache fourmolu binary to speed up workflow 2025-11-17 21:38:59 +01:00
github-actions[bot]
637e9160ef Auto-format code with fourmolu 2025-11-17 20:36:05 +00:00
Anthony Alaribe
11eac7866f Use make fmt to format code instead of fourmolu action 2025-11-17 21:35:43 +01:00
Anthony Alaribe
a6a641de63 Allow fourmolu workflow to continue on error 2025-11-17 21:30:13 +01:00
Anthony Alaribe
1a801fbd45 Revert to mode: 'inplace' for fourmolu workflow 2025-11-17 21:29:04 +01:00
Anthony Alaribe
f3afc40c44 Use -i flag instead of --mode inplace for fourmolu 2025-11-17 21:23:19 +01:00
Anthony Alaribe
87c3025cad Fix fourmolu workflow to format files in place
The workflow was using an unsupported 'mode' parameter, causing fourmolu
to run in check mode instead of formatting files. Changed to use extra-args
to pass --mode inplace directly to fourmolu.
2025-11-17 21:21:10 +01:00
Anthony Alaribe
a1d768282c auto push formated code 2025-11-17 21:18:05 +01:00
Anthony Alaribe
aa6fe0dd20 Complete GHC 9.12.2 upgrade across build tools
- Update Dockerfile base image to haskell:9.12.2
- Update Makefile GHC_VERSION and compiler flags
- Update GitHub Actions workflows to use GHC 9.12.2
- Replace manual Default instances with deriving anyclass
2025-11-17 21:12:54 +01:00
Anthony Alaribe
d2ed18574a Upgrade to GHC 9.12.2 and update dependencies
- Switch from GHC 9.10.3 to 9.12.2
- Use Stackage nightly-2025-11-17
- Update proto-lens to custom fork
- Add ghc-source-gen dependency
- Comment out opentelemetry dependencies
2025-11-17 21:12:54 +01:00
Yussif Mohammed
6034559e31 towards trace shape flame graph 2025-11-17 18:58:24 +00:00
Anthony Alaribe
edafce3566 upgrade to 9.10.3 2025-11-17 17:58:40 +01:00
Anthony Alaribe
084c28791c make fmt 2025-11-17 17:52:14 +01:00
Anthony Alaribe
aa4819b182 Replace apitoolkit.io email with monoscope.tech in tests
Change test user email from test@apitoolkit.io to test@monoscope.tech
to align with project domain.
2025-11-17 17:49:43 +01:00
Anthony Alaribe
b3e5033535 Grant sudo privileges to test user in testSessionHeader
Add UPDATE to set is_sudo = true for test user (ID ...001) after creation
to enable BusinessFlows and other tests requiring sudo access.
2025-11-17 17:43:00 +01:00
Anthony Alaribe
8b0877352a Fix testSessionHeader user ID mismatch
Change email back to test@apitoolkit.io so Auth.authorizeUserAndPersist
creates a new user (ID ...001) instead of reusing the nil user, matching
the project_members insert.
2025-11-17 17:35:04 +01:00
Anthony Alaribe
873b71e13c Refactor test infrastructure and fix onboarding session caching
- Add refreshSession and runTestEffect helpers to eliminate duplication
- Skip session cache for ONBOARDING projects (actively being updated)
- Use pattern guards in sessionAndProject for cleaner control flow
- Simplify test setup: UPDATE sudo status instead of INSERT with conflict handling
- Restructure BusinessFlowsSpec with TestContext and withTestProject
- Rename projectOnboarding to projectOnboardingH for consistency
- Fix LemonSqueezy payment plan enum (FREE vs Free)
2025-11-17 17:16:41 +01:00
Anthony Alaribe
4b0e92659b Fix integration test compilation errors after testServant refactoring
Update all integration tests to properly unpack tuple response from testServant helper, which now returns (RespHeaders a, a).

Key changes:
- Add servant and servant-htmx to integration test dependencies
- Fix tuple unpacking in all test specs (AnomalyList, Log, Alerts, ManageMembers, Projects, BusinessFlows, Reports, Api, ApiCatalog, GrpcIngestion)
- Fix BusinessFlowsSpec imports to use ResponseHeader data constructor
- Fix type-level string usage for header lookups
- Fix ProjectId to Text conversions using .toText
- Add missing pattern match cases to avoid incomplete pattern warnings
2025-11-17 11:30:07 +01:00
Anthony Alaribe
c13704adf3 Rename onboarding handlers for consistency and cleanup config
- Renamed onboardingInfoPost -> onboardingInfoPostH
- Renamed onboardingConfPost -> onboardingConfPostH
- Updated Routes to use renamed handlers
- Removed unused notifChannels function
- Cleaned up BusinessFlowsSpec comments
- Updated auto-instrument config (commented out ATBackgroundCtx target and some span attributes)
2025-11-17 09:25:29 +01:00
Anthony Alaribe
f10795b158 Refactor integration tests to use simplified testServant helper
Simplified test code by:
- Replacing verbose toServantResponse pattern with concise testServant helper
- Changed test lambdas from \tr@TestResources{..} to \tr for cleaner syntax
- Updated field access to use dot notation (tr.trPool, tr.trATCtx, etc.)

This reduces boilerplate and improves test readability across all integration
test suites while maintaining the same functionality.

Affected test suites:
- Pages (ApiSpec, LogExplorer, Anomalies, Projects, Endpoints, Reports,
  Monitors, BusinessFlows, Share)
- MonitoringSpec
- ProcessMessageSpec
2025-11-17 09:04:28 +01:00
Anthony Alaribe
7a549ad053 logs management in integration test run 2025-11-16 01:48:12 +00:00
Anthony Alaribe
04e21f37ee Add business flows integration test suite
Add comprehensive integration tests for business-critical workflows:

- Onboarding flow: Test all steps (Info, Survey, NotifChannel,
  Integration) through handlers, verifying data persistence via
  GET endpoints
- LemonSqueezy billing: Table-driven tests for webhook events
  (subscription_created, cancelled, resumed, expired)
- Replay session recording: Test event ingestion and retrieval
- S3 configuration: Validation and removal tests (pending Minio setup)

Tests use the new structured response types to verify handler behavior
without HTML parsing. Includes table-driven testing patterns for
webhook scenarios and helper functions for creating test payloads.
2025-11-16 01:46:02 +00:00
Anthony Alaribe
ceba76da2b Add structured response types for onboarding and settings handlers
Replace raw Html responses with typed response wrappers for better
type safety and testability:

- Onboarding handlers now return OnboardingGet, OnboardingInfoPost,
  OnboardingConfPost, and OnboardingPhoneEmailsPost types
- Refactor onboardingGetH to build OnboardingStepData (InfoStep,
  SurveyStep, NotifChannelStep, IntegrationStep, PricingStep,
  CompleteStep) with ToHtml instance for rendering
- Add NotificationsUpdatePost type for notification channel updates
- Add Data.Default import to LemonSqueezy module
- Update Replay module imports for cleaner structure
- Update route type signatures to use new response types

This enables testing handlers through their return values rather than
parsing rendered HTML.
2025-11-16 01:43:53 +00:00
Anthony Alaribe
c8a9007920 Refactor OTLP test helpers into TestUtils module
Move test helper functions for creating API keys and ingesting
telemetry data (logs, traces, metrics) from GrpcIngestionSpec into
the shared TestUtils module. This includes:
- createTestAPIKey: Create API keys via handler
- ingestLog/Trace/Metric: Ingest via resource attributes
- ingestLogWithHeader/TraceWithHeader/MetricWithHeader: Ingest via gRPC Authorization header
- toBaseServantResponse: Run base context handlers in tests

Add necessary imports (Proto, OTLP modules, Api module) and derive
Generic for AuthContext to support the new test infrastructure.
2025-11-16 01:43:22 +00:00
Anthony Alaribe
876223e2a0 make fmt 2025-11-15 22:03:15 +00:00
Anthony Alaribe
3ba4f67d23 Suppress verbose test output in Makefile
Change test-show-details from direct to never to reduce test
output noise during test runs.
2025-11-15 21:50:13 +00:00
Anthony Alaribe
dc486656d3 Change monitor threshold logging from attention to trace
Reduce log verbosity for query monitor threshold events by using
trace level instead of attention level.
2025-11-15 21:49:35 +00:00
Anthony Alaribe
8477228369 Update integration tests to pass logger to logging helper
Pass logger parameter to logBackgroundJobsInfo calls to support
the new structured logging interface.
2025-11-15 21:48:42 +00:00
Anthony Alaribe
c28d1f6f20 Update test infrastructure to support log levels
Load environment config in test setup to respect LOG_LEVEL setting.
Update logBackgroundJobsInfo to use structured logging and accept logger parameter.
2025-11-15 21:48:12 +00:00
Anthony Alaribe
26aa7c7b3f Add configurable log level support
Add LOG_LEVEL environment variable to control application logging verbosity.
Supports trace, info, and attention levels with trace as the default.
Update all logging call sites to use the configured log level.
2025-11-15 21:47:57 +00:00
Anthony Alaribe
7b0a5b769c Consolidate LLM API logic to effect module
Remove duplicate callOpenAIAPI implementation from Pkg.AI and use the
version from Data.Effectful.LLM instead. Export callOpenAIAPI from the
effect module and re-export it in Pkg.AI for backward compatibility.

Also clean up unused imports in both modules.
2025-11-15 20:13:43 +00:00
Anthony Alaribe
8c2b7e1b3e Add gRPC metadata authentication and fix grapesy API compatibility
Metadata authentication:
- Add OtlpRequestMetadata type to parse Authorization header from gRPC metadata
- Support both 'Bearer <token>' and raw token formats
- Update processTraceRequest, processLogsRequest, processMetricsRequest to accept
  metadata API key parameter
- Add RPC handlers that extract API key from gRPC metadata
- Combine metadata API key with resource attribute keys for authentication
- Add test helpers for ingesting telemetry with gRPC headers

Grapesy API compatibility (for upgraded library):
- Replace NoMethods with NoMoreMethods constructor
- Update sendFinalOutput calls to pass tuple (defMessage, NoMetadata)
- Add type instance declarations for response metadata
2025-11-15 20:06:37 +00:00
Anthony Alaribe
4cddf7f82e Update OpenAI integration to use new API format
- Add openai package dependency
- Update LLM effect to use OpenAI V1 chat completion parameters
- Pass model name and messages via proper parameter structure
- Fix error handling to use show instead of toText
2025-11-15 20:04:18 +00:00
Anthony Alaribe
0ef74a098f Upgrade GHC to 9.10.3 and update dependencies
- Update GHC from 9.10.2 to 9.10.3
- Update stackage resolver to lts-24.19
- Update grapesy to commit 411b3e173575275cb2c745992dfe6782d2d87115
- Update odd-jobs, langchain-hs, ollama-haskell, and openai dependencies
2025-11-15 20:02:58 +00:00
Anthony Alaribe
499b7038c5 Fix test assertions and exception handling in GrpcIngestionSpec
Update expectLogsJson helper to use fail instead of expectationFailure
for proper IO type compatibility, add handling for LogsPatternList
constructor, and fix Test 3.2 to properly expect GrpcUnauthenticated
exception when API key is missing.
2025-11-15 05:59:13 +00:00
Anthony Alaribe
32a4be21c4 Fix type signatures and add missing import in GrpcIngestionSpec
- Add Data.Aeson qualified import
- Fix queryLogs return type: LogsResp -> LogsGet
- Make expectLogsJson type more specific
- Add LogsQueryLibrary case to expectLogsJson pattern match
2025-11-15 05:59:12 +00:00
Anthony Alaribe
28a250766c Add gRPC ingestion test suite and update test database setup
- Add GrpcIngestionSpec to test suite in package.yaml and cabal
- Add required dependencies: lens, proto-lens, grapesy
- Update Makefile timescaledb-docker-tmp to use faketime for frozen test time
2025-11-15 05:59:12 +00:00
Anthony Alaribe
8b0d315756 Add test infrastructure for gRPC ingestion tests
- Export gRPC handlers and process functions from OtlpServer for testing
- Add runQueryEffect helper in TestUtils for chart query testing
- Fix ProjectsSpec test to verify updates in list instead of relying on index
2025-11-15 05:59:12 +00:00
Anthony Alaribe
e4ae118ae4 Revert query debug logging to trace level
Change Log.logInfo back to Log.logTrace for query debug information
to reduce production log noise.
2025-11-15 05:59:11 +00:00
Anthony Alaribe
b977108665 Refactor GrpcIngestionSpec with helper functions
- Add testTimeRange constant for common time range setup
- Add helper functions: ingestLog, ingestTrace, ingestMetric
- Add queryLogs helper to replace repetitive 22-parameter apiLogH calls
- Add expectLogsJson helper for unified response extraction
- Use traverse and zip/zip3 for cleaner iteration patterns
- Reduced from 447 lines to 176 lines (60% reduction)
- All tests still target complete handler chains
2025-11-15 05:59:11 +00:00
Anthony Alaribe
1e05f5e867 Refactor OtlpMockValues to eliminate duplication
- Remove duplicate functions (createOtelLogMessage, createOtelLogWithStatus,
  createOtelSpan, createOtelTrace, createGaugeMetric)
- Keep only *AtTime versions for all telemetry types
- Extract mkResource helper to eliminate duplicate resource attribute code
- Consolidate functions using concise let-bindings
- Reduced from 282 lines to 95 lines (66% reduction)
2025-11-15 05:59:10 +00:00
Anthony Alaribe
9d754562f2 Add test log files to gitignore 2025-11-15 05:59:10 +00:00
Anthony Alaribe
1bc0e0c22f Add golden test cache for LLM API responses
Add cached LLM responses for integration tests to enable deterministic
testing without making actual OpenAI API calls.

Files cached:
- Issue classification prompts
- Title generation prompts
- Description generation prompts

These golden files will be reused across test runs to ensure consistency
and avoid unnecessary API costs during testing.
2025-11-15 05:59:10 +00:00
Anthony Alaribe
a4ccb14bd2 Refactor integration tests to use TestResources pattern
Update integration tests to use the new TestResources pattern for better
test organization and consistency.

Changes:
- Replace withSetup callback with withTestResources
- Use runTestBg helper instead of runTestBackground
- Access test resources via TestResources record fields
- Remove redundant imports (execute from DBT)
- Simplify test setup code

This refactoring improves test readability and reduces boilerplate.
2025-11-15 05:59:09 +00:00
Anthony Alaribe
68b8837b4f Improve notification logging in test mode
Add structured logging for notifications in test mode to show notification
type, receiver, and template information. Also add trace-level logging for
full notification payloads to aid debugging.
2025-11-15 05:59:09 +00:00
Anthony Alaribe
ad12dbf927 Fix issues table constraint to allow multiple query alerts
The previous unique constraint was too restrictive, preventing multiple
query alert issues for the same project and preventing new api_change
issues after acknowledging old ones.

Changes:
- Add migration to drop overly restrictive table-level constraint
- Update insertIssue to use partial unique index instead
- Partial index only applies to open api_change issues per endpoint

The partial unique index unique_open_api_change_issue_per_endpoint
already enforces the correct business logic: only one open (unacknowledged,
unarchived) api_change issue per (project_id, endpoint_hash).
2025-11-15 05:59:08 +00:00