Skip to content
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

chore: bump clickhouse client to v0.2.7 #159

Merged
merged 4 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-cougars-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperdx/api': minor
---

chore: bump clickhouse client to v0.2.7
4 changes: 2 additions & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ services:
environment:
APP_TYPE: 'scheduled-task'
CLICKHOUSE_HOST: http://ch-server:8123
CLICKHOUSE_LOG_LEVEL: trace
CLICKHOUSE_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
CLICKHOUSE_PASSWORD: worker
CLICKHOUSE_USER: worker
FRONTEND_URL: 'http://localhost:8080' # need to be localhost (CORS)
Expand Down Expand Up @@ -166,7 +166,7 @@ services:
AGGREGATOR_API_URL: 'http://aggregator:8001'
APP_TYPE: 'api'
CLICKHOUSE_HOST: http://ch-server:8123
CLICKHOUSE_LOG_LEVEL: trace
CLICKHOUSE_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
CLICKHOUSE_PASSWORD: api
CLICKHOUSE_USER: api
EXPRESS_SESSION_SECRET: 'hyperdx is cool 👋'
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ services:
environment:
APP_TYPE: 'scheduled-task'
CLICKHOUSE_HOST: http://ch-server:8123
CLICKHOUSE_LOG_LEVEL: trace
CLICKHOUSE_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
CLICKHOUSE_PASSWORD: worker
CLICKHOUSE_USER: worker
FRONTEND_URL: ${HYPERDX_APP_URL}:${HYPERDX_APP_PORT} # need to be localhost (CORS)
Expand Down Expand Up @@ -137,7 +137,7 @@ services:
AGGREGATOR_API_URL: 'http://aggregator:8001'
APP_TYPE: 'api'
CLICKHOUSE_HOST: http://ch-server:8123
CLICKHOUSE_LOG_LEVEL: trace
CLICKHOUSE_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
CLICKHOUSE_PASSWORD: api
CLICKHOUSE_USER: api
EXPRESS_SESSION_SECRET: 'hyperdx is cool 👋'
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"node": ">=18.12.0"
},
"dependencies": {
"@clickhouse/client": "^0.1.1",
"@clickhouse/client": "^0.2.7",
"@hyperdx/lucene": "^3.1.1",
"@hyperdx/node-logger": "^0.2.8",
"@hyperdx/node-opentelemetry": "^0.3.0",
Expand Down
25 changes: 17 additions & 8 deletions packages/api/src/clickhouse/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import type { ResponseJSON, ResultSet } from '@clickhouse/client';
import {
BaseResultSet,
createClient,
ErrorLogParams as _CHErrorLogParams,
Logger as _CHLogger,
LogParams as _CHLogParams,
ResponseJSON,
SettingsMap,
} from '@clickhouse/client';
import {
ErrorLogParams as _CHErrorLogParams,
LogParams as _CHLogParams,
} from '@clickhouse/client/dist/logger';
import opentelemetry from '@opentelemetry/api';
import * as fns from 'date-fns';
import _ from 'lodash';
import ms from 'ms';
import { serializeError } from 'serialize-error';
import SqlString from 'sqlstring';
import { Readable } from 'stream';

import * as config from '@/config';
import { sleep } from '@/utils/common';
Expand Down Expand Up @@ -192,7 +192,16 @@ export const buildMetricStreamAdditionalFilters = (
teamId: string,
) => SettingsMap.from({});

export const healthCheck = () => client.ping();
export const healthCheck = async () => {
const result = await client.ping();
if (!result.success) {
logger.error({
message: 'ClickHouse health check failed',
error: result.error,
});
throw result.error;
}
};

export const connect = async () => {
// FIXME: this is a hack to avoid CI failure
Expand Down Expand Up @@ -1838,7 +1847,7 @@ export const getRrwebEvents = async ({
],
);

let resultSet: ResultSet;
let resultSet: BaseResultSet<Readable>;
await tracer.startActiveSpan('clickhouse.getRrwebEvents', async span => {
span.setAttribute('query', query);

Expand Down Expand Up @@ -1897,7 +1906,7 @@ export const getLogStream = async ({
limit,
});

let resultSet: ResultSet;
let resultSet: BaseResultSet<Readable>;
await tracer.startActiveSpan('clickhouse.getLogStream', async span => {
span.setAttribute('query', query);
span.setAttribute('search', q);
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/routers/api/logs.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Row } from '@clickhouse/client';
import opentelemetry, { SpanStatusCode } from '@opentelemetry/api';
import express from 'express';
import { isNumber, omit, parseInt } from 'lodash';
Expand Down Expand Up @@ -261,7 +262,7 @@ router.get('/stream', async (req, res, next) => {
res.write('event: end\ndata:\n\n');
res.end();
} else {
stream.on('data', (rows: any[]) => {
stream.on('data', (rows: Row[]) => {
resultCount += rows.length;
logger.info(`Sending ${rows.length} rows`);

Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/routers/api/sessions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Row } from '@clickhouse/client';
import opentelemetry, { SpanStatusCode } from '@opentelemetry/api';
import express from 'express';
import { isNumber, parseInt } from 'lodash';
Expand Down Expand Up @@ -83,7 +84,7 @@ router.get('/:sessionId/rrweb', async (req, res, next) => {
offset: offsetNum,
});

stream.on('data', (rows: any[]) => {
stream.on('data', (rows: Row[]) => {
res.write(`${rows.map(row => `data: ${row.text}`).join('\n')}\n\n`);
res.flush();
});
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1272,12 +1272,17 @@
human-id "^1.0.2"
prettier "^2.7.1"

"@clickhouse/client@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@clickhouse/client/-/client-0.1.1.tgz#1a848438baf5deefadf7dcee40ad441c8666c398"
integrity sha512-oeALCAjNFEXHPxMHJgj0QERiLM2ZknOOavvHB1mxmztZLhTuj86HaQEfh9q8x7LgKnv3jep7lb/fhFgD71WTjA==
"@clickhouse/client-common@0.2.7":
version "0.2.7"
resolved "https://registry.yarnpkg.com/@clickhouse/client-common/-/client-common-0.2.7.tgz#c238ef9f5386f7d7a18e09931bb765a4ad4d7ebb"
integrity sha512-vgZm+8c5Cu1toIx1/xplF5dEHlCPw+7pJDOOEtLv2CIUVZ0Bl6nGVZ43EWxRdHeah9ivTfoRWhN1zI1PxjH0xQ==

"@clickhouse/client@^0.2.7":
version "0.2.7"
resolved "https://registry.yarnpkg.com/@clickhouse/client/-/client-0.2.7.tgz#f13103d7a4ab39d86307e6211504f46b8c71faae"
integrity sha512-ZiyarrGngHc+f5AjZSA7mkQfvnE/71jgXk304B0ps8V+aBpE2CsFB6AQmE/Mk2YkP5j+8r/JfG+m0AZWmE27ig==
dependencies:
uuid "^9.0.0"
"@clickhouse/client-common" "0.2.7"

"@cnakazawa/watch@^1.0.3":
version "1.0.4"
Expand Down Expand Up @@ -16466,11 +16471,6 @@ uuid@^8.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

uuid@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5"
integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==

uvu@^0.5.0:
version "0.5.6"
resolved "https://registry.yarnpkg.com/uvu/-/uvu-0.5.6.tgz#2754ca20bcb0bb59b64e9985e84d2e81058502df"
Expand Down
Loading