---
title: Diesel configuration
description: Configuration for Allure Diesel | Disable transaction steps | Capture connection events | Control the SQL attachment
---

# Allure Diesel configuration

This page describes `CaptureOptions`, which controls what
[`AllureInstrumentation`](/docs/diesel-reference/) records. Build it with the builder methods
below and pass it to `AllureInstrumentation::with_options(...)`:

```rust
use allure_diesel::{AllureInstrumentation, CaptureOptions};

let options = CaptureOptions::default()
    .without_transactions()
    .with_connection_events()
    .without_sql_attachment()
    .with_max_sql_preview(256);

let instrumentation = AllureInstrumentation::with_options(options);
```

## Disable transaction steps

- `without_transactions()`

By default, `BEGIN`/`COMMIT`/`ROLLBACK` boundaries are wrapped in a `transaction` step that nests
the statements run inside that transaction — see
[Reference](/docs/diesel-reference/#transactions). Call `without_transactions()` to turn this off;
every statement (including the boundary `BEGIN`/`COMMIT`/`ROLLBACK` SQL itself) is then recorded
as a flat, top-level step instead of being grouped.

## Capture connection events

- `with_connection_events()`

Off by default. When enabled, establishing a new connection is recorded as its own `connect` step
(no SQL, no attachment), bracketing Diesel's `StartEstablishConnection`/
`FinishEstablishConnection` instrumentation events. A connection failure marks the step failed with
the Diesel error.

## Control the SQL attachment

- `without_sql_attachment()`

By default, each query step gets a nested `query.sql` attachment step carrying the full,
untruncated SQL. Call `without_sql_attachment()` to skip that nested step — the step name (see
below) still shows the SQL, so this only removes the redundant full-text copy, not all visibility
into the statement.

- `with_max_sql_preview(max_sql_preview: usize)` (default: `1024`)

Sets how many characters of the rendered SQL are used for the step **name**. Longer statements are
cut to this length with a trailing `…`. This only affects the step name — when the `query.sql`
attachment is enabled, it always carries the complete, untruncated SQL regardless of this setting.

```rust
use allure_diesel::CaptureOptions;

let options = CaptureOptions::default().with_max_sql_preview(80);
```

Warning:
None of these options add redaction. Reducing `max_sql_preview` shortens the step _name_, but the
`query.sql` attachment (when enabled) always contains the full statement, bind values included.
See the warning in [Getting started](/docs/diesel/#what-s-not-captured).
