diff --git a/.changeset/thirty-seahorses-relax.md b/.changeset/thirty-seahorses-relax.md new file mode 100644 index 00000000..7eaf21fa --- /dev/null +++ b/.changeset/thirty-seahorses-relax.md @@ -0,0 +1,7 @@ +--- +"@hyperdx/common-utils": patch +"@hyperdx/api": patch +"@hyperdx/app": patch +--- + +chore: Customize user-agent for Alerts ClickHouse client diff --git a/packages/api/src/tasks/providers/default.ts b/packages/api/src/tasks/providers/default.ts index 4745b83a..62a358c1 100644 --- a/packages/api/src/tasks/providers/default.ts +++ b/packages/api/src/tasks/providers/default.ts @@ -313,6 +313,7 @@ export default class DefaultAlertProvider implements AlertProvider { host, username, password, + application: `hyperdx-alerts ${config.CODE_VERSION}`, }); } } diff --git a/packages/common-utils/src/clickhouse/browser.ts b/packages/common-utils/src/clickhouse/browser.ts index c4101723..494cac7e 100644 --- a/packages/common-utils/src/clickhouse/browser.ts +++ b/packages/common-utils/src/clickhouse/browser.ts @@ -92,6 +92,7 @@ export class ClickhouseClient extends BaseClickhouseClient { }, fetch: myFetch, request_timeout: this.requestTimeout, + application: this.application, }); } diff --git a/packages/common-utils/src/clickhouse/index.ts b/packages/common-utils/src/clickhouse/index.ts index 2c16e00f..b0bd88b9 100644 --- a/packages/common-utils/src/clickhouse/index.ts +++ b/packages/common-utils/src/clickhouse/index.ts @@ -373,6 +373,8 @@ export type ClickhouseClientOptions = { username?: string; password?: string; queryTimeout?: number; + /** Application name, used as the client's HTTP user-agent header */ + application?: string; }; export abstract class BaseClickhouseClient { @@ -381,6 +383,7 @@ export abstract class BaseClickhouseClient { protected readonly password?: string; protected readonly queryTimeout?: number; protected client?: WebClickHouseClient | NodeClickHouseClient; + protected readonly application?: string; /* * Some clickhouse db's (the demo instance for example) make the * max_rows_to_read setting readonly and the query will fail if you try to @@ -394,12 +397,14 @@ export abstract class BaseClickhouseClient { username, password, queryTimeout, + application, }: ClickhouseClientOptions) { this.host = host!; this.username = username; this.password = password; this.queryTimeout = queryTimeout; this.maxRowReadOnly = false; + this.application = application; } protected getClient(): WebClickHouseClient | NodeClickHouseClient { diff --git a/packages/common-utils/src/clickhouse/node.ts b/packages/common-utils/src/clickhouse/node.ts index b8a63c31..57dc6baa 100644 --- a/packages/common-utils/src/clickhouse/node.ts +++ b/packages/common-utils/src/clickhouse/node.ts @@ -13,11 +13,13 @@ export { createClient as createNativeClient }; export class ClickhouseClient extends BaseClickhouseClient { constructor(options: ClickhouseClientOptions) { super(options); + this.client = createClient({ url: this.host, username: this.username, password: this.password, request_timeout: this.requestTimeout, + application: this.application, }); }