Skip to content

Tag ClickHouse User-Agent with lib identity - #47

Merged
alex-clickhouse merged 3 commits into
mainfrom
add-user-agent-lib-tag
Jul 8, 2026
Merged

Tag ClickHouse User-Agent with lib identity#47
alex-clickhouse merged 3 commits into
mainfrom
add-user-agent-lib-tag

Conversation

@alex-clickhouse

Copy link
Copy Markdown
Collaborator

What

ClickHouse.Driver 1.3.0 adds ClickHouseClientSettings.ApplicationInfo — free-form tags appended to the HTTP User-Agent header for per-application query attribution. This sets the lib tag to ClickHouse.EntityFrameworkCore on the connections/data sources the provider constructs, so queries issued through EF Core are attributable server-side.

Changes

  • Bump ClickHouse.Driver 1.1.0 → 1.3.0.
  • Add internal ClickHouseClientIdentity.CreateSettings helper.
  • Build the pooled ClickHouseDataSource from tagged settings (ClickHouseDataSourceManager) and apply the tag to the fallback ClickHouseConnection in CreateDbConnection.

Only the connection-string path is tagged; when the caller supplies their own DbConnection or DbDataSource, the provider does not construct the client and leaves it alone.

Testing

dotnet build -c Release succeeds with 0 errors (pre-existing analyzer warnings only, none from the changed files).

🤖 Generated with Claude Code

alex-clickhouse and others added 2 commits July 7, 2026 15:38
ClickHouse.Driver 1.3.0 adds ClickHouseClientSettings.ApplicationInfo,
a set of free-form tags appended to the HTTP User-Agent for per-application
query attribution. Set the "lib" tag to "ClickHouse.EntityFrameworkCore" on
the connections/data sources the provider constructs so queries issued
through EF Core are attributable server-side. Only the connection-string
path is tagged; when the caller supplies their own DbConnection or
DbDataSource the provider does not construct the client and leaves it alone.

- Bump ClickHouse.Driver 1.1.0 -> 1.3.0.
- Add ClickHouseClientIdentity.CreateSettings helper.
- Build the pooled ClickHouseDataSource from tagged settings
  (ClickHouseDataSourceManager) and apply the tag to the fallback
  ClickHouseConnection in CreateDbConnection.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The functional and unit test projects referenced ClickHouse.Driver 1.1.0
directly, which downgrades below the provider's 1.3.0 reference (NU1605 as
error) after the bump.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Runs a query through an EF Core DbContext, flushes system.query_log, and
verifies http_user_agent carries lib:ClickHouse.EntityFrameworkCore.
Verification uses a separate untagged connection so the tag can only
originate from the provider.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades the ClickHouse ADO.NET driver and tags provider-created ClickHouse clients with a lib:ClickHouse.EntityFrameworkCore token via ClickHouseClientSettings.ApplicationInfo, enabling server-side attribution of EF Core-originated queries.

Changes:

  • Bump ClickHouse.Driver from 1.1.0 to 1.3.0 across src + test projects.
  • Introduce ClickHouseClientIdentity.CreateSettings() to apply the lib User-Agent tag.
  • Construct pooled ClickHouseDataSource and fallback ClickHouseConnection using tagged settings, plus add an end-to-end functional test validating the tag via system.query_log.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/EFCore.ClickHouse.Tests/EFCore.ClickHouse.Tests.csproj Updates test project dependency to ClickHouse.Driver 1.3.0.
test/EFCore.ClickHouse.FunctionalTests/EFCore.ClickHouse.FunctionalTests.csproj Updates functional test project dependency to ClickHouse.Driver 1.3.0.
test/EFCore.ClickHouse.FunctionalTests/UserAgentClickHouseTest.cs Adds functional coverage asserting the lib User-Agent token is present in system.query_log.
src/EFCore.ClickHouse/Storage/Internal/ClickHouseRelationalConnection.cs Applies tagged client settings when creating fallback ClickHouseConnection.
src/EFCore.ClickHouse/Storage/Internal/ClickHouseDataSourceManager.cs Builds pooled ClickHouseDataSource from tagged client settings.
src/EFCore.ClickHouse/Storage/Internal/ClickHouseClientIdentity.cs Adds internal helper for creating settings with ApplicationInfo["lib"].
src/EFCore.ClickHouse/EFCore.ClickHouse.csproj Updates provider dependency to ClickHouse.Driver 1.3.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/EFCore.ClickHouse.FunctionalTests/UserAgentClickHouseTest.cs
@alex-clickhouse
alex-clickhouse merged commit 9ecf523 into main Jul 8, 2026
4 checks passed
@alex-clickhouse
alex-clickhouse deleted the add-user-agent-lib-tag branch July 8, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants