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
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) => { + const output: Record<string, stri...
I think we should just check if `stringifiedValue !== null`. To me, this is easier to understand: ``` if (stringifiedValue !== null) { output[keyPath.join('.')] = stringifiedValue; } ```
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) => { + const output: Record<string, stri...
no need for async/await
hyperdx
github_2023
typescript
200
hyperdxio
wrn14897
@@ -229,17 +227,14 @@ export type VectorMetric = { v: number; // value }; -abstract class ParsingInterface<T> { - abstract _parse( - log: T, - ...args: any[] - ): LogStreamModel | MetricModel | RrwebEventModel; +abstract class ParsingInterface<T, S> { + abstract _parse(log: T): S; - parse(logs: T[], ....
this is critical. we can't remove this `...args`
hyperdx
github_2023
typescript
200
hyperdxio
wrn14897
@@ -282,10 +277,30 @@ class VectorLogParser extends ParsingInterface<VectorLog> { } } -class VectorMetricParser extends ParsingInterface<VectorMetric> { +export const convertToStringMap = (obj: JSONBlob) => { + const mapped = mapObjectToKeyValuePairs(obj); + const converted_string_attrs: Record<string, string> ...
can we rollback this for now ? I'd prefer this to be applied in following PR. ideally, this PR should only update types
hyperdx
github_2023
typescript
200
hyperdxio
wrn14897
@@ -282,10 +277,10 @@ class VectorLogParser extends ParsingInterface<VectorLog> { } } -class VectorMetricParser extends ParsingInterface<VectorMetric> { +class VectorMetricParser extends ParsingInterface<VectorMetric, MetricModel> { _parse(metric: VectorMetric): MetricModel { return { - _string_attri...
nit: we can leave a TODO note here if you want to
hyperdx
github_2023
typescript
217
hyperdxio
MikeShi42
@@ -18,6 +19,79 @@ import styles from '../styles/LogSidePanel.module.scss'; const CHART_HEIGHT = 300; const defaultTimeRange = parseTimeQuery('Past 1h', false); +const PodDetailsProperty = React.memo( + ({ label, value }: { label: string; value?: string }) => { + if (!value) return null; + return ( + <d...
hrmm this might be a bit expensive to pull this data as this will cause us to scan all rows in the db over the time range. We can probably use `useLogBatch` with limit 1 and extra fields set to those properties, which will just scan for 1 row of data and return immediately.
hyperdx
github_2023
others
212
hyperdxio
jaggederest
@@ -1,7 +1,18 @@ +[sinks.go_parser] +type = "http" +uri = "http://go-parser:7777" +inputs = ["go_spans"] # only send spans for now +compression = "gzip" +encoding.codec = "json" +batch.max_bytes = 10485760 # 10MB, required for rrweb payloads
Do we want rrweb spans? They should never have a db.statement right? Just double checking
hyperdx
github_2023
go
212
hyperdxio
jaggederest
@@ -0,0 +1,167 @@ +package main + +import ( + "bytes" + "compress/gzip" + "encoding/json" + "fmt" + "io" + "net/http" + "os" + "slices" + "time" + + "github.com/DataDog/go-sqllexer" + "github.com/gin-gonic/gin" + "github.com/hashicorp/go-retryablehttp" + "github.com/xwb1989/sqlparser" +) + +var ( + VERSION = "0....
I think Cassandra is close enough to parse with sql-lexer, for now.
hyperdx
github_2023
go
212
hyperdxio
jaggederest
@@ -0,0 +1,167 @@ +package main + +import ( + "bytes" + "compress/gzip" + "encoding/json" + "fmt" + "io" + "net/http" + "os" + "slices" + "time" + + "github.com/DataDog/go-sqllexer" + "github.com/gin-gonic/gin" + "github.com/hashicorp/go-retryablehttp" + "github.com/xwb1989/sqlparser" +) + +var ( + VERSION = "0....
Couchbase is sql-like
hyperdx
github_2023
typescript
193
hyperdxio
wrn14897
@@ -1516,6 +1516,112 @@ export const getMultiSeriesChartLegacyFormat = async ({ }; }; +// This query needs to be generalized and replaced once use-case matures +export const getSpanPerformanceChart = async ({ + parentSpanWhere, + childrenSpanWhere, + teamId, + tableVersion, + maxNumGroups, + propertyTypeMap...
nit: can do this concurrently ?
hyperdx
github_2023
typescript
198
hyperdxio
MikeShi42
@@ -1130,8 +1138,14 @@ const buildEventSeriesQuery = async ({ const label = SqlString.escape(`${aggFn}(${field})`); const selectClause = [ - isCountFn + aggFn === AggFn.Count ? 'toFloat64(count()) as data' + : aggFn === AggFn.CountPerSec + ? "divide(count(), age('ss', MIN(timestamp), MAX(...
shouldn't it be divided by the diff of the time range given by the user? (I noticed this issue from the test values showing 0.75 for the rate instead of what I'd calculate by hand to be 0.6)
hyperdx
github_2023
typescript
198
hyperdxio
jaggederest
@@ -1130,8 +1138,35 @@ const buildEventSeriesQuery = async ({ const label = SqlString.escape(`${aggFn}(${field})`); const selectClause = [ - isCountFn + aggFn === AggFn.Count ? 'toFloat64(count()) as data' + : aggFn === AggFn.CountPerSec + ? granularity + ? SqlString.format('divide...
Fine for now, but I tend to think these kind of duplicates are safer as `CountPer('second')` or equivalent. Maybe a TODO here
hyperdx
github_2023
typescript
194
hyperdxio
wrn14897
@@ -233,13 +251,13 @@ abstract class ParsingInterface<T> { abstract _parse( log: T, ...args: any[] - ): LogStreamModel | MetricModel | RrwebEventModel; + ): Promise<LogStreamModel | MetricModel | RrwebEventModel>; - parse(logs: T[], ...args: any[]) { + async parse(logs: T[], ...args: any[]) { co...
Can we type this `parsedLogs` here ? I think that's the reason why ts didn't pick it up. Also its better to double check all any types in this file
hyperdx
github_2023
typescript
188
hyperdxio
MikeShi42
@@ -170,6 +171,14 @@ export const mapObjectToKeyValuePairs = ( } } + if (output['string.names'].includes('db.statement')) { + const index = output['string.names'].indexOf('db.statement'); + const value = output['string.values'][index]; + const obfuscated = await sqlObfuscator(value); + output['st...
I feel a bit iffy attaching the property to `db.statement` since `db.statement` itself is a string, so this object wouldn't be JSON-serializable anymore. I wonder if we should just call it like `db.sql.normalized` (not otel as the client themselves will attach the normalized query to `db.statement`, but seems sensib...
hyperdx
github_2023
typescript
188
hyperdxio
MikeShi42
@@ -170,6 +171,14 @@ export const mapObjectToKeyValuePairs = ( } } + if (output['string.names'].includes('db.statement')) {
If it's useful, we can also check `db.system` https://opentelemetry.io/docs/specs/semconv/database/database-spans/#:~:text=db.system%20has%20the%20following%20list%20of%20well%2Dknown%20values.
hyperdx
github_2023
typescript
189
hyperdxio
jaggederest
@@ -269,7 +288,230 @@ export default function ServiceDashboardPage() { </Grid.Col> </Grid> </Tabs.Panel> - <Tabs.Panel value="http">HTTP Service</Tabs.Panel> + <Tabs.Panel value="http"> + <Grid> + <Grid.Col span...
Should this Debug section still be here?
hyperdx
github_2023
typescript
184
hyperdxio
MikeShi42
@@ -1053,7 +1054,7 @@ const buildEventSeriesQuery = async ({ endTime, field, granularity, - groupBy, + groupBys,
We should continue to call this `groupBy`, since everywhere else assumes a groupBy is an array
hyperdx
github_2023
typescript
184
hyperdxio
MikeShi42
@@ -1096,14 +1097,39 @@ const buildEventSeriesQuery = async ({ ? buildSearchColumnName(propertyTypeMappingsModel.get(field), field) : ''; - const hasGroupBy = groupBy != '' && groupBy != null; const isCountFn = aggFn === AggFn.Count; - const groupByField = - hasGroupBy && - buildSearchColumnN...
mega nit: probably call this groupByColumnNames, fields to me usually means the user-facing field I think
hyperdx
github_2023
typescript
184
hyperdxio
MikeShi42
@@ -1096,14 +1097,36 @@ const buildEventSeriesQuery = async ({ ? buildSearchColumnName(propertyTypeMappingsModel.get(field), field) : ''; - const hasGroupBy = groupBy != '' && groupBy != null; const isCountFn = aggFn === AggFn.Count; - const groupByField = - hasGroupBy && - buildSearchColumnN...
this feels like we should just do a `.map` and throw if the column name can't be generated (otherwise we'd get a non-sensical group value right?)
hyperdx
github_2023
typescript
182
hyperdxio
wrn14897
@@ -1299,12 +1297,6 @@ export const queryMultiSeriesChart = async ({ const rows = await client.query({ query, format: 'JSON', - clickhouse_settings: {
nit: I think we can still keep this to be consistent with other methods
hyperdx
github_2023
typescript
181
hyperdxio
MikeShi42
@@ -897,6 +899,9 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) { </Link> </div> </div> + <div className="d-flex justify-content-end align-items-end">
nit: since this isn't super important, we can probably slap a `fs-7` in the className to make it smaller
hyperdx
github_2023
typescript
40
hyperdxio
wrn14897
@@ -248,3 +248,36 @@ export function S3Icon({ style, width }: IconProps) { </svg> ); } + +export function Eye({ style, width }: IconProps) {
I think we can use bootstrap icons instead https://icons.getbootstrap.com/?q=eye
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -0,0 +1,142 @@ +import * as clickhouse from '@/clickhouse';
nit: can move this to `fixtures.ts`
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -904,6 +912,588 @@ export const getMetricsChart = async ({ return result; }; +export const buildMetricSeriesQuery = async ({ + aggFn, + dataType, + endTime, + granularity, + groupBy, + name, + q, + startTime, + teamId, +}: { + aggFn: AggFn; + dataType: MetricsDataType; + endTime: number; // unix in...
Not sure I fully understand this. So if Mas/Min aggs are the same for both, why do we need extra aggFn checking here ?
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -1,4 +1,14 @@ +import _ from 'lodash';
Great tests!! not required in this PR, but I'd write tests for `buildEventSeriesQuery` and `queryMultiSeriesChart` to make sure queries are properly generated
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -904,6 +912,588 @@ export const getMetricsChart = async ({ return result; }; +export const buildMetricSeriesQuery = async ({ + aggFn, + dataType, + endTime, + granularity, + groupBy, + name, + q, + startTime, + teamId, +}: { + aggFn: AggFn; + dataType: MetricsDataType; + endTime: number; // unix in...
hmm....this is critical and tricky. How do we apply filters separately for log and metric tables ? for now at least we need to execute two queries and merge them afterward
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -904,6 +912,588 @@ export const getMetricsChart = async ({ return result; }; +export const buildMetricSeriesQuery = async ({ + aggFn, + dataType, + endTime, + granularity, + groupBy, + name, + q, + startTime, + teamId, +}: { + aggFn: AggFn; + dataType: MetricsDataType; + endTime: number; // unix in...
This assumes all series have the same table ?
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -904,6 +912,588 @@ export const getMetricsChart = async ({ return result; }; +export const buildMetricSeriesQuery = async ({ + aggFn, + dataType, + endTime, + granularity, + groupBy, + name, + q, + startTime, + teamId, +}: { + aggFn: AggFn; + dataType: MetricsDataType; + endTime: number; // unix in...
I think we need to test this guy to make sure it outputs the same data as the original chart method
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -0,0 +1,115 @@ +import type { Row } from '@clickhouse/client'; +import opentelemetry, { SpanStatusCode } from '@opentelemetry/api'; +import express from 'express'; +import { isNumber, omit, parseInt } from 'lodash'; +import ms from 'ms'; +import { serializeError } from 'serialize-error'; +import { z } from 'zod'; +i...
nit: can move this to `body` later
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -336,8 +336,8 @@ export const processAlert = async (now: Date, alert: AlertDocument) => { // Logs Source let checksData: | Awaited<ReturnType<typeof clickhouse.checkAlert>> - | Awaited<ReturnType<typeof clickhouse.getLogsChart>> | Awaited<ReturnType<typeof clickhouse.getMetricsChart>>
can also move `getMetricsChart` return type
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -904,6 +912,588 @@ export const getMetricsChart = async ({ return result; }; +export const buildMetricSeriesQuery = async ({ + aggFn, + dataType, + endTime, + granularity, + groupBy, + name, + q, + startTime, + teamId, +}: { + aggFn: AggFn; + dataType: MetricsDataType; + endTime: number; // unix in...
I can't really read this one and it hurts my brain. I think a simple test helps (at least I can see what the output query looks like). What I can tell so far is it concats a bunch of CTE and merges them afterward
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -904,6 +912,588 @@ export const getMetricsChart = async ({ return result; }; +export const buildMetricSeriesQuery = async ({ + aggFn, + dataType, + endTime, + granularity, + groupBy, + name, + q, + startTime, + teamId, +}: { + aggFn: AggFn; + dataType: MetricsDataType; + endTime: number; // unix in...
do we want to do this for other counts ?
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -904,6 +912,588 @@ export const getMetricsChart = async ({ return result; }; +export const buildMetricSeriesQuery = async ({ + aggFn, + dataType, + endTime, + granularity, + groupBy, + name, + q, + startTime, + teamId, +}: { + aggFn: AggFn; + dataType: MetricsDataType; + endTime: number; // unix in...
nit: `SeriesReturnType`
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -904,6 +912,588 @@ export const getMetricsChart = async ({ return result; }; +export const buildMetricSeriesQuery = async ({ + aggFn, + dataType, + endTime, + granularity, + groupBy, + name, + q, + startTime, + teamId, +}: { + aggFn: AggFn; + dataType: MetricsDataType; + endTime: number; // unix in...
style suggestion: any chance we can move this to the format 2nd arg ? (to improve readability)
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -904,6 +912,588 @@ export const getMetricsChart = async ({ return result; }; +export const buildMetricSeriesQuery = async ({ + aggFn, + dataType, + endTime, + granularity, + groupBy, + name, + q, + startTime, + teamId, +}: { + aggFn: AggFn; + dataType: MetricsDataType; + endTime: number; // unix in...
style suggestion: I'd move 'WITH' to the final query so its clear that we are building a bunch of CTEs
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -904,6 +912,588 @@ export const getMetricsChart = async ({ return result; }; +export const buildMetricSeriesQuery = async ({ + aggFn, + dataType, + endTime, + granularity, + groupBy, + name, + q, + startTime, + teamId, +}: { + aggFn: AggFn; + dataType: MetricsDataType; + endTime: number; // unix in...
curious why do we need 'AS' here ?
hyperdx
github_2023
typescript
171
hyperdxio
wrn14897
@@ -904,6 +912,626 @@ export const getMetricsChart = async ({ return result; }; +export const buildMetricSeriesQuery = async ({ + aggFn, + dataType, + endTime, + granularity, + groupBy, + name, + q, + startTime, + teamId, + sortOrder, +}: { + aggFn: AggFn; + dataType: MetricsDataType; + endTime: numb...
nit: I wonder if we also want to do `toFloat64` here
hyperdx
github_2023
typescript
172
hyperdxio
wrn14897
@@ -54,114 +90,78 @@ function disableAlert(alertId?: string) { // TODO do some lovely disabling of the alert here } -function AlertDetails({ - alert, - history, -}: { - alert: AlertData; - history: AlertHistory[]; -}) { +function AlertDetails({ alert }: { alert: AlertData }) { // TODO enable once disable h...
I think we have information to pull out the chart name, right ? (dashboard record + chartId)
hyperdx
github_2023
typescript
164
hyperdxio
MikeShi42
@@ -208,6 +210,14 @@ const MemoChart = memo(function MemoChart({ {isClickActive != null ? ( <ReferenceLine x={isClickActive.activeLabel} stroke="#ccc" /> ) : null} + {logReferenceTimestamp != null ? ( + <ReferenceLine + x={logReferenceTimestamp} + strok...
```suggestion label="Event" ``` we should call it an event since it could be a span or log
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -71,6 +72,52 @@ const validateGroupBy = async (req, res, next) => { }; // Routes +router.get('/', isUserAuthenticated, async (req, res, next) => { + try { + const teamId = req.user?.team; + if (teamId == null) { + return res.sendStatus(403); + } + const alerts = await Alert.find({ team: teamId ...
can use `zod` for the validation
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -71,6 +72,52 @@ const validateGroupBy = async (req, res, next) => { }; // Routes +router.get('/', isUserAuthenticated, async (req, res, next) => { + try { + const teamId = req.user?.team; + if (teamId == null) { + return res.sendStatus(403); + } + const alerts = await Alert.find({ team: teamId ...
Any reason we want to fetch this ?
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -71,6 +72,52 @@ const validateGroupBy = async (req, res, next) => { }; // Routes +router.get('/', isUserAuthenticated, async (req, res, next) => { + try { + const teamId = req.user?.team; + if (teamId == null) { + return res.sendStatus(403); + } + const alerts = await Alert.find({ team: teamId ...
I wonder if we want to populate associated dashboard or chart record for the chart type alerts. It really depends on what we show on the frontend side
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -71,6 +72,52 @@ const validateGroupBy = async (req, res, next) => { }; // Routes +router.get('/', isUserAuthenticated, async (req, res, next) => { + try { + const teamId = req.user?.team; + if (teamId == null) { + return res.sendStatus(403); + } + const alerts = await Alert.find({ team: teamId ...
can use `findOne` instead
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -71,6 +72,52 @@ const validateGroupBy = async (req, res, next) => { }; // Routes +router.get('/', isUserAuthenticated, async (req, res, next) => { + try { + const teamId = req.user?.team; + if (teamId == null) { + return res.sendStatus(403); + } + const alerts = await Alert.find({ team: teamId ...
better check this before fetching histories
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -71,6 +74,57 @@ const validateGroupBy = async (req, res, next) => { }; // Routes +router.get('/', async (req, res, next) => { + try { + const teamId = req.user?.team; + if (teamId == null) { + return res.sendStatus(403); + } + const alerts = await Alert.find({ team: teamId }); + const alertH...
should we sort here ?
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -71,6 +74,57 @@ const validateGroupBy = async (req, res, next) => { }; // Routes +router.get('/', async (req, res, next) => { + try { + const teamId = req.user?.team; + if (teamId == null) { + return res.sendStatus(403); + } + const alerts = await Alert.find({ team: teamId }); + const alertH...
nit: I would suggest to type this if possible
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -71,6 +74,57 @@ const validateGroupBy = async (req, res, next) => { }; // Routes +router.get('/', async (req, res, next) => { + try { + const teamId = req.user?.team; + if (teamId == null) { + return res.sendStatus(403); + } + const alerts = await Alert.find({ team: teamId }); + const alertH...
this chunk of code can be optimized using promise all to fetch histories concurrently
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -43,6 +46,13 @@ const zAlert = z const zAlertInput = zAlert; +const getHistory = async (alertId: string, teamId: string) => { + const histories = await AlertHistory.find({ alert: alertId, team: teamId }) + .sort({ createdAt: -1 }) + .limit(20);
I wonder if we want to pull history by time frame (as an option). that's something we can think about once the frontend draft is out
hyperdx
github_2023
typescript
154
hyperdxio
MikeShi42
@@ -71,6 +81,55 @@ const validateGroupBy = async (req, res, next) => { }; // Routes +router.get('/', async (req, res, next) => { + try { + const teamId = req.user?.team; + if (teamId == null) { + return res.sendStatus(403); + } + const alerts = await Alert.find({ team: teamId }); + const alerts...
nit: This shouldn't matter too much now, but perf could be improved with an `$in` query instead right?
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -43,6 +48,29 @@ const zAlert = z const zAlertInput = zAlert; +const getHistory = async (alert: IAlert, teamId: string) => { + const histories = await AlertHistory.find({ alert: alert._id, team: teamId }) + .sort({ createdAt: -1 }) + .limit(20); + return histories; +}; + +const getDashboard = async (aler...
No need to add these methods. You can use `populate` method. check out the example https://github.com/hyperdxio/hyperdx/blob/ce70319186eee0f8981c49e0fe03f40e3c96780e/packages/api/src/tasks/checkAlerts.ts#L29-L37
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -497,7 +497,11 @@ export const processAlert = async (now: Date, alert: AlertDocument) => { windowSizeInMins, }); history.counts += 1; + // will overwrite if multiple alerts fire + history.lastValue = totalCount; } + // only write one lastValue if t...
This code is equal to one line `history.lastValue = totalCount;` outside of if condition. Now when I think about it, I think we probably want to put `{ bucketStart, totalCount }` in an array since history only represent the most recent checking point instead of bucket by bucket if that makes sense
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -0,0 +1,286 @@ +import Head from 'next/head'; +import Link from 'next/link'; +import { formatRelative } from 'date-fns'; + +import api from './api'; +import AppNav from './AppNav'; + +// stolen directly from the api alert model for now +export type AlertType = 'presence' | 'absence'; + +export enum AlertState { + A...
Please check out `types.ts` file https://github.com/hyperdxio/hyperdx/blob/ce70319186eee0f8981c49e0fe03f40e3c96780e/packages/app/src/types.ts#L46
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -71,6 +99,45 @@ const validateGroupBy = async (req, res, next) => { }; // Routes +router.get('/', async (req, res, next) => { + try { + const teamId = req.user?.team; + if (teamId == null) { + return res.sendStatus(403); + } + const alerts = await Alert.find({ team: teamId }); + const alerts...
I think its better to check the source here as well and throw at the end if necessary
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -71,6 +99,45 @@ const validateGroupBy = async (req, res, next) => { }; // Routes +router.get('/', async (req, res, next) => { + try { + const teamId = req.user?.team; + if (teamId == null) { + return res.sendStatus(403); + } + const alerts = await Alert.find({ team: teamId }); + const alerts...
I assume `logView` is the redundant info. why don't we overwrite `logView` with object here ?
hyperdx
github_2023
typescript
154
hyperdxio
wrn14897
@@ -89,7 +89,7 @@ const AlertSchema = new Schema<IAlert>( // Log alerts logView: { type: mongoose.Schema.Types.ObjectId, - ref: 'Alert', + ref: 'LogView',
Found this bug...that explains why logView couldn't be populated
hyperdx
github_2023
typescript
163
hyperdxio
wrn14897
@@ -1978,6 +1978,27 @@ function SidePanelHeader({ parsedProperties?.['process.tag.rum.sessionId'] ?? sessionId; + const headerEventTags = useMemo(() => { + return [ + ['service', logData._service], + ['host', logData._host], + ['k8s.node', parsedProperties['k8s.node.name']], + ['k8s....
maybe we want to keep '.name' so its consistent with other tags ?
hyperdx
github_2023
typescript
147
hyperdxio
wrn14897
@@ -421,7 +421,9 @@ export const processAlert = async (now: Date, alert: AlertDocument) => { series.field ) { targetDashboard = dashboard; - const startTimeMs = fns.getTime(checkStartTime); + const startTimeMs = fns.getTime( + fns.subMinutes(checkStartTime, wi...
I think we want this fix to be applied only to Sum type (rate) metrics
hyperdx
github_2023
others
147
hyperdxio
wrn14897
@@ -48,6 +48,18 @@ dev-unit: ci-unit: npx nx run-many -t ci:unit +.PHONY: dev-alerts +dev-alerts: + docker compose exec api yarn dev:task check-alerts + +.PHONY: dev-clickhouse +dev-clickhouse: + docker compose exec ch-server clickhouse-client + +.PHONY: dev-clear-alert-history +dev-clear-alert-history: + docker c...
Can we rollback these for now ? I'd suggest to add these as alias on local. We need to specify compose file path or its gonna read the `docker-compose.yml` one which is not used for dev
hyperdx
github_2023
typescript
150
hyperdxio
MikeShi42
@@ -1342,10 +1336,149 @@ function PropertySubpanel({ }, {} as any); }, [displayedParsedProperties, propertySearchValue, search]); - const events: any[] | undefined = parsedProperties?.__events; + let events: any[] | undefined; + if (parsedProperties?.__events) { + try { + events = JSON.parse(parsed...
It seems like there's no way to actually ask to copy a parent any more in the flat view. On the old viewer this was accomplishable by clicking the key of the object, in the flat view. Iiirc the use case was that users woud like to find a specific key/value via searching the flat view, and then copy the parent object...
hyperdx
github_2023
typescript
151
hyperdxio
MikeShi42
@@ -0,0 +1,39 @@ +import express from 'express'; + +import { Api404Error } from '@/utils/errors'; +import { getTeam } from '@/controllers/team'; +import { isUserAuthenticated } from '@/middleware/auth'; + +const router = express.Router(); + +router.get('/', isUserAuthenticated, async (req, res, next) => {
we can remove the auth middleware right?
hyperdx
github_2023
typescript
145
hyperdxio
jaggederest
@@ -439,7 +464,9 @@ export const processAlert = async (now: Date, alert: AlertDocument) => { let alertState = AlertState.OK; if (checksData?.rows && checksData?.rows > 0) { for (const checkData of checksData.data) { - const totalCount = parseInt(checkData.data); + const totalCount = isStr...
Nit: Should always provide a radix argument for parseInt
hyperdx
github_2023
typescript
121
hyperdxio
wrn14897
@@ -1,4 +1,5 @@ import * as clickhouse from '..'; +import { describe, beforeEach, jest, it, expect } from '@jest/globals';
I don't think we need to import these from globals. did you hit any issues on local ?
hyperdx
github_2023
typescript
121
hyperdxio
wrn14897
@@ -704,6 +704,7 @@ export const getMetricsChart = async ({ startTime: number; // unix in ms teamId: string; }) => { + await redisClient.connect();
no need for this. redis client should be connected when server starts
hyperdx
github_2023
typescript
121
hyperdxio
MikeShi42
@@ -42,4 +43,29 @@ describe('clickhouse', () => { expect(clickhouse.client.insert).toHaveBeenCalledTimes(2); expect.assertions(2); }); + + it('getMetricsChart', async () => {
would be awesome to have a bit more descriptive of a test case name
hyperdx
github_2023
typescript
121
hyperdxio
MikeShi42
@@ -42,4 +43,29 @@ describe('clickhouse', () => { expect(clickhouse.client.insert).toHaveBeenCalledTimes(2); expect.assertions(2); }); + + it('getMetricsChart', async () => { + jest + .spyOn(clickhouse.client, 'query') + .mockResolvedValueOnce({ json: () => Promise.resolve({}) } as any); + + ...
we can also use an snapshot/inline snapshot if that's better. Though depending on the intent I imagine this is good enough
hyperdx
github_2023
typescript
136
hyperdxio
MikeShi42
@@ -633,6 +633,8 @@ const getMetricsTagsUncached = async (teamId: string) => { SELECT format('{} - {}', name, data_type) as name, data_type, + MAX(flags) as flags,
Mega Nit: I'm wondering if [`any`](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/any) has a real perf improvement over `max`, in theory it should allow clickhouse to just scan one granule
hyperdx
github_2023
typescript
63
hyperdxio
MikeShi42
@@ -16,10 +16,13 @@ import pick from 'lodash/pick'; import api from './api'; import { AggFn, Granularity, convertGranularityToSeconds } from './ChartUtils'; +import useUserPreferences, { TimeFormat } from './useUserPreferences'; +import { TIME_TOKENS } from './utils'; import { semanticKeyedColor, truncateMiddle ...
nit: extra new line
hyperdx
github_2023
typescript
63
hyperdxio
MikeShi42
@@ -37,7 +37,7 @@ export default function SearchTimeRangePicker({ setInputValue, onSearch, showLive = false, - timeFormat = '24h', + timeFormat = '12h',
minor thing - it looks like we end up overwriting this in the UI via https://github.com/hyperdxio/hyperdx/blob/f231d1f65f3e431cc72f2d6c152109c350d19c59/packages/app/src/timeQuery.ts#L18 (so after you hit search for the time range, we end up showing 24h time again instead of 12h) That being said, I don't think it's a...
hyperdx
github_2023
typescript
63
hyperdxio
MikeShi42
@@ -421,6 +428,17 @@ export default function TeamPage() { </Modal.Body> </Modal> </div> + <div> + <h2 className="mt-5">Time Format</h2>
I know we don't have a global personal setting place, could we maybe for now just put some subtext describing that this setting is a local setting and won't propagate across the entire team? Since this settings page is technically supposed to be the team page. Something like: ``` <div className="text-muted my-2"...
hyperdx
github_2023
others
131
hyperdxio
MikeShi42
@@ -0,0 +1,6 @@ +--- +'@hyperdx/api': minor +'@hyperdx/app': minor +--- + +refactor + feat: split metrics chart endpoint name query param + add validator
Might be worth being more explicit that we're changing an (internal) API shape
hyperdx
github_2023
typescript
126
hyperdxio
wrn14897
@@ -28,7 +28,12 @@ function formatTs({ const seconds = Math.floor((value / 1000) % 60); return `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`; } else { - return format(new Date(ts), 'hh:mm:ss a'); + try { + return format(new Date(ts), 'hh:mm:ss a');
nit: we can also use `isValid` (https://date-fns.org/v2.16.1/docs/isValid) to verify date object
hyperdx
github_2023
others
119
hyperdxio
MikeShi42
@@ -1,5 +1,7 @@ @import './variables'; @import '~bootstrap/scss/bootstrap'; +@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css');
curious why the switch?
hyperdx
github_2023
javascript
119
hyperdxio
MikeShi42
@@ -20,5 +20,6 @@ module.exports = { 'react/display-name': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-empty-function': 'off', + 'import/no-anonymous-default-export': 'off',
☹️
hyperdx
github_2023
typescript
122
hyperdxio
MikeShi42
@@ -2135,7 +2209,10 @@ export default function LogSidePanel({ : []), ]} activeItem={displayedTab} - onClick={(v: any) => setTab(v)} + onClick={(v: any) => { + setTab(v); + throw new Error('For Kolechia...
might want to clean this one up 😄
hyperdx
github_2023
others
122
hyperdxio
MikeShi42
@@ -756,3 +756,7 @@ div.react-datepicker { opacity: 0.7; } } + +.no-underline {
You can also use `text-decoration-none` from bs
hyperdx
github_2023
others
112
hyperdxio
MikeShi42
@@ -0,0 +1,69 @@ +@import '../../styles/variables'; + +.tableWrapper { + table { + width: 100%; + + th, + td { + &:first-child { + padding-left: 24px; + } + &:last-child { + padding-right: 24px; + } + } + + th { + color: $slate-300; + font-family: Inter; + ...
thoughts on leaving out the border for some of the network panel stuff? it feels a bit cleaner/less busy <img width="532" alt="image" src="https://github.com/hyperdxio/hyperdx/assets/2781687/0d40177a-1fec-45e0-b9fc-d7089802f7f7">
hyperdx
github_2023
typescript
112
hyperdxio
MikeShi42
@@ -0,0 +1,333 @@ +import * as React from 'react'; +import { format } from 'date-fns'; +import { JSONTree } from 'react-json-tree'; +import type { StacktraceFrame, StacktraceBreadcrumb } from './types'; +import styles from '../styles/LogSidePanel.module.scss'; +import { CloseButton } from 'react-bootstrap'; +import { u...
I think it's a bit more intuitive to have the line context open (as it feels like the most helpful part!)
hyperdx
github_2023
typescript
112
hyperdxio
MikeShi42
@@ -1975,95 +1854,68 @@ const ExceptionSubpanel = ({ // TODO: show all frames (stackable) return ( <div> - <CollapsibleSection title="Stack Trace" initiallyCollapsed={false}> - {firstException ? ( - <div> - <div className="fw-bold fs-8">{firstException.type}</div> - ...
I wonder if we should reverse the frames here so that the more specific and likely user-land code is on top? <img width="1063" alt="image" src="https://github.com/hyperdxio/hyperdx/assets/2781687/3d349c7d-8966-4b09-822c-c3145e018481">
hyperdx
github_2023
typescript
112
hyperdxio
MikeShi42
@@ -1975,95 +1854,68 @@ const ExceptionSubpanel = ({ // TODO: show all frames (stackable) return ( <div> - <CollapsibleSection title="Stack Trace" initiallyCollapsed={false}> - {firstException ? ( - <div> - <div className="fw-bold fs-8">{firstException.type}</div> - ...
I also think it'd be nice if this was default open
hyperdx
github_2023
typescript
112
hyperdxio
MikeShi42
@@ -0,0 +1,333 @@ +import * as React from 'react'; +import { format } from 'date-fns'; +import { JSONTree } from 'react-json-tree'; +import type { StacktraceFrame, StacktraceBreadcrumb } from './types'; +import styles from '../styles/LogSidePanel.module.scss'; +import { CloseButton } from 'react-bootstrap'; +import { u...
I think it'd be nice here if can also make use of the fetch/xhr categories, as they currently show up as empty (maybe a follow up PR?) Here's a few examples if helpful of the data structure I see: ``` { "category": "fetch", "data": { "method": "GET", "status_code": 200, "url": "http://localhost...
hyperdx
github_2023
typescript
112
hyperdxio
MikeShi42
@@ -0,0 +1,333 @@ +import * as React from 'react';
I'm curious how do we differentiate what should belong here vs LogSidePanel? Is this like a generic util elements for the LogSidePanel?
hyperdx
github_2023
typescript
112
hyperdxio
MikeShi42
@@ -655,18 +667,24 @@ function TraceSubpanel({ )} > <ExceptionSubpanel - breadcrumbs={JSON.parse( - selectedLogData?.['string.values']?.[ - selectedLogData?.['string.names']?.indexOf('breadcrumbs') - ...
Actually I believe in this case we need to do ``` JSON.parse( selectedLogData?.['string.values']?.[ selectedLogData?.['string.names']?.indexOf( 'breadcrumbs', ) ] ?? '[]') ``` as the undefined value into `JSON.parse` will throw a parse error
hyperdx
github_2023
typescript
117
hyperdxio
wrn14897
@@ -200,14 +200,22 @@ const Tile = forwardRef( <div className="fs-7 text-muted">{chart.name}</div> <i className="bi bi-grip-horizontal text-muted" /> <div className="fs-7 text-muted d-flex gap-2 align-items-center"> - {hasAlert && ( - <div - classN...
Super cool effect. It would be awesome to add this to sidebar bell as well (saved logs alert)
hyperdx
github_2023
others
113
hyperdxio
wrn14897
@@ -205,6 +205,7 @@ services: environment: NEXT_PUBLIC_API_SERVER_URL: 'http://localhost:8000' # need to be localhost (CORS) NEXT_PUBLIC_HDX_API_KEY: ${HYPERDX_API_KEY} + HYPERDX_API_KEY: ${HYPERDX_API_KEY}
Ah can we also remove `NEXT_PUBLIC_HDX_API_KEY` here since its not used ?
hyperdx
github_2023
typescript
103
hyperdxio
svc-shorpo
@@ -0,0 +1,101 @@ +import { useEffect, useState } from 'react'; + +const checkLength = (password: string) => password.length >= 12; +const checkOneUpper = (password: string) => /[A-Z]+/.test(password); +const checkOneLower = (password: string) => /[a-z]+/.test(password); +const checkOneNumber = (password: string) => /\...
alternatively you should be able to use bootstrap-icons here: https://icons.getbootstrap.com ``` <span class="bi bi-check" /> ```
hyperdx
github_2023
typescript
103
hyperdxio
svc-shorpo
@@ -0,0 +1,101 @@ +import { useEffect, useState } from 'react'; + +const checkLength = (password: string) => password.length >= 12; +const checkOneUpper = (password: string) => /[A-Z]+/.test(password); +const checkOneLower = (password: string) => /[a-z]+/.test(password); +const checkOneNumber = (password: string) => /\...
you can also consider having a computed var with `useMemo` instead of updating state with useEffect: ```ts const isValid = useMemo(() => handler(password), [handler, password]) ```
hyperdx
github_2023
typescript
103
hyperdxio
svc-shorpo
@@ -0,0 +1,101 @@ +import { useEffect, useState } from 'react'; + +const checkLength = (password: string) => password.length >= 12; +const checkOneUpper = (password: string) => /[A-Z]+/.test(password); +const checkOneLower = (password: string) => /[a-z]+/.test(password); +const checkOneNumber = (password: string) => /\...
interesting, maybe type checking isn't working correctly upstream 🤔
hyperdx
github_2023
typescript
103
hyperdxio
wrn14897
@@ -45,6 +46,26 @@ export default function AuthPage({ action }: { action: 'register' | 'login' }) { } }, [installation, isRegister, router]); + const [currentPassword, setCurrentPassword] = useState<string>(''); + const [confirmPassword, setConfirmPassword] = useState<string>(''); + + const updateCurrentPa...
can remove this console log ?
hyperdx
github_2023
typescript
103
hyperdxio
wrn14897
@@ -45,6 +46,26 @@ export default function AuthPage({ action }: { action: 'register' | 'login' }) { } }, [installation, isRegister, router]); + const [currentPassword, setCurrentPassword] = useState<string>(''); + const [confirmPassword, setConfirmPassword] = useState<string>(''); + + const updateCurrentPa...
can we get target object from the arg ? (so no need to call document.getElementById)
hyperdx
github_2023
typescript
103
hyperdxio
wrn14897
@@ -63,39 +68,25 @@ export const CheckOrX = ({ const Check = () => ( <svg xmlns="http://www.w3.org/2000/svg" - width="1em" - height="1em" + width="16"
I wonder if we can use bootstrap icon directly without using this svg component (for example: https://github.com/hyperdxio/hyperdx/blob/2fcd167540f596f800b042c9403dfbcc3072fffe/packages/app/src/InstallInstructionsModal.tsx#L33-L38)
hyperdx
github_2023
typescript
103
hyperdxio
MikeShi42
@@ -45,6 +48,23 @@ export default function AuthPage({ action }: { action: 'register' | 'login' }) { } }, [installation, isRegister, router]); + const [currentPassword, setCurrentPassword] = useState<string>('');
sorry to pile on late on this PR... we're a bit inconsistent in the project but we're trying to move frontend forms to be more based off of `react-hook-form` when possible. In this case we're already using the hook on line 30 above here, and the hook allows for listening to values in the form via [`watch`](https://...
hyperdx
github_2023
typescript
103
hyperdxio
MikeShi42
@@ -0,0 +1,70 @@ +import { useMemo } from 'react'; + +const checkLength = (password: string) => password.length >= 12; +const checkOneUpper = (password: string) => /[A-Z]+/.test(password); +const checkOneLower = (password: string) => /[a-z]+/.test(password); +const checkOneNumber = (password: string) => /\d+/.test(pass...
personally not a fan of the li's here, can probably do without the bullet points and just have them as just divs to make it nice and clean <img width="497" alt="image" src="https://github.com/hyperdxio/hyperdx/assets/2781687/5b4e4c05-556b-49c5-bc67-9110ab0ba5fc">
hyperdx
github_2023
typescript
103
hyperdxio
MikeShi42
@@ -153,15 +174,22 @@ export default function AuthPage({ action }: { action: 'register' | 'login' }) { htmlFor="confirmPassword" className="text-start text-muted fs-7.5 mb-1" > - Confirm Password + <CheckOrX + ...
```suggestion className="border-0 mb-2" ``` just adds a bit of breathing room between the input <img width="510" alt="image" src="https://github.com/hyperdxio/hyperdx/assets/2781687/34288d16-be85-4222-8c21-b7fa54761dfc"> vs <img width="454" alt="image" src="https://github.com/hyperdxio/hyp...
hyperdx
github_2023
typescript
92
hyperdxio
wrn14897
@@ -25,3 +25,8 @@ export const PORT = Number.parseInt(env.PORT as string); export const REDIS_URL = env.REDIS_URL as string; export const SERVER_URL = env.SERVER_URL as string; export const USAGE_STATS_ENABLED = env.USAGE_STATS_ENABLED !== 'false'; +export const CACHE_METRICS_TAGS = env.CACHE_METRICS_TAGS !== 'false...
we want this defaults to '600' instead of '600s', right ?
hyperdx
github_2023
typescript
92
hyperdxio
wrn14897
@@ -13,3 +13,5 @@ client.on('error', (err: any) => { }); export default client; + +export { client as redisClient };
I think this export is redundant since we already export client as default. So importing code is like ``` import redisClient from './utils/redis'; ```
hyperdx
github_2023
typescript
92
hyperdxio
wrn14897
@@ -25,3 +25,8 @@ export const PORT = Number.parseInt(env.PORT as string); export const REDIS_URL = env.REDIS_URL as string; export const SERVER_URL = env.SERVER_URL as string; export const USAGE_STATS_ENABLED = env.USAGE_STATS_ENABLED !== 'false'; +export const CACHE_METRICS_TAGS = env.CACHE_METRICS_TAGS !== 'false...
nit: maybe be more explicit in naming like `CACHE_METRICS_EXPIRATION_IN_SEC`
hyperdx
github_2023
typescript
108
hyperdxio
MikeShi42
@@ -12,10 +14,10 @@ type Chart = { series: { table: string; type: 'time' | 'histogram' | 'search' | 'number' | 'table' | 'markdown'; - aggFn: string; - field?: string; - where?: string; - groupBy?: string[]; + aggFn: AggFn; + field: string; + where: string; + groupBy: string[];
this typing seems incorrect, the frontend has a more accurate version of types but we can't assume these fields are non-null for all chart types. I'm assuming we went with a less specific type here for a reason though as opposed to the specific union. https://github.com/hyperdxio/hyperdx/blob/fe41b150de8065634bf3e5f...
hyperdx
github_2023
typescript
108
hyperdxio
MikeShi42
@@ -58,25 +56,110 @@ export const buildLogSearchLink = ({ return url.toString(); }; -const buildEventSlackMessage = ({ +// TODO: should link to the chart instead +export const buildChartLink = ({ + dashboardId, + endTime, + granularity, + startTime, +}: { + dashboardId: string; + endTime: Date; + granulari...
```suggestion `${totalCount} ${ ``` lines doesn't make sense in this context
hyperdx
github_2023
typescript
108
hyperdxio
MikeShi42
@@ -58,25 +56,110 @@ export const buildLogSearchLink = ({ return url.toString(); }; -const buildEventSlackMessage = ({ +// TODO: should link to the chart instead +export const buildChartLink = ({ + dashboardId, + endTime, + granularity, + startTime, +}: { + dashboardId: string; + endTime: Date; + granulari...
```suggestion } ${alert.threshold}`, ``` ![image](https://github.com/hyperdxio/hyperdx/assets/2781687/0ae0f969-84bb-4669-a08f-0ae708ed0daf)
hyperdx
github_2023
typescript
108
hyperdxio
MikeShi42
@@ -58,25 +56,110 @@ export const buildLogSearchLink = ({ return url.toString(); }; -const buildEventSlackMessage = ({ +// TODO: should link to the chart instead +export const buildChartLink = ({ + dashboardId, + endTime, + granularity, + startTime, +}: { + dashboardId: string; + endTime: Date; + granulari...
```suggestion text: `Alert for "${dashboard.chart.name}" in "${dashboard.name}" - ${totalCount} ${... exceeds/falls below ${threshold} ...}`, ``` We should include the exceeds/falls below threshold message here too