repo_name stringlengths 1 62 | dataset stringclasses 1
value | lang stringclasses 11
values | pr_id int64 1 20.1k | owner stringlengths 2 34 | reviewer stringlengths 2 39 | diff_hunk stringlengths 15 262k | code_review_comment stringlengths 1 99.6k |
|---|---|---|---|---|---|---|---|
hyperdx | github_2023 | typescript | 209 | hyperdxio | wrn14897 | @@ -751,6 +751,181 @@ Array [
"ts_bucket": 1641341100,
},
]
+`);
+
+ const buildMetricSeriesHistogram = ({
+ tags,
+ name,
+ points,
+ data_type,
+ is_delta,
+ is_monotonic,
+ unit,
+ }: {
+ tags: Record<string, string>;
+ name: string;
+ points: { value:... | this is awesome. I wonder if we can also add points in the next window so we know it works with multiple timestamp buckets |
hyperdx | github_2023 | typescript | 209 | hyperdxio | wrn14897 | @@ -1017,6 +1024,41 @@ export const buildMetricSeriesQuery = async ({
],
);
+ const quantile =
+ aggFn === AggFn.P50
+ ? '0.5'
+ : aggFn === AggFn.P90
+ ? '0.90'
+ : aggFn === AggFn.P95
+ ? '0.95'
+ : '0.99';
+
+ const histogramMetricSource = SqlString.format(
+ `SELECT
+... | maybe we can add `??._string_attributes` here so we know its realiased |
hyperdx | github_2023 | typescript | 209 | hyperdxio | wrn14897 | @@ -1017,6 +1024,41 @@ export const buildMetricSeriesQuery = async ({
],
);
+ const quantile =
+ aggFn === AggFn.P50
+ ? '0.5'
+ : aggFn === AggFn.P90
+ ? '0.90'
+ : aggFn === AggFn.P95
+ ? '0.95'
+ : '0.99';
+
+ const histogramMetricSource = SqlString.format(
+ `SELECT
+... | style suggestion: can we move the comments out from the query itself ? |
hyperdx | github_2023 | typescript | 209 | hyperdxio | wrn14897 | @@ -1017,6 +1024,41 @@ export const buildMetricSeriesQuery = async ({
],
);
+ const quantile =
+ aggFn === AggFn.P50
+ ? '0.5'
+ : aggFn === AggFn.P90
+ ? '0.90'
+ : aggFn === AggFn.P95
+ ? '0.95'
+ : '0.99';
+
+ const histogramMetricSource = SqlString.format( | we can also add a comment here to let people know the implementation doesnt linear interpolate the bucket values |
hyperdx | github_2023 | typescript | 209 | hyperdxio | wrn14897 | @@ -1017,6 +1024,41 @@ export const buildMetricSeriesQuery = async ({
],
);
+ const quantile =
+ aggFn === AggFn.P50
+ ? '0.5'
+ : aggFn === AggFn.P90
+ ? '0.90'
+ : aggFn === AggFn.P95
+ ? '0.95'
+ : '0.99';
+
+ const histogramMetricSource = SqlString.format(
+ `SELECT
+... | can use `MetricsDataType.Histogram` enum |
hyperdx | github_2023 | typescript | 209 | hyperdxio | wrn14897 | @@ -1017,6 +1024,41 @@ export const buildMetricSeriesQuery = async ({
],
);
+ const quantile =
+ aggFn === AggFn.P50
+ ? '0.5'
+ : aggFn === AggFn.P90
+ ? '0.90'
+ : aggFn === AggFn.P95
+ ? '0.95'
+ : '0.99';
+
+ const histogramMetricSource = SqlString.format(
+ `SELECT
+... | nit: I wonder if we want to pass var instead of hard coding the data type here |
hyperdx | github_2023 | typescript | 358 | hyperdxio | MikeShi42 | @@ -0,0 +1,99 @@
+import { FormEvent, useEffect, useState } from 'react'; | Are we not able to re-use the SaveSearchModal instead of creating a new component? |
hyperdx | github_2023 | typescript | 358 | hyperdxio | MikeShi42 | @@ -704,6 +712,37 @@ function SearchPage() {
setShowSaveSearchModal(false);
}}
/>
+ <RenameSearchModal
+ show={renameSearchModalData.show}
+ searchName={selectedSavedSearch?.name ?? ''}
+ onHide={() =>
+ setRenameSearchModalData({
+ show: false,
+... | Do we need to push this route? I'm not sure renaming requires this right? |
hyperdx | github_2023 | typescript | 358 | hyperdxio | MikeShi42 | @@ -685,8 +692,11 @@ function SearchPage() {
</Head>
<SaveSearchModal
show={showSaveSearchModal}
+ mode={saveSearchModalData.mode}
onHide={() => setShowSaveSearchModal(false)}
searchQuery={displayedSearchQuery}
+ searchName={selectedSavedSearch?.name ?? ''}
+ ... | Can't this always be derived from `selectedSavedSearch?._id`? |
hyperdx | github_2023 | typescript | 358 | hyperdxio | MikeShi42 | @@ -461,6 +461,13 @@ function SearchPage() {
);
const [showSaveSearchModal, setShowSaveSearchModal] = useState(false);
+ const [saveSearchModalData, setSaveSearchModalData] = useState<{ | I think this can be combined with `showSaveSearchModal`, maybe can be renamed into something like `saveSearchModalMode` and then just have `'update' | 'save' | 'hidden'` or something like that. |
hyperdx | github_2023 | typescript | 358 | hyperdxio | MikeShi42 | @@ -460,7 +460,9 @@ function SearchPage() {
[searchInput],
);
- const [showSaveSearchModal, setShowSaveSearchModal] = useState(false);
+ const [saveSearchModalMode, setSaveSearchModalMode] = useState<
+ 'update' | 'save' | 'hidden'
+ >('save'); | This need to be initialized as hidden or else it will show up every time the user opens the page |
hyperdx | github_2023 | others | 361 | hyperdxio | wrn14897 | @@ -37,6 +42,7 @@ ENABLE_GO_PARSER="false" \
GO_PARSER_API_URL="http://go-parser:7777" \
ENABLE_TOKEN_MATCHING_CHECK="false" \
vector \
+ -qq \ | nit: imo it would be more readable to use `VECTOR_LOG` |
hyperdx | github_2023 | typescript | 361 | hyperdxio | wrn14897 | @@ -125,13 +126,23 @@ export default function MyApp({ Component, pageProps }: AppPropsWithLayout) {
fetch('/api/config')
.then(res => res.json())
.then(_jsonData => {
+ // Set API url dynamically for users who aren't rebuilding
+ try {
+ const url = new URL(_jsonData.apiServerU... | oh I see. So the hack is we reset this `apiConfigs` global var |
hyperdx | github_2023 | typescript | 361 | hyperdxio | wrn14897 | @@ -699,20 +719,20 @@ const api = {
},
useInstallation() {
return useQuery<any, HTTPError>(`installation`, () =>
- server(`installation`).json(),
+ hdxServer(`installation`).json(), | I assume the default method is GET |
hyperdx | github_2023 | typescript | 361 | hyperdxio | wrn14897 | @@ -20,7 +20,7 @@ export default function PasswordResetPage({
<div>
<Form
className="text-start"
- action={`${API_SERVER_URL}/password-reset`}
+ action={`${SERVER_URL}/password-reset`} | double check that this url won't be updated dynamically, right ? |
hyperdx | github_2023 | others | 148 | hyperdxio | wrn14897 | @@ -0,0 +1,90 @@
+# Starts several services in a single container for local use
+# - Clickhouse
+# - Mongo
+# - Otel Collector (otelcol)
+# - Ingestor (Vector)
+# - API (Node)
+# - Aggregator (Node)
+# - App (Frontend)
+# - Redis Cache
+
+# TODO:
+# - Customize ports, need to set up env vars or relax CORS and other por... | better to use `nvm use` to lock node version |
hyperdx | github_2023 | others | 148 | hyperdxio | wrn14897 | @@ -0,0 +1,90 @@
+# Starts several services in a single container for local use
+# - Clickhouse
+# - Mongo
+# - Otel Collector (otelcol)
+# - Ingestor (Vector)
+# - API (Node)
+# - Aggregator (Node)
+# - App (Frontend)
+# - Redis Cache
+
+# TODO:
+# - Customize ports, need to set up env vars or relax CORS and other por... | we also want to specify vector version (https://github.com/hyperdxio/hyperdx/blob/843cfa3ba8c7ae0f1104f880c77f3c5677591206/.github/workflows/main.yml#L28) |
hyperdx | github_2023 | others | 148 | hyperdxio | wrn14897 | @@ -0,0 +1,90 @@
+# Starts several services in a single container for local use
+# - Clickhouse
+# - Mongo
+# - Otel Collector (otelcol)
+# - Ingestor (Vector)
+# - API (Node)
+# - Aggregator (Node)
+# - App (Frontend)
+# - Redis Cache
+
+# TODO:
+# - Customize ports, need to set up env vars or relax CORS and other por... | version ? |
hyperdx | github_2023 | others | 148 | hyperdxio | wrn14897 | @@ -0,0 +1,11 @@
+#!/bin/bash
+# Meant to be run from the root of the repo
+
+docker build -f ./docker/local/Dockerfile \
+ --build-context clickhouse=./docker/clickhouse \
+ --build-context otel-collector=./docker/otel-collector \
+ --build-context ingestor=./docker/ingestor \
+ --build-context local=./docker/loca... | Is this intentional ? (app context) |
hyperdx | github_2023 | others | 148 | hyperdxio | wrn14897 | @@ -27,6 +27,7 @@
"jsonwebtoken": "^9.0.0",
"lodash": "^4.17.21",
"minimist": "^1.2.7",
+ "mongodb": "^6.3.0", | I think this is supposed to be dev dep ? (for migration script) |
hyperdx | github_2023 | others | 148 | hyperdxio | wrn14897 | @@ -14,7 +14,51 @@
# - Allow persisting settings on disk
# - Limiting persisted data with some auto rotation
-FROM clickhouse/clickhouse-server:23.11.1-alpine AS base
+# Get Node base image to copy over Node binaries
+ARG NODE_VERSION=18.15.0
+FROM node:${NODE_VERSION}-alpine AS node
+
+# == API Builder Image ==
+F... | I would suggest to align the ch version with the prebuilt and dev envs (v23.8.8) |
hyperdx | github_2023 | others | 148 | hyperdxio | wrn14897 | @@ -25,15 +69,25 @@ EXPOSE 1888 4317 4318 55679 13133
RUN apk update
RUN apk add wget shadow
-RUN wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.90.1/otelcol-contrib_0.90.1_linux_arm64.apk
-RUN apk add --allow-untrusted otelcol-contrib_0.90.1_linux_arm64.apk
+RUN wget h... | v0.35.0 |
hyperdx | github_2023 | typescript | 321 | hyperdxio | wrn14897 | @@ -243,3 +245,67 @@ export const deleteAlert = async (id: string, teamId: ObjectId) => {
],
});
};
+
+export const generateSignedAlertSilenceToken = async (
+ id: string,
+ teamId: ObjectId,
+) => {
+ const secret = process.env.EXPRESS_SESSION_SECRET;
+
+ if (!secret) {
+ logger.error(
+ 'EXPRESS_... | nit: would be nice to make silence window size adjustable |
hyperdx | github_2023 | typescript | 321 | hyperdxio | wrn14897 | @@ -606,24 +606,32 @@ export const processAlert = async (now: Date, alert: AlertDocument) => {
checkData,
});
- try {
- await fireChannelEvent({
+ if ((alert.silencedUntil?.getTime() ?? 0) <= now.getTime()) { | nit: maybe its a bit more readable if we do this within fireChannelEvent |
hyperdx | github_2023 | typescript | 338 | hyperdxio | MikeShi42 | @@ -1818,21 +1818,39 @@ export const getMultiSeriesChartLegacyFormat = async ({
const flatData = result.data.flatMap(row => {
if (seriesReturnType === 'column') {
- return series.map((_, i) => {
+ return series.map((s, i) => {
+ const groupBy =
+ s.type === 'number' ? [] : 'groupBy' ... | nit: I think we can replace indexOf with the 3rd arg in the callback to grab the index faster that way |
hyperdx | github_2023 | typescript | 338 | hyperdxio | MikeShi42 | @@ -2550,8 +2568,9 @@ export const checkAlert = async ({
`
SELECT
?
- count(*) as data,
- toUnixTimestamp(toStartOfInterval(timestamp, INTERVAL ?)) as ts_bucket
+ count(*) AS data,
+ any(_string_attributes) AS attributes, | I think we might also need to extract the default properties like service, level, etc. that are in columns as attributes as well. |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -0,0 +1,27 @@
+import { Db, MongoClient } from 'mongodb'; | we don't need the migration if all these fields are optional and the new changes won't break the old records |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -13,6 +14,10 @@ export interface IWebhook {
team: ObjectId;
updatedAt: Date;
url: string;
+ description: string;
+ queryParams: string;
+ headers: string;
+ body: string; | we should add `?` if these are optional |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -28,6 +33,22 @@ const WebhookSchema = new Schema<IWebhook>(
required: true,
},
url: {
+ type: String,
+ required: false, // TODO: should this not be required?
+ },
+ description: {
+ type: String,
+ required: false,
+ },
+ queryParams: {
+ type: String,
+ re... | I wonder if it makes more sense to use `Map` type for headers (https://mongoosejs.com/docs/schematypes.html#maps) |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -444,6 +502,127 @@ describe('checkAlerts', () => {
);
});
+ it('LOG alert - generic webhook', async () => { | ๐ |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -160,27 +161,134 @@ export const notifyChannel = async ({
}),
});
- // ONLY SUPPORTS SLACK WEBHOOKS FOR NOW
if (webhook?.service === 'slack') {
- await slack.postMessageToWebhook(webhook.url, {
- text: message.title,
- blocks: [
- {
- ... | nit: I think we'd need a request-error-tolerant api client here (handling retry for example). Don't need to do it in this PR and we can add it later |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -223,8 +223,8 @@ export const alertSchema = z
// External API Alerts
// ==============================
-export const externalSlackWebhookAlertChannel = z.object({
- type: z.literal('slack_webhook'),
+export const externalWebhookAlertChannel = z.object({
+ type: z.literal('webhook'), | we should still support `slack_webhook` type for backward compatibility reason |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -93,7 +93,7 @@ describe('/api/v1/alerts', () => {
Array [
Object {
"channel": Object {
- "type": "slack_webhook",
+ "type": "webhook", | we still want to test `slack_webhook` here to make sure the translator is working fine |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -223,8 +223,8 @@ export const alertSchema = z
// External API Alerts | I think we need to update zod's `alertSchema` so the validator works properly with the new schema. Also one idea is to use zod to do the parsing to make sure the input string is in JSON stringified format (ref: https://github.com/colinhacks/zod/discussions/2215) |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -28,6 +33,22 @@ const WebhookSchema = new Schema<IWebhook>(
required: true,
},
url: {
+ type: String,
+ required: false, // TODO: should this not be required? | Its not required in EE. In OSS, the url should be required. But I think we can just update the `IWebhook` for now |
hyperdx | github_2023 | others | 337 | hyperdxio | wrn14897 | @@ -99,7 +103,7 @@
"@types/jest": "^28.1.6",
"@types/lodash": "^4.14.186",
"@types/pluralize": "^0.0.29",
- "@types/react": "18.2.23",
+ "@types/react": "^18.2.0", | this seems to cause issue on unit test. any reason for this change ? |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -160,27 +160,144 @@ export const notifyChannel = async ({
}),
});
- // ONLY SUPPORTS SLACK WEBHOOKS FOR NOW
if (webhook?.service === 'slack') {
- await slack.postMessageToWebhook(webhook.url, {
- text: message.title,
- blocks: [
- {
- ... | nit: I wonder if we can use `tmpURL.searchParams.append(xxx, yyy)` (since queryParams is an object) |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -160,27 +160,144 @@ export const notifyChannel = async ({
}),
});
- // ONLY SUPPORTS SLACK WEBHOOKS FOR NOW
if (webhook?.service === 'slack') {
- await slack.postMessageToWebhook(webhook.url, {
- text: message.title,
- blocks: [
- {
- ... | nit: `??` is probably what we want here ? |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -160,27 +160,144 @@ export const notifyChannel = async ({
}),
});
- // ONLY SUPPORTS SLACK WEBHOOKS FOR NOW
if (webhook?.service === 'slack') {
- await slack.postMessageToWebhook(webhook.url, {
- text: message.title,
- blocks: [
- {
- ... | nit: trying to understand why we stringify and parse the body field instead of just iterating through values |
hyperdx | github_2023 | typescript | 337 | hyperdxio | wrn14897 | @@ -3,6 +3,17 @@ import mongoose, { Schema } from 'mongoose';
export enum WebhookService {
Slack = 'slack',
+ Generic = 'generic',
+}
+
+interface MongooseMap extends Map<string, string> {
+ // https://mongoosejs.com/docs/api/map.html#MongooseMap.prototype.toJSON()
+ // Converts this map to a native JavaScript... | so we need to set `flattenMaps` to true to convert the document to JSON ? not very intuitive |
hyperdx | github_2023 | typescript | 334 | hyperdxio | ellipsis-dev[bot] | @@ -599,6 +601,55 @@ export default function ServiceDashboardPage() {
</Grid.Col>
</Grid>
</Tabs.Panel>
+ <Tabs.Panel value="errors">
+ <Grid>
+ <Grid.Col span={12}>
+ <Card p="md">
+ <Card.Section p="md" py="xs" wit... | The level filter in the scopeWhereQuery function should be 'level:"error"' instead of 'level:error' to correctly filter the logs.
```suggestion
where: scopeWhereQuery('level:"error"'),
``` |
hyperdx | github_2023 | typescript | 331 | hyperdxio | ellipsis-dev[bot] | @@ -465,16 +472,31 @@ export function MetricNameSelect({
}, [metricNamesData]);
return (
- <AsyncSelect
- isLoading={isLoading}
- isDisabled={isError}
+ <MSelect
+ disabled={isLoading || isError}
+ variant="filled"
placeholder={
isLoading
? 'Loading...'
... | The AsyncSelect component is still being returned at the end of the MetricNameSelect function. This seems redundant as the MSelect component is already being returned earlier in the function. Consider removing this redundant return statement. |
hyperdx | github_2023 | typescript | 331 | hyperdxio | ellipsis-dev[bot] | @@ -2,7 +2,13 @@ import { useMemo, useRef, useState } from 'react';
import { add } from 'date-fns';
import Select from 'react-select';
import AsyncSelect from 'react-select/async'; | This import of AsyncSelect is no longer used and should be removed to keep the code clean. |
hyperdx | github_2023 | typescript | 331 | hyperdxio | ellipsis-dev[bot] | @@ -441,6 +447,7 @@
</>
);
}
+import { Autocomplete } from '@mantine/core'; | This import of Autocomplete is not used and should be removed to keep the code clean. |
hyperdx | github_2023 | typescript | 331 | hyperdxio | ellipsis-dev[bot] | @@ -465,34 +472,26 @@
}, [metricNamesData]);
return (
- <AsyncSelect
- isLoading={isLoading}
- isDisabled={isError}
+ <MSelect | The MSelect component should include a similar filtering functionality to the loadOptions prop of the AsyncSelect component it replaced. This will prevent potential performance issues if the options list is very large. |
hyperdx | github_2023 | typescript | 314 | hyperdxio | MikeShi42 | @@ -1,56 +1,75 @@
import { memo } from 'react';
import api from './api';
-import type { AggFn, NumberFormat } from './types';
+import { Granularity } from './ChartUtils';
+import type { AggFn, ChartSeries, NumberFormat } from './types';
import { formatNumber } from './utils';
const HDXNumberChart = memo(
({
... | Do you think we can just use the multi-series for everything here? |
hyperdx | github_2023 | typescript | 316 | hyperdxio | MikeShi42 | @@ -697,6 +727,10 @@ export default function DashboardPage() {
chart={chart}
dateRange={searchedTimeRange}
onEditClick={() => setEditedChart(chart)}
+ onAddAlertClick={() => {
+ setIsAddingAlert(true); | I'm curious if it would've been possible instead of having a boolean here to set the `alert` property to either the actual chart alert or `DEFAULT_ALERT` at this level instead of needing to depend on a useEffect? That feels a bit cleaner, but maybe there's some details that make it more annoying/harder to implement. |
hyperdx | github_2023 | typescript | 326 | hyperdxio | ellipsis-dev[bot] | @@ -206,11 +253,36 @@ export const buildAlertMessageTemplateTitle = ({
throw new Error(`Unsupported alert source: ${(alert as any).source}`);
};
+
+export const getDefaultExternalAction = (
+ alert: AlertMessageTemplateDefaultView['alert'],
+) => {
+ if (
+ alert.channel.type === 'slack_webhook' &&
+ aler... | The function `buildAlertMessageTemplateBody` is quite large and complex. Consider breaking it down into smaller, more manageable functions to improve readability and maintainability. |
hyperdx | github_2023 | typescript | 326 | hyperdxio | ellipsis-dev[bot] | @@ -133,6 +131,48 @@ type AlertMessageTemplateDefaultView = {
};
value: number;
};
+export const notifyChannel = async ({
+ channel,
+ id,
+ message,
+ teamId,
+}: {
+ channel: AlertMessageTemplateDefaultView['alert']['channel']['type'];
+ id: string;
+ message: {
+ hdxLink: string;
+ title: string;... | This function should handle the case where the webhook is not found in the database. Consider adding a check for whether the webhook is null and handle it appropriately. |
hyperdx | github_2023 | typescript | 326 | hyperdxio | ellipsis-dev[bot] | @@ -256,85 +369,43 @@
.join('\n'),
2500,
);
- return `${group ? `Group: "${group}"` : ''}
+ rawTemplateBody = `${group ? `Group: "${group}"` : ''}
${value} lines found, expected ${
alert.threshold_type === 'above' ? 'less than' : 'greater than'
} ${alert.threshold} lines
-${rende... | Consider simplifying this complex ternary operation. You could create a separate function to handle this logic or use a more straightforward control flow structure like if-else statements. |
hyperdx | github_2023 | typescript | 326 | hyperdxio | ellipsis-dev[bot] | @@ -133,6 +131,55 @@ type AlertMessageTemplateDefaultView = {
};
value: number;
};
+export const notifyChannel = async ({
+ channel,
+ id,
+ message,
+ teamId,
+}: {
+ channel: AlertMessageTemplateDefaultView['alert']['channel']['type'];
+ id: string;
+ message: {
+ hdxLink: string;
+ title: string;... | Consider adding error handling to manage scenarios where the `id` provided does not exist in the database. This will improve the robustness of the `notifyChannel` function. |
hyperdx | github_2023 | typescript | 326 | hyperdxio | ellipsis-dev[bot] | @@ -133,6 +132,55 @@ type AlertMessageTemplateDefaultView = {
};
value: number;
};
+export const notifyChannel = async ({
+ channel,
+ id,
+ message,
+ teamId,
+}: {
+ channel: AlertMessageTemplateDefaultView['alert']['channel']['type'];
+ id: string;
+ message: {
+ hdxLink: string;
+ title: string;... | The regular expression used to match the prefix of the webhook name is not safe. It does not escape special characters, which could lead to unexpected behavior or security vulnerabilities. Consider using a library or function to escape special characters in the `id` before constructing the regular expression.
```sugge... |
hyperdx | github_2023 | typescript | 326 | hyperdxio | ellipsis-dev[bot] | @@ -177,40 +225,71 @@ export const buildAlertMessageTemplateTitle = ({
view: AlertMessageTemplateDefaultView;
}) => {
const { alert, dashboard, savedSearch, value } = view;
+ const handlebars = Handlebars.create(); | Consider refactoring this complex ternary operation to improve code readability. |
hyperdx | github_2023 | typescript | 318 | hyperdxio | MikeShi42 | @@ -404,14 +373,14 @@ describe('checkAlerts', () => {
1,
'https://hooks.slack.com/services/123',
{
- text: 'Alert for "Max Duration" in "My Dashboard" - 102 exceeds 10',
blocks: [
{
text: {
text: [
`*<http://l... | nit: should we just `trim()` the rendered string so we don't send extra new lines? |
hyperdx | github_2023 | typescript | 263 | hyperdxio | wrn14897 | @@ -0,0 +1,205 @@
+import express, { NextFunction, Request, Response } from 'express';
+import _ from 'lodash';
+import { z } from 'zod';
+import { validateRequest } from 'zod-express-middleware';
+
+import {
+ createAlert,
+ deleteAlert,
+ getAlerts,
+ updateAlert,
+ validateGroupByProperty,
+} from '@/controller... | shouldn't we throw here ? |
hyperdx | github_2023 | typescript | 263 | hyperdxio | wrn14897 | @@ -93,22 +97,129 @@ const makeAlert = (alert: AlertInput) => {
};
};
-export const createAlert = async (teamId: ObjectId, alertInput: AlertInput) => {
+export const createAlert = async (
+ teamId: ObjectId,
+ alertInput: z.infer<typeof alertSchema>,
+) => {
+ if (alertInput.source === 'CHART') { | nit: I feel it would be cleaner if `AlertSource` is an enum |
hyperdx | github_2023 | typescript | 301 | hyperdxio | wrn14897 | @@ -27,7 +27,7 @@ const registrationSchema = z
'Password must include at least one number',
)
.refine(
- pass => /[!@#$%^&*(),.?":{}|<>]/.test(pass),
+ pass => /[!@#$%^&*(),.?":{}|<>-]/.test(pass), | can we also add `;` to the list ? |
hyperdx | github_2023 | typescript | 301 | hyperdxio | wrn14897 | @@ -27,7 +27,7 @@ const registrationSchema = z
'Password must include at least one number',
)
.refine(
- pass => /[!@#$%^&*(),.?":{}|<>]/.test(pass),
+ pass => /[!@#$%^&*(),.?":{}|<>;-]/.test(pass), | I realized = + are also missing |
hyperdx | github_2023 | typescript | 288 | hyperdxio | wrn14897 | @@ -172,7 +176,7 @@ export function seriesToSearchQuery({
aggFn !== 'count' && field ? ` ${field}:*` : ''
}${
'groupBy' in s && s.groupBy != null && s.groupBy.length > 0
- ? ` ${s.groupBy}:${groupByValue}`
+ ? ` ${s.groupBy}:${groupByValue ?? '*'}` | groupBy * ? |
hyperdx | github_2023 | typescript | 276 | hyperdxio | wrn14897 | @@ -19,6 +19,38 @@ export async function deleteDashboardAndAlerts(
}
}
+export async function updateDashboard(
+ dashboardId: string,
+ teamId: ObjectId,
+ {
+ name,
+ charts,
+ query,
+ tags,
+ }: {
+ name: string;
+ charts: z.infer<typeof chartSchema>[];
+ query: string;
+ tags: z.in... | nit: I assume we can reuse `updateDashboard` in here |
hyperdx | github_2023 | others | 283 | hyperdxio | MikeShi42 | @@ -205,6 +205,7 @@ services:
CLICKHOUSE_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
CLICKHOUSE_PASSWORD: api
CLICKHOUSE_USER: api
+ DEBUG: 'http-graceful-shutdown' | do we want to keep this? |
hyperdx | github_2023 | typescript | 279 | hyperdxio | wrn14897 | @@ -0,0 +1,87 @@
+import opentelemetry, { SpanStatusCode } from '@opentelemetry/api';
+import express from 'express';
+import _ from 'lodash';
+import { z } from 'zod';
+import { validateRequest } from 'zod-express-middleware';
+
+import * as clickhouse from '@/clickhouse';
+import { getTeam } from '@/controllers/team'... | oh this is cool |
hyperdx | github_2023 | typescript | 279 | hyperdxio | wrn14897 | @@ -0,0 +1,87 @@
+import opentelemetry, { SpanStatusCode } from '@opentelemetry/api';
+import express from 'express';
+import _ from 'lodash';
+import { z } from 'zod';
+import { validateRequest } from 'zod-express-middleware';
+
+import * as clickhouse from '@/clickhouse';
+import { getTeam } from '@/controllers/team'... | nit: can do this after team validation |
hyperdx | github_2023 | typescript | 279 | hyperdxio | wrn14897 | @@ -0,0 +1,190 @@
+import { z } from 'zod';
+
+import type { IDashboard } from '@/models/dashboard';
+import {
+ chartSchema,
+ externalChartSchema,
+ externalChartSchemaWithId,
+ histogramChartSeriesSchema,
+ markdownChartSeriesSchema,
+ numberChartSeriesSchema,
+ searchChartSeriesSchema,
+ tableChartSeriesSch... | do we want to make this guy camelcase ? |
hyperdx | github_2023 | typescript | 142 | hyperdxio | MikeShi42 | @@ -120,6 +120,7 @@ const api = {
const endTime = endDate.getTime();
// FIXME: pass metric name and type separately
+ if (!name.includes(' - ')) return; | I think this should be throwing a react error as this will cause a different number of hooks to run from render to render.
I'm not sure what the intent is, but I suspect we want to be actually toggling the `enabled` property of the react-query query. I also suspect we want to add this logic in the component rather t... |
hyperdx | github_2023 | typescript | 244 | hyperdxio | MikeShi42 | @@ -75,7 +70,7 @@ const AlertSchema = new Schema<IAlert>(
type: String,
required: true,
},
- channel: Schema.Types.Mixed, // slack, email, etc
+ channel: mongoose.Schema.Types.Mixed, | Reading more, I think this is intending to be a objectid pointing to a doc in the channel collection right? |
hyperdx | github_2023 | typescript | 253 | hyperdxio | MikeShi42 | @@ -1019,6 +1024,71 @@ export const buildMetricSeriesQuery = async ({
],
);
+ const quantile =
+ aggFn === AggFn.P50
+ ? '0.5'
+ : aggFn === AggFn.P90
+ ? '0.90'
+ : aggFn === AggFn.P95
+ ? '0.95'
+ : '0.99';
+
+ const histogramMetricSource = SqlString.format(
+ `
+ ... | We should use a NaN here/filter out this point somehow since we can't rely on the point value itself. |
hyperdx | github_2023 | typescript | 253 | hyperdxio | MikeShi42 | @@ -1019,6 +1024,71 @@ export const buildMetricSeriesQuery = async ({
],
);
+ const quantile =
+ aggFn === AggFn.P50
+ ? '0.5'
+ : aggFn === AggFn.P90
+ ? '0.90'
+ : aggFn === AggFn.P95
+ ? '0.95'
+ : '0.99';
+
+ const histogramMetricSource = SqlString.format(
+ `
+ ... | we should also check that the last bucket is actually infinite before substituting the 2nd to last bucket |
hyperdx | github_2023 | typescript | 253 | hyperdxio | MikeShi42 | @@ -1019,6 +1024,71 @@ export const buildMetricSeriesQuery = async ({
],
);
+ const quantile =
+ aggFn === AggFn.P50
+ ? '0.5'
+ : aggFn === AggFn.P90
+ ? '0.90'
+ : aggFn === AggFn.P95
+ ? '0.95'
+ : '0.99';
+
+ const histogramMetricSource = SqlString.format(
+ `
+ ... | If the bucket boundary is greater than 0, we should interpolate from 0 to bucket boundary. If it's less than 0, we should do this logic of returning the lowest bucket. |
hyperdx | github_2023 | typescript | 253 | hyperdxio | MikeShi42 | @@ -1019,6 +1024,71 @@ export const buildMetricSeriesQuery = async ({
],
);
+ const quantile =
+ aggFn === AggFn.P50
+ ? '0.5'
+ : aggFn === AggFn.P90
+ ? '0.90'
+ : aggFn === AggFn.P95
+ ? '0.95'
+ : '0.99';
+
+ const histogramMetricSource = SqlString.format(
+ `
+ ... | I think we need one more CTE at the top here to properly calculate the group by request from the user, that aggregates bucket counts of all timeseries in a given group. (Ex. add up the counts for all 50 servers in one AWS region, if I wanted to group by AWS region) |
hyperdx | github_2023 | typescript | 268 | hyperdxio | MikeShi42 | @@ -747,6 +780,22 @@ export default function SearchPage() {
setShowSaveSearchModal(true);
}}
/>
+ <Tags | We probably need to add a check to ensure the user is actually looking at a saved search, and hide otherwise. |
hyperdx | github_2023 | typescript | 267 | hyperdxio | wrn14897 | @@ -0,0 +1,373 @@
+import express from 'express';
+import { uniq } from 'lodash';
+import { ObjectId } from 'mongodb';
+import { z } from 'zod';
+import { validateRequest } from 'zod-express-middleware';
+
+import {
+ deleteDashboardAndAlerts,
+ updateDashboardAndAlerts,
+} from '@/controllers/dashboard';
+import Das... | do we need limit and offset for this guy ? |
hyperdx | github_2023 | typescript | 267 | hyperdxio | wrn14897 | @@ -0,0 +1,373 @@
+import express from 'express';
+import { uniq } from 'lodash';
+import { ObjectId } from 'mongodb';
+import { z } from 'zod';
+import { validateRequest } from 'zod-express-middleware';
+
+import {
+ deleteDashboardAndAlerts,
+ updateDashboardAndAlerts,
+} from '@/controllers/dashboard';
+import Das... | we might want to expose sort query to the user (like name or createdAt) |
hyperdx | github_2023 | typescript | 261 | hyperdxio | MikeShi42 | @@ -507,6 +507,140 @@ const NodesTable = ({
);
};
+const NamespacesTable = ({
+ where,
+ dateRange,
+}: {
+ where: string;
+ dateRange: [Date, Date];
+}) => {
+ const groupBy = ['k8s.namespace.name'];
+
+ const { data, isError, isLoading } = api.useMultiSeriesChart({
+ series: [
+ {
+ table: ... | I think it makes more sense to show the aggregate CPU and memory usage via a `sum` here |
hyperdx | github_2023 | typescript | 261 | hyperdxio | MikeShi42 | @@ -507,6 +507,140 @@ const NodesTable = ({
);
};
+const NamespacesTable = ({
+ where,
+ dateRange,
+}: {
+ where: string;
+ dateRange: [Date, Date];
+}) => {
+ const groupBy = ['k8s.namespace.name'];
+
+ const { data, isError, isLoading } = api.useMultiSeriesChart({
+ series: [
+ {
+ table: ... | I think we'd want to use `last_value` here |
hyperdx | github_2023 | typescript | 261 | hyperdxio | MikeShi42 | @@ -848,7 +982,61 @@ export default function KubernetesDashboardPage() {
</Grid.Col>
</Grid>
</Tabs.Panel>
- <Tabs.Panel value="namespaces">Namespaces</Tabs.Panel>
+ <Tabs.Panel value="namespaces">
+ <Grid>
+ <Grid.Col span={6}>
+ ... | same here I think we'd want `sum` for cpu/mem |
hyperdx | github_2023 | typescript | 260 | hyperdxio | MikeShi42 | @@ -472,30 +479,37 @@ const NodesTable = ({
) : (
<tbody>
{nodesList.map(node => (
- <tr key={node.name}>
- <td>{node.name || 'N/A'}</td>
- <td>
- {node.ready === 1 ? (
- ... | any chance we can add anchor tags to these so they're more clicky? |
hyperdx | github_2023 | typescript | 260 | hyperdxio | MikeShi42 | @@ -0,0 +1,286 @@
+import * as React from 'react';
+import Link from 'next/link';
+import Drawer from 'react-modern-drawer';
+import { StringParam, useQueryParam, withDefault } from 'use-query-params';
+import {
+ Anchor,
+ Badge,
+ Card,
+ Flex,
+ Grid,
+ SegmentedControl,
+ Text,
+} from '@mantine/core';
+
+im... | When clicking on the pod table here, the side panel gets obscured behind since it's triggering it in the "wrong" z index context. I wonder if we still need to import side panels like we do with the log side panel (along with the table, instead of just globally on a page). |
hyperdx | github_2023 | typescript | 260 | hyperdxio | MikeShi42 | @@ -0,0 +1,286 @@
+import * as React from 'react';
+import Link from 'next/link';
+import Drawer from 'react-modern-drawer';
+import { StringParam, useQueryParam, withDefault } from 'use-query-params';
+import {
+ Anchor,
+ Badge,
+ Card,
+ Flex,
+ Grid,
+ SegmentedControl,
+ Text,
+} from '@mantine/core';
+
+im... | probably want `last_value` for both of these |
hyperdx | github_2023 | typescript | 256 | hyperdxio | svc-shorpo | @@ -528,6 +507,43 @@ const NodesTable = ({
);
};
+const K8sMetricTagValueSelect = ({
+ metricAttribute,
+ searchQuery,
+ setSearchQuery,
+ placeholder,
+ dropdownClosedWidth,
+ icon,
+}: {
+ metricAttribute: string;
+ searchQuery: string;
+ setSearchQuery: (query: string) => void;
+ placeholder: string;... | hmm |
hyperdx | github_2023 | typescript | 252 | hyperdxio | MikeShi42 | @@ -431,3 +431,16 @@ export const formatNumber = (
(options.unit ? ` ${options.unit}` : '')
);
};
+
+// format uptime as days, hours, minutes or seconds
+export const formatUptime = (seconds: number) => {
+ if (seconds < 60) {
+ return `${seconds}s`;
+ } else if (seconds < 60 * 60) {
+ return `${Math.f... | Would https://date-fns.org/v3.2.0/docs/formatDistance or `formatDistanceToNowStrictShort` (in the utils) not work here? |
hyperdx | github_2023 | typescript | 237 | hyperdxio | MikeShi42 | @@ -18,11 +19,16 @@ router.post('/', async (req, res, next) => {
}
const logView = await new LogView({
name,
+ tags,
query: `${query}`,
team: teamId,
creator: userId,
}).save();
-
+ if (tags?.length) {
+ redisClient.del(`tags:${teamId}`).catch(e => { | my 2c is that we should avoid caching complexity until it's warranted. I think for now avoiding caching and just reading directly from mongo would be perfect. Usually just long CH-operations warrant caching (and even then I try to push for cache-less approaches)
Though @wrn14897 maintains the backend so I'll defer t... |
hyperdx | github_2023 | typescript | 237 | hyperdxio | MikeShi42 | @@ -144,4 +148,43 @@ router.patch('/apiKey', async (req, res, next) => {
}
});
+router.get('/tags', async (req, res, next) => {
+ try {
+ const teamId = req.user?.team;
+ if (teamId == null) {
+ throw new Error(`User ${req.user?._id} not associated with a team`);
+ }
+ const simpleCache = new Si... | We've gotten a bit loose with our standards recently, but our preference is actually that mongoose code lives under a controller, maybe under the `controllers/team.ts` in this case - so that we can encapsulate data fetching separate from router logic. I know that several of our routes don't do this but we've recently t... |
hyperdx | github_2023 | typescript | 237 | hyperdxio | wrn14897 | @@ -31,3 +33,24 @@ export function getTeamByApiKey(apiKey: string) {
export function rotateTeamApiKey(teamId: ObjectId) {
return Team.findByIdAndUpdate(teamId, { apiKey: uuidv4() }, { new: true });
}
+
+export async function getTags(teamId: ObjectId) {
+ const dashboardTags = await Dashboard.aggregate([
+ { $m... | we can fetch these concurrently |
hyperdx | github_2023 | typescript | 237 | hyperdxio | wrn14897 | @@ -106,15 +107,15 @@ router.post(
return res.sendStatus(403);
}
- const { name, charts, query } = req.body ?? {};
+ const { name, charts, query, tags } = req.body ?? {}; | we might want to assert the uniqueness of tagging values and also enforce the size limit |
hyperdx | github_2023 | typescript | 237 | hyperdxio | wrn14897 | @@ -108,12 +108,13 @@ router.post(
}
const { name, charts, query, tags } = req.body ?? {};
+
// Create new dashboard from name and charts
const newDashboard = await new Dashboard({
name,
charts,
query,
- tags,
+ tags: tags && uniq(tags), | double check that we want to assign this undefined instead empty array ? |
hyperdx | github_2023 | typescript | 249 | hyperdxio | wrn14897 | @@ -652,3 +652,21 @@ export const buildSearchQueryWhereCondition = async ({
builder.teamId = teamId;
return await builder.timestampInBetween(startTime, endTime).build();
};
+
+export const buildPostGroupWhereCondition = ({ query }: { query: string }) => { | nit: I wonder why we don't pass query string directly |
hyperdx | github_2023 | typescript | 251 | hyperdxio | wrn14897 | @@ -37,7 +37,7 @@ export const timeChartSeriesSchema = z.object({
aggFn: aggFnSchema,
field: z.union([z.string(), z.undefined()]),
where: z.string(),
- groupBy: z.array(z.string()),
+ groupBy: z.array(z.string()).max(10), | ๐ |
hyperdx | github_2023 | typescript | 250 | hyperdxio | wrn14897 | @@ -189,6 +190,27 @@ export class SQLSerializer implements Serializer {
};
}
+ operator(op: lucene.Operator) {
+ switch (op) {
+ case 'NOT':
+ case 'AND NOT':
+ return 'AND NOT';
+ case 'OR NOT':
+ return 'OR NOT';
+ // @ts-ignore TODO: Types need to be fixed upstream
+ ... | nit: use `IMPLICIT_FIELD` ? |
hyperdx | github_2023 | typescript | 242 | hyperdxio | MikeShi42 | @@ -14,3 +14,4 @@ export const IS_OSS = process.env.NEXT_PUBLIC_IS_OSS ?? 'true' === 'true';
export const METRIC_ALERTS_ENABLED = process.env.NODE_ENV === 'development';
export const K8S_METRICS_ENABLED = process.env.NODE_ENV === 'development';
export const SERVICE_DASHBOARD_ENABLED = process.env.NODE_ENV === 'devel... | just a note for next time - we're starting to think of using specific env flags for specific features ex. `NEXT_PUBLIC_DEV_K8S_DASHBOARD_ENABLED`, this makes it easier to opt-in/out of UI on various environments like being able to do more dogfooding in staging without mucking NODE_ENV there.
Let's ship this as-is an... |
hyperdx | github_2023 | typescript | 235 | hyperdxio | MikeShi42 | @@ -0,0 +1,168 @@
+import * as React from 'react';
+import { useRouter } from 'next/router';
+import { SpotlightAction, SpotlightProvider } from '@mantine/spotlight';
+
+import api from './api';
+import { SERVICE_DASHBOARD_ENABLED } from './config';
+import Logo from './Icon';
+
+const useSpotlightActions = () => {
+ ... | this should go to https://www.hyperdx.io/docs |
hyperdx | github_2023 | typescript | 234 | hyperdxio | MikeShi42 | @@ -645,7 +645,7 @@ export default function SearchPage() {
}, [setResultsMode]);
return (
- <div className="LogViewerPage d-flex" style={{ height: '100vh' }}> | Testing out locally I suspect this is breaking the search table scroll behavior (we're scrolling the page instead of the search results) |
hyperdx | github_2023 | typescript | 231 | hyperdxio | jaggederest | @@ -514,6 +517,27 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
: 'ok' // All alerts are green
: 'none'; // No alerts are set up
+ const [searchesListQ, setSearchesListQ] = useState(''); | Could consider using local storage here and for `dashboardsListQ`, too. |
hyperdx | github_2023 | typescript | 231 | hyperdxio | jaggederest | @@ -514,6 +517,27 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
: 'ok' // All alerts are green
: 'none'; // No alerts are set up
+ const [searchesListQ, setSearchesListQ] = useState('');
+ const [dashboardsListQ, setDashboardsListQ] = useState('');
+
+ const filteredSe... | Nit: These are probably a candidate for future refactoring into a function since they look identical except the `logViews` and `searchesListQ` parameter differences ๐ |
hyperdx | github_2023 | typescript | 231 | hyperdxio | jaggederest | @@ -808,41 +851,54 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
query.config !=
JSON.stringify(REDIS_DASHBOARD_CONFIG) &&
query.config != JSON.stringify(MONGO_DASHBOARD_CONFIG)
- ? 'text-su... | Nit: Should probably match the `No results matching <i>{searchesListQ}</i>` style above |
hyperdx | github_2023 | typescript | 231 | hyperdxio | MikeShi42 | @@ -426,6 +423,64 @@ function PresetSearchLink({ query, name }: { query: string; name: string }) {
);
}
+function SearchInput({
+ placeholder,
+ value,
+ onChange,
+}: {
+ placeholder: string;
+ value: string;
+ onChange: (arg0: string) => void;
+}) {
+ return (
+ <Input
+ placeholder={placeholder}... | just an fyi, we do have fuse.js already included and can use it in the future as well for fancy search :) |
hyperdx | github_2023 | typescript | 231 | hyperdxio | MikeShi42 | @@ -592,58 +665,90 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
/>
)}
</div>
- {isSearchExpanded && !isCollapsed && (
- <>
- <div className="fw-bold text-light fs-8 ms-3 mt-3">
- SAVED SEA... | Just dup'ing the same message in chat, not totally sold on using `Live Tail` for empty state, I think ideally we still try to hint to the user as much as we can that they can create saved searches. |
hyperdx | github_2023 | typescript | 200 | hyperdxio | wrn14897 | @@ -1,6 +1,16 @@
+export type JSONBlob = Record<string, Json>;
+
+export type Json =
+ | string
+ | number
+ | boolean
+ | null
+ | Json[]
+ | { [key: string]: Json }; | This can be `JSONBlob` |
hyperdx | github_2023 | typescript | 200 | hyperdxio | wrn14897 | @@ -123,7 +121,7 @@ export const mapObjectToKeyValuePairs = async (
const pushArray = (
type: 'bool' | 'number' | 'string',
keyPath: string,
- value: any,
+ value: number | string, // Note that booleans are converted to 0 or 1 | ๐ |
hyperdx | github_2023 | typescript | 200 | hyperdxio | wrn14897 | @@ -247,17 +245,26 @@ export type VectorMetric = {
v: number; // value
};
-abstract class ParsingInterface<T> {
- abstract _parse(
- log: T,
- ...args: any[]
- ): Promise<LogStreamModel | MetricModel | RrwebEventModel>;
+const convertToStringMap = (blob: JSONBlob) => { | Can we leave non-type changes to another PR ? What is this change about ? Any chance we can reuse `mapObjectToKeyValuePairs` ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.