Skip to content

feat: Neo4j slow query logger#759

Open
aintnostressin wants to merge 37 commits intomainfrom
feat/slow-graph-query-logger
Open

feat: Neo4j slow query logger#759
aintnostressin wants to merge 37 commits intomainfrom
feat/slow-graph-query-logger

Conversation

@aintnostressin
Copy link
Contributor

Adds slow query logging for Neo4j.

GraphExec trait becomes the main application interface for interacting with the Neo4j database. TracedGraph is a decorator over GraphExec that logs queries exceeding a configurable time threshold. Graph is a plain GraphExec implementation that delegates directly to neo4rs::Graph - used when slow query logging is disabled (e.g. migrations, CLI commands).

All graph queries now use a custom Query type (replacing neo4rs::Query) that carries a label for identification in logs.

Note on timing: Measured query time is wall-clock time from the application's perspective. It includes the Neo4j roundtrip, driver-level connection pool acquisition, retry logic, row streaming, and async executor scheduling delays - not just
server-side execution time.

Configuration:

  • slow_query_threshold_ms - queries exceeding this threshold are logged with their label and timing breakdown (execute vs fetch).
  • log_slow_query_cypher - additionally logs the fully interpolated cypher for slow queries. Has per-query overhead so should not be enabled in production by default.
  • slow_query_logging - set to false to disable tracing entirely (used by migration and mock configs).

@aintnostressin aintnostressin added this to the 2026-Q1 milestone Mar 5, 2026
@aintnostressin aintnostressin self-assigned this Mar 5, 2026
@aintnostressin aintnostressin added the 📈 enhancement New feature or request label Mar 5, 2026
Copy link
Contributor

@ok300 ok300 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single last comment, otherwise LGTM.

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📈 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants