Skip to content

Add context option to append more ClientInfo to the system.query_log#1736

Merged
SpencerTorres merged 1 commit intomainfrom
client_info_query_option
Dec 12, 2025
Merged

Add context option to append more ClientInfo to the system.query_log#1736
SpencerTorres merged 1 commit intomainfrom
client_info_query_option

Conversation

@SpencerTorres
Copy link
Copy Markdown
Member

Summary

ClientInfo is appended per-query, but it can only be set upon connection.

This PR allows users to append to it per-query. The original ClientInfo from the initial connection is unaffected, it's append-only.

Changes:

  • Add WithClientInfo function for usage with clickhouse.Context
  • Made Comment public on ClientInfo so users can append to it in their clickhouse.Options config
  • Updated TCP and HTTP usage. ClientInfo is merged from connection options and query options.
  • Updated unit + integration tests

Usage

// This data will be appended to the existing ClientInfo from clickhouse.Options
queryCtx := clickhouse.Context(ctx, clickhouse.WithClientInfo(clickhouse.ClientInfo{
	Products: []struct {
		Name    string
		Version string
	}{
		{ Name:    "ctxProduct", Version: "1.2.3" },
	},
	Comment: []string{"ctxComment"},
}))

// The system.query_log table will include the additional ClientInfo from the queryCtx
row := conn.QueryRow(queryCtx, "SELECT 1")

Checklist

  • Unit and integration tests covering the common scenarios were added

Copy link
Copy Markdown
Contributor

@kavirajk kavirajk left a comment

Choose a reason for hiding this comment

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

LGTM. one minor question.

@SpencerTorres SpencerTorres merged commit 325704c into main Dec 12, 2025
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants