Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
title: ClickHouse
description: "Adds instrumentation for the ClickHouse JavaScript clients. (default)"
supportedCategories:
- server
- serverless
---

<AvailableSince version="11.17.0" />

_Import name: `Sentry.clickhouseIntegration`_

This integration is enabled by default when <PlatformLink to="/tracing/">tracing</PlatformLink> is enabled. To customize it, see [Modifying Default Integrations](./../#modifying-default-integrations).

The `clickhouseIntegration` adds instrumentation for the official ClickHouse clients: [`@clickhouse/client`](https://www.npmjs.com/package/@clickhouse/client) for Node.js and [`@clickhouse/client-web`](https://www.npmjs.com/package/@clickhouse/client-web) for web runtimes such as Cloudflare Workers. It creates a `db` span for each statement the client sends, so slow or failing ClickHouse queries show up in your traces.

```javascript
Sentry.init({
dsn: "___PUBLIC_DSN___",
tracesSampleRate: 1.0,
integrations: [Sentry.clickhouseIntegration()],
});
```

<PlatformSection supported={["javascript.nextjs"]}>

Run ClickHouse calls in the Node.js runtime. This automatic instrumentation isn't available in the Edge runtime.

</PlatformSection>

<PlatformSection supported={["javascript.cloudflare"]}>

On Cloudflare Workers, use `@clickhouse/client-web` and build your Worker with the <PlatformLink to="/install/vite-plugin/">Sentry Cloudflare Vite plugin</PlatformLink>. The plugin traces the client automatically, as long as `@clickhouse/client-web` is bundled and not marked as external. If you deploy with `wrangler` directly, Sentry doesn't trace ClickHouse calls.

</PlatformSection>

<PlatformSection supported={["javascript.deno"]}>

On Deno, preload Sentry's import hook so it can instrument the ClickHouse client:

```bash
deno run --allow-net --allow-env --allow-read --allow-sys --allow-write --preload=npm:@sentry/deno/import app.ts
```

</PlatformSection>

<PlatformSection supported={["javascript.bun", "javascript.elysia"]}>

On Bun, automatic instrumentation requires a build with `sentryBunPlugin()` and `@clickhouse/client` included in the bundle:

```typescript {filename:build.ts}
import { sentryBunPlugin } from "@sentry/bun/plugin";

await Bun.build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
target: "bun",
plugins: [sentryBunPlugin()],
});
```

</PlatformSection>

## Supported Operations

The integration traces these `ClickHouseClient` methods:

- `query()`
- `command()`
- `exec()`
- `insert()`

`ping()` and `close()` don't send a statement, so they don't create spans. An `insert()` with an empty `values` array doesn't send a request and doesn't create a span either.

The integration only creates spans inside an active span, such as a request handler or a span you start with <PlatformLink to="/tracing/instrumentation/">`Sentry.startSpan()`</PlatformLink>.

## Spans

The integration names each span after the operation and its table, for example `SELECT events`. In the query text, it replaces string and number literals with `?` and removes comments and inline data. It doesn't record `query_params` values or inserted rows.

## Supported Versions

- `@clickhouse/client`: `>=1.1.0 <2`
- `@clickhouse/client-web`: `>=1.1.0 <2`
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Depending on whether an integration enhances the functionality of a particular r
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`firebaseIntegration`](./firebase/) | ✓ | | ✓ | |
| [`zodErrorsIntegration`](./zodErrors/) | | | | ✓ |
| [`pinoIntegration`](./pino/) | | ✓ | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`amqplibIntegration`](./amqplib/) | | | ✓ | |
| [`anrIntegration`](./anr/) | | ✓ | | |
| [`captureConsoleIntegration`](./captureconsole/) | | | | ✓ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`firebaseIntegration`](./firebase/) | ✓ | | ✓ | |
| [`captureConsoleIntegration`](./captureconsole/) | | | | ✓ |
| [`dataloaderIntegration`](./dataloader/) | | | ✓ | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
| [`rewriteFramesIntegration`](./rewriteframes/) | | ✓ | | | |
| [`supabaseIntegration`](./supabase/) | | ✓ | ✓ | | |
| [`instrumentPostgresJsSql`](./postgresjs/) | | | ✓ | | |
| [`clickhouseIntegration`](./clickhouse/) | | | ✓ | | |
| [`prismaIntegration`](./prisma/) | | | ✓ | | |
| [`serveTunnelIntegration`](./servetunnel/) | | | | | |

[Mistral AI](./mistral/) is automatically instrumented when built with the Sentry Cloudflare Vite plugin. Without the plugin, use `instrumentMistralAiClient`.

The [`clickhouseIntegration`](./clickhouse/) traces `@clickhouse/client-web` when your Worker is built with the Sentry Cloudflare Vite plugin.

The [`prismaIntegration`](./prisma/) needs the `nodejs_compat` compatibility flag on your Worker.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
| [`zodErrorsIntegration`](./zodErrors/) | | | | ✓ |
| [`mistralAIIntegration`](./mistral/) | ✓ | | ✓ | | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | | |
| [`serveTunnelIntegration`](./servetunnel/) | | | | | |
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`anrIntegration`](./anr/) | | ✓ | | |
| [`awsLambdaWebIntegration`](./awslambdaweb/) | ✓ | | | ✓ |
| [`captureConsoleIntegration`](./captureconsole/) | | | | ✓ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`firebaseIntegration`](./firebase/) | ✓ | | ✓ | |
| [`amqplibIntegration`](./amqplib/) | | | ✓ | |
| [`anrIntegration`](./anr/) | | ✓ | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`anrIntegration`](./anr/) | | ✓ | | |
| [`awsLambdaWebIntegration`](./awslambdaweb/) | ✓ | | | ✓ |
| [`captureConsoleIntegration`](./captureconsole/) | | | | ✓ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`zodErrorsIntegration`](./zodErrors/) | | | | ✓ |
| [`pinoIntegration`](./pino/) | | ✓ | | |
| [`serveTunnelIntegration`](./servetunnel/) | | | | |
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Depending on whether an integration enhances the functionality of a particular r
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`zodErrorsIntegration`](./zodErrors/) | | | | ✓ |
| [`pinoIntegration`](./pino/) | | ✓ | | |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`firebaseIntegration`](./firebase/) | ✓ | | ✓ | |
| [`zodErrorsIntegration`](./zodErrors/) | | | | ✓ |
| [`pinoIntegration`](./pino/) | | ✓ | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Depending on whether an integration enhances the functionality of a particular r
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`zodErrorsIntegration`](./zodErrors/) | | | | ✓ |
| [`pinoIntegration`](./pino/) | | ✓ | | |
| [`serveTunnelIntegration`](./servetunnel/) | | | | |
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Depending on whether an integration enhances the functionality of a particular r
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`zodErrorsIntegration`](./zodErrors/) | | | | ✓ |
| [`pinoIntegration`](./pino/) | | ✓ | | |
| [`serveTunnelIntegration`](./servetunnel/) | | | | |
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@ Depending on whether an integration enhances the functionality of a particular r
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`zodErrorsIntegration`](./zodErrors/) | | | | ✓ |
| [`pinoIntegration`](./pino/) | | ✓ | | |
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Depending on whether an integration enhances the functionality of a particular r
| [`groqIntegration`](./groq/) | ✓ | | ✓ | |
| [`togetherAIIntegration`](./together-ai/) | ✓ | | ✓ | |
| [`typesafeIntegration`](./typesafe/) | ✓ | | ✓ | |
| [`clickhouseIntegration`](./clickhouse/) | ✓ | | ✓ | |
| [`zodErrorsIntegration`](./zodErrors/) | | | | ✓ |
| [`pinoIntegration`](./pino/) | | ✓ | | |
| [`serveTunnelIntegration`](./servetunnel/) | | | | |
Loading