Skip to content

Add detailed client information to User-Agent #25889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wendigo
Copy link
Contributor

@wendigo wendigo commented May 29, 2025

This sends more information about the client to the Trino cluster.

Structure is similiar to other tools like AWS SDK:

aws-sdk-java/2.31.42 md/io#sync md/http#Apache ua/2.1 os/Linux#5.10.236-228.935.amzn2.aarch64 lang/java#24.0.1 md/OpenJDK_64-Bit_Server_VM#24.0.1+9 md/vendor#Eclipse_Adoptium md/en_US app/Trino cfg/auth-source#stsweb m/D

For our own clients it will be similiar to:

trino-cli/1.0.0 os=Mac_OS_X os/version=15.3.1 arch=aarch64 lang/java=24+36 java/vm=OpenJDK_64-Bit_Server_VM java/vendor=Eclipse_Adoptium locale=pl-PL md/lang=en-US md/feature=experimental

Description

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

## CLI, JDBC, client
* Send detailed client information in the source ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label May 29, 2025
@github-actions github-actions bot added the jdbc Relates to Trino JDBC driver label May 29, 2025
@wendigo wendigo requested review from electrum and martint May 29, 2025 10:16
@wendigo wendigo force-pushed the serafin/cli-source branch 5 times, most recently from 0a48c6f to c32f0dd Compare May 29, 2025 12:40
Copy link
Member

@electrum electrum left a comment

Choose a reason for hiding this comment

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

The “source” field is user visible and used by resource groups for matching. It’s often set by applications for queuing purposes. It is not intended to be used for client version information.

The standard User-Agent header is appropriate for this purpose. If the intent is to log this in query history, user agent could be included there.

@wendigo
Copy link
Contributor Author

wendigo commented May 29, 2025

@electrum we send source as User-Agent

@electrum
Copy link
Member

Source is sent as X-Trino-Source. User agent is hard-coded:

builder.addHeader(TRINO_HEADERS.requestSource(), session.getSource());

private static final String USER_AGENT_VALUE = StatementClientV1.class.getSimpleName() +
"/" +
firstNonNull(StatementClientV1.class.getPackage().getImplementationVersion(), "unknown");

@electrum
Copy link
Member

It's been that way since the beginning: 33032e7

@wendigo wendigo force-pushed the serafin/cli-source branch from c32f0dd to 91e68bf Compare June 2, 2025 10:13
@wendigo wendigo changed the title Add detailed client information to source Add detailed client information to User-Agent Jun 2, 2025
@wendigo wendigo requested review from electrum and nineinchnick June 2, 2025 10:14
@wendigo wendigo force-pushed the serafin/cli-source branch from 91e68bf to 9830bbb Compare June 2, 2025 10:17
@wendigo wendigo requested a review from losipiuk June 3, 2025 10:06
@VisibleForTesting
static String sanitize(String value)
{
return value.replaceAll("[^a-zA-Z0-9_.-]", "_");
Copy link
Member

Choose a reason for hiding this comment

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

nit: colapse mutiple unsane characters into single _

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Added a test

wendigo added 2 commits June 3, 2025 12:27
This sends more information about the client to the Trino cluster.

Structure is similiar to other tools like AWS SDK:

```
aws-sdk-java/2.31.42 md/io#sync md/http#Apache ua/2.1 os/Linux#5.10.236-228.935.amzn2.aarch64 lang/java#24.0.1 md/OpenJDK_64-Bit_Server_VM#24.0.1+9 md/vendor#Eclipse_Adoptium md/en_US app/Trino cfg/auth-source#stsweb m/D
```

For our own clients it will be similiar to:

```
trino-cli/1.0.0 os=Mac_OS_X os/version=15.3.1 arch=aarch64 lang/java=24+36 java/vm=OpenJDK_64-Bit_Server_VM java/vendor=Eclipse_Adoptium locale=pl-PL md/lang=en-US md/feature=experimental
```
User-Agent header is already added when HttpClientFactory is used to construct OkHttpClient
@wendigo wendigo force-pushed the serafin/cli-source branch from 04d65f3 to ee1b720 Compare June 3, 2025 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed jdbc Relates to Trino JDBC driver
Development

Successfully merging this pull request may close these issues.

4 participants