Skip to content

[client-v2] Build the User-Agent in the standard client format and let applications add metadata #3202

Open

Description

@Marais

client-v2 always appends its own part to the application's client name (HttpAPIClientHelper#buildDefaultUserAgent / #correctUserAgentHeader, same in 0.9.5 and 0.11.0-rc1):

<client_name> clickhouse-java-v2/<v> (<os.name>; jvm:<java.version>) Apache-HttpClient/<v>

The standard ClickHouse client format, already used by clickhouse-go, clickhouse-js, clickhouse-connect and clickhouse-rs, is:

<app_name>/<app_version> <client_name>/<client_version> (<comment>; <key1>:<value1>; <key2>:<value2>)

Needed

  1. Send the language version as lv:java/<java.version> instead of jvm:, and the OS as os:<os.name> instead of a plain comment.
  2. Don't append Apache-HttpClient/<v> after the bracket group (drop it or move it into a key).
  3. Let applications add key/value pairs to the client's bracket group, e.g. Client.Builder#setClientMetadata(Map<String, String>). Today a connector has to add its own bracket group before clickhouse-java-v2/<v>, so it can't follow the format.

Example (Flink connector)

  • Now: Flink-ClickHouse-Sink/0.2.0 (fv:flink/2.0.0; api:table) clickhouse-java-v2/0.9.5 (Mac OS X; jvm:17.0.19) Apache-HttpClient/5.4.4
  • Expected: Flink-ClickHouse-Sink/0.2.0 clickhouse-java-v2/0.11.0 (fv:flink/2.0.0; api:table; lv:java/17.0.19; os:Mac OS X)

This affects every Java-based connector that sets a client name (Flink, Spark, Kafka Connect).

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions