Skip to content
This repository was archived by the owner on Aug 2, 2026. It is now read-only.

Add execute-with-state overloads for correlated query profiling - #89

Merged
coronabytes merged 3 commits into
coronabytes:masterfrom
HolonCom:feature/Execute-with-State
Aug 2, 2026
Merged

Add execute-with-state overloads for correlated query profiling#89
coronabytes merged 3 commits into
coronabytes:masterfrom
HolonCom:feature/Execute-with-State

Conversation

@robsiera

@robsiera robsiera commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Why

QueryProfile can log query stats, but it has no way to receive per-call context (a request-scoped logger, correlation ID, or similar). Callers either use ambient/static state or lose the link between a specific Execute* call and its profile callback.

What

  • Add optional object? state overloads for ExecuteAsync / ExecuteStreamAsync (existing overloads unchanged; they pass state: null).
  • Add QueryProfileWithState on configuration: (query, bindVars, stats, returnCount, state).
  • For non-stream execute, invoke profiling after the cursor is fully drained so returnCount matches the real result size; on failure pass stats: null and returnCount: -1.

Benefit

Pass any call-site object through to the profile callback—for example a scoped logger—without changing how the driver is shared application-wide:

config.QueryProfileWithState = (query, bindVars, stats, returnCount, state) =>
{
    if (state is ILogger logger)
        logger.LogInformation("Returned {Count} rows in {Time}s: {Query}",
            returnCount, stats?.ExecutionTime, query);
};

var result = await arango.Query.ExecuteAsync<MyDoc>(
    "database",
    $"FOR d IN docs RETURN d",
    logger);

Documented in the README; QueryProfileWithStateTest is a runnable usage example.

Test plan

  • Build against supported TFMs
  • Run QueryProfileWithStateTest
  • Existing query tests still pass (overloads without state)
  • Confirm QueryProfile and QueryProfileWithState both fire when configured

@coronabytes
coronabytes merged commit 9112e5f into coronabytes:master Aug 2, 2026
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants