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
637
hyperdxio
wrn14897
@@ -81,7 +113,7 @@ function getConfig(source: TSource, traceId: string) { alias: 'Body', }, { - valueExpression: alias.Timestamp, + valueExpression: sortKey,
is this suppose be `alias.Timestamp` ?
hyperdx
github_2023
typescript
641
hyperdxio
teeohhem
@@ -55,8 +65,16 @@ export const Tags = React.memo( (event: React.KeyboardEvent<HTMLInputElement>) => { if (event.key === 'Enter') { if (allowCreate && q.length > 0) { - onChange([...values, event.currentTarget.value]); - setQ(''); + // Check if tag already exi...
nit: If a tag exists, do we want to display an info message of some sort?
hyperdx
github_2023
typescript
641
hyperdxio
teeohhem
@@ -926,6 +1009,24 @@ function DBSearchPage() { Alerts </Button> )} + {!!savedSearch && ( + <Tags + allowCreate + values={savedSearch.tags || []} + onChange={handleUpdateTags} + ...
Just a note, clicking on this "x" in the input does nothing ![image](https://github.com/user-attachments/assets/d5dedbc3-3241-4a5b-9a12-0be9cf80f716)
hyperdx
github_2023
typescript
640
hyperdxio
LYHuang
@@ -554,6 +531,18 @@ function DBSearchPage() { updateInput: !isLive, }); + // If live tail is null, but time range exists, don't live tail + // If live tail is null, and time range is null, let's live tail + useEffect(() => { + if (_isLive == null && isReady) {
A little bit confuse about this part, is it try to init livetail flag become `true` when user enter the search page and does not set time range? And once the flag is set, we don't auto turn on the flag even user remove time range?
hyperdx
github_2023
typescript
640
hyperdxio
LYHuang
@@ -87,33 +29,94 @@ export function RowOverviewPanel({ return firstRow; }, [data]); - const resourceAttributes = useMemo(() => { - return firstRow[source.resourceAttributesExpression!] || {}; - }, [firstRow, source.resourceAttributesExpression]); + const resourceAttributes = firstRow?.__hdx_resource_att...
Not sure this is intent but there is a chance `resourceAttributes` and `eventAttributes` reference the same obj, I don't think it is safe. ``` const EMPTY_OBJ = {} const randomObj = {} const ob1 = randomObj?.key1 ?? EMPTY_OBJ const ob2 = randomObj?.key2 ?? EMPTY_OBJ; EMPTY_OBJ.random = 'random words' console.l...
hyperdx
github_2023
typescript
640
hyperdxio
LYHuang
@@ -87,33 +29,94 @@ export function RowOverviewPanel({ return firstRow; }, [data]); - const resourceAttributes = useMemo(() => { - return firstRow[source.resourceAttributesExpression!] || {}; - }, [firstRow, source.resourceAttributesExpression]); + const resourceAttributes = firstRow?.__hdx_resource_att...
is it ok we don't update `_generateSearchUrl` even `query` and `timeRange` change?
hyperdx
github_2023
typescript
640
hyperdxio
LYHuang
@@ -61,7 +62,10 @@ export const FilterCheckbox = ({ <Checkbox checked={!!value} size={13 as any} - onChange={e => onChange?.(e.currentTarget.checked)} + onChange={
Can we just remove `onChange` or pass `() => {}`?
hyperdx
github_2023
typescript
640
hyperdxio
LYHuang
@@ -0,0 +1,343 @@ +import React, { useMemo } from 'react'; +import Link from 'next/link'; +import { pickBy } from 'lodash'; +import CopyToClipboard from 'react-copy-to-clipboard'; +import { JSONTree } from 'react-json-tree'; +import { + Accordion, + Box, + Button, + CopyButton, + TableData, + Text, +} from '@mant...
don't need `if` if we already try catch it
hyperdx
github_2023
typescript
640
hyperdxio
LYHuang
@@ -0,0 +1,343 @@ +import React, { useMemo } from 'react'; +import Link from 'next/link'; +import { pickBy } from 'lodash'; +import CopyToClipboard from 'react-copy-to-clipboard'; +import { JSONTree } from 'react-json-tree'; +import { + Accordion, + Box, + Button, + CopyButton, + TableData, + Text, +} from '@mant...
no console.log
hyperdx
github_2023
typescript
640
hyperdxio
LYHuang
@@ -0,0 +1,343 @@ +import React, { useMemo } from 'react'; +import Link from 'next/link'; +import { pickBy } from 'lodash'; +import CopyToClipboard from 'react-copy-to-clipboard'; +import { JSONTree } from 'react-json-tree'; +import { + Accordion, + Box, + Button, + CopyButton, + TableData, + Text, +} from '@mant...
if object `value` can only from parsing, we can use `_value` at here
hyperdx
github_2023
typescript
640
hyperdxio
LYHuang
@@ -0,0 +1,343 @@ +import React, { useMemo } from 'react'; +import Link from 'next/link'; +import { pickBy } from 'lodash'; +import CopyToClipboard from 'react-copy-to-clipboard'; +import { JSONTree } from 'react-json-tree'; +import { + Accordion, + Box, + Button, + CopyButton, + TableData, + Text, +} from '@mant...
prob do `return null` at here to make result consistent
hyperdx
github_2023
typescript
635
hyperdxio
teeohhem
@@ -810,8 +846,67 @@ function translateMetricChartConfig( databaseName: '', tableName: 'RawSum', }, - where: `MetricName = '${metricName}'`, - whereLanguage: 'sql', + }; + } else if (metricType === MetricsDataType.Histogram && metricName) { + // histograms are only valid for qu...
![chic-fil-a](https://github.com/user-attachments/assets/0fd125e3-dc4a-47fc-924e-381d4e2452d3)
hyperdx
github_2023
typescript
624
hyperdxio
wrn14897
@@ -189,6 +191,21 @@ export default function DBRowSidePanel({ ? source.logSourceId : undefined; + const resourceAttributes = useMemo<Record<string, string>>(() => { + const key = source.resourceAttributesExpression || 'ResourceAttributes'; + return normalizedRow?.[key] || {}; + }, [normalize...
To match what we have in v1, we want to grab the session Id from the top level span. That being said, the session replay should be accessible for any spans in the same trace (log items as well) <img width="1184" alt="Screenshot 2025-02-24 at 5 11 24 PM" src="https://github.com/user-attachments/assets/50151a68-a8b9-4...
hyperdx
github_2023
typescript
624
hyperdxio
wrn14897
@@ -0,0 +1,139 @@ +import { useMemo } from 'react'; +import { TSource } from '@hyperdx/common-utils/dist/types'; +import { Loader } from '@mantine/core'; + +import SessionSubpanel from '@/SessionSubpanel'; +import { useSource } from '@/source'; +import { getDisplayedTimestampValueExpression } from '@/source'; + +import...
style: better to centralize getDisplayedTimestampValueExpression call somewhere top level. for now, I think we can use `timestampValueExpression` directly
hyperdx
github_2023
typescript
624
hyperdxio
wrn14897
@@ -0,0 +1,139 @@ +import { useMemo } from 'react'; +import { TSource } from '@hyperdx/common-utils/dist/types'; +import { Loader } from '@mantine/core'; + +import SessionSubpanel from '@/SessionSubpanel'; +import { useSource } from '@/source'; +import { getDisplayedTimestampValueExpression } from '@/source'; + +import...
style: `useEventsData` seems to be used for `DBTraceWaterfallChartContainer` particularly. I think here we can just make a call using `clickhouseClient.query` like https://github.com/hyperdxio/hyperdx/blob/b66fc1464166dffaf06258f9c77094f3f9f3dd85/packages/app/src/clickhouse.ts#L244-L249
hyperdx
github_2023
typescript
634
hyperdxio
wrn14897
@@ -73,3 +80,78 @@ describe('formatAttributeClause', () => { ); }); }); + +describe('getMetricTableName', () => { + // Base source object with required properties + const createBaseSource = () => ({ + from: { + tableName: 'default_table',
nit: as I recall, the tableName is an empty string for the metrics source
hyperdx
github_2023
typescript
634
hyperdxio
wrn14897
@@ -73,3 +80,78 @@ describe('formatAttributeClause', () => { ); }); }); + +describe('getMetricTableName', () => { + // Base source object with required properties + const createBaseSource = () => ({ + from: { + tableName: 'default_table', + databaseName: 'test_db', + }, + id: 'test-id', + ...
nit: 'metric'?
hyperdx
github_2023
others
633
hyperdxio
MikeShi42
@@ -75,9 +85,8 @@ extensions: endpoint: :13133 service: telemetry: - # TODO: enable internal metrics - # metrics: - # address: ':8888' + metrics:
can ticket this for later but seems better if we push directly? https://opentelemetry.io/docs/collector/internal-telemetry/#configure-internal-metrics
hyperdx
github_2023
typescript
629
hyperdxio
MikeShi42
@@ -688,18 +727,119 @@ function renderLimit( return chSql`${{ Int32: chartConfig.limit.limit }}${offset}`; } -export async function renderChartConfig( +// CTE (Common Table Expressions) isn't exported at this time. It's only used internally +// for metric SQL generation. +type ChartConfigWithOptDateRateAndCte = C...
We need to expose all the original columns here, otherwise the user won't be able to query the table for something like `GROUP BY ResourceAttrributes['host.name']`
hyperdx
github_2023
typescript
619
hyperdxio
wrn14897
@@ -262,21 +262,16 @@ export const handleSendGenericWebhook = async ( 'Content-Type': 'application/json', // default, will be overwritten if user has set otherwise ...(webhook.headers?.toJSON() ?? {}), }; - - // BODY - - let body = ''; - if (webhook.body) { - const handlebars = Handlebars.create(); -...
Can't we set this as a default value when creating a generic webhook? Giving it another thought, I think we should just add a 'body' field in the UI. It's kind of critical imo to empower the generic webhook. v1 design looks like <img width="701" alt="Screenshot 2025-02-18 at 9 46 16 PM" src="https://github.com/use...
hyperdx
github_2023
typescript
619
hyperdxio
wrn14897
@@ -262,18 +262,26 @@ export const handleSendGenericWebhook = async ( 'Content-Type': 'application/json', // default, will be overwritten if user has set otherwise ...(webhook.headers?.toJSON() ?? {}), }; - // BODY - let body = ''; - if (webhook.body) { - const handlebars = Handlebars.create(); -...
Any reason we want to set the default body here? I think aborting is more appropriate given the template is invalid
hyperdx
github_2023
typescript
619
hyperdxio
wrn14897
@@ -37,6 +46,15 @@ import { capitalizeFirstLetter } from './utils'; import styles from '../styles/TeamPage.module.scss'; +const DEFAULT_GENERIC_WEBHOOK_BODY = + '{"text": "{{title}} | {{body}} | {{link}}"}'; + +const jsonLinterWithEmptyCheck = () => (view: any) => {
can we type `view` ?
hyperdx
github_2023
typescript
619
hyperdxio
wrn14897
@@ -742,6 +764,50 @@ function CreateWebhookForm({ error={form.formState.errors.description?.message} {...form.register('description')} /> + {form.getValues('service') === 'generic' && [ + <label className=".mantine-TextInput-label" key="1"> + Webhook Body (optio...
style: can use `DEFAULT_GENERIC_WEBHOOK_BODY` here
hyperdx
github_2023
typescript
619
hyperdxio
wrn14897
@@ -742,6 +764,50 @@ function CreateWebhookForm({ error={form.formState.errors.description?.message} {...form.register('description')} /> + {form.getValues('service') === 'generic' && [ + <label className=".mantine-TextInput-label" key="1"> + Webhook Body (optio...
style: it would be nice if we could reuse `DEFAULT_GENERIC_WEBHOOK_BODY` so the component matches it always
hyperdx
github_2023
typescript
619
hyperdxio
wrn14897
@@ -262,18 +262,26 @@ export const handleSendGenericWebhook = async ( 'Content-Type': 'application/json', // default, will be overwritten if user has set otherwise ...(webhook.headers?.toJSON() ?? {}), }; - // BODY - let body = ''; - if (webhook.body) { - const handlebars = Handlebars.create(); -...
this if case is probably redundant? given the `compile` would throw
hyperdx
github_2023
typescript
619
hyperdxio
wrn14897
@@ -672,12 +693,17 @@ function CreateWebhookForm({ }); const onSubmit: SubmitHandler<WebhookForm> = async values => { + const { service, name, url, description, body } = values; try { await saveWebhook.mutateAsync({ - service: values.service, - name: values.name, - url: value...
style: can import enum from the common-utils https://github.com/hyperdxio/hyperdx/blob/4586cc1c1bf54b00dbfcea855a0c1e19176dc237/packages/common-utils/src/types.ts#L168
hyperdx
github_2023
typescript
619
hyperdxio
wrn14897
@@ -742,6 +768,45 @@ function CreateWebhookForm({ error={form.formState.errors.description?.message} {...form.register('description')} /> + {form.getValues('service') === 'generic' && [
same here
hyperdx
github_2023
typescript
622
hyperdxio
MikeShi42
@@ -790,7 +790,7 @@ function translateMetricChartConfig( any(Attributes) OVER (ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS PrevAttributes, IF(AggregationTemporality = 1, Value,IF(Value - PrevValue < 0 AND Attributes = PrevAttributes,Value, - IF(At...
I think we want to actually run this on the subselect first, otherwise we'll be rehashing a lot more than we need to.
hyperdx
github_2023
typescript
623
hyperdxio
MikeShi42
@@ -0,0 +1,120 @@ +import { ResponseJSON } from '@clickhouse/client'; +import { chSql } from '@hyperdx/common-utils/dist/clickhouse'; +import { SourceKind } from '@hyperdx/common-utils/dist/types'; +import { TSource } from '@hyperdx/common-utils/dist/types'; +import { useQuery } from '@tanstack/react-query'; + +import ...
I think we should be able to safely set this into the thousands?
hyperdx
github_2023
typescript
623
hyperdxio
MikeShi42
@@ -0,0 +1,120 @@ +import { ResponseJSON } from '@clickhouse/client'; +import { chSql } from '@hyperdx/common-utils/dist/clickhouse'; +import { SourceKind } from '@hyperdx/common-utils/dist/types'; +import { TSource } from '@hyperdx/common-utils/dist/types'; +import { useQuery } from '@tanstack/react-query'; + +import ...
do we want to do select distinct?
hyperdx
github_2023
typescript
623
hyperdxio
MikeShi42
@@ -0,0 +1,120 @@ +import { ResponseJSON } from '@clickhouse/client'; +import { chSql } from '@hyperdx/common-utils/dist/clickhouse'; +import { SourceKind } from '@hyperdx/common-utils/dist/types'; +import { TSource } from '@hyperdx/common-utils/dist/types'; +import { useQuery } from '@tanstack/react-query'; + +import ...
it _may_ be nice to also add a row scan limit https://github.com/hyperdxio/hyperdx/blob/4529dfe459cab43745a8d30f54442bf4ed976950/packages/common-utils/src/metadata.ts#L428-L431
hyperdx
github_2023
typescript
623
hyperdxio
MikeShi42
@@ -17,6 +17,7 @@ export default function SearchInputV2({ connectionId, enableHotkey, onSubmit, + additionalSuggestions,
I think this works for now, though I wonder if the v1 pattern of having a separate metrics tag filter input would be cleaner? We can leave it as a follow up. https://github.com/hyperdxio/hyperdx/blob/main/packages/app/src/MetricTagFilterInput.tsx
hyperdx
github_2023
typescript
623
hyperdxio
wrn14897
@@ -0,0 +1,120 @@ +import { ResponseJSON } from '@clickhouse/client'; +import { chSql } from '@hyperdx/common-utils/dist/clickhouse'; +import { SourceKind } from '@hyperdx/common-utils/dist/types'; +import { TSource } from '@hyperdx/common-utils/dist/types'; +import { useQuery } from '@tanstack/react-query'; + +import ...
style: we want to parameterize query like ``` FROM ${tableExpr({ database: databaseName, table: tableName })} WHERE MetricName=${{ String: metricName }} LIMIT ${{ Int32: METRIC_FETCH_LIMIT}} ```
hyperdx
github_2023
typescript
623
hyperdxio
wrn14897
@@ -0,0 +1,120 @@ +import { ResponseJSON } from '@clickhouse/client'; +import { chSql } from '@hyperdx/common-utils/dist/clickhouse'; +import { SourceKind } from '@hyperdx/common-utils/dist/types'; +import { TSource } from '@hyperdx/common-utils/dist/types'; +import { useQuery } from '@tanstack/react-query'; + +import ...
``` { ScopeAttributes?: Record<string, string>; ResourceAttributes?: Record<string, string>; Attributes?: Record<string, string>; } ```
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -22,233 +27,338 @@ type SpanRow = { ParentSpanId: string; StatusCode?: string; ServiceName?: string; + SeverityText?: string; HyperDXEventType: 'span'; + type?: string; }; + +function textColor(condition: { isError: boolean; isWarn: boolean }): string { + const { isError, isWarn } = condition; + if ...
Should we be reusing `ChartConfigSchema` types here instead of duping?
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -22,233 +27,338 @@ type SpanRow = { ParentSpanId: string; StatusCode?: string; ServiceName?: string; + SeverityText?: string; HyperDXEventType: 'span'; + type?: string; }; + +function textColor(condition: { isError: boolean; isWarn: boolean }): string { + const { isError, isWarn } = condition; + if ...
it'd be nice to DRY this out
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -202,7 +204,14 @@ export default function DBTracePanel({ <Text size="sm" c="dark.2" my="sm"> Span Details
This should reflect the correct event type name
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -202,7 +204,14 @@ export default function DBTracePanel({ <Text size="sm" c="dark.2" my="sm"> Span Details </Text> - <RowDataPanel source={traceSourceData} rowId={traceRowWhere} /> + <RowDataPanel + source={ + traceRowWhere?.type === SourceK...
I think parentSourceData is a log source only if the user opened a log, but if you open a trace, then the parentSourceData would be a trace type?
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -56,7 +57,7 @@ export default function DBTracePanel({ const [traceRowWhere, setTraceRowWhere] = useQueryState( 'traceRowWhere',
not a huge fan of overloading this query param, esp if the rowWhere is for a log but put in the "traceRowWhere" - the naming wouldn't make sense. I think it might be better to introduce another query param for `logRowWhere`? We could rename this query param but it'd technically be a breaking change (technically this...
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -22,233 +27,338 @@ type SpanRow = { ParentSpanId: string; StatusCode?: string; ServiceName?: string; + SeverityText?: string; HyperDXEventType: 'span'; + type?: string; }; + +function textColor(condition: { isError: boolean; isWarn: boolean }): string { + const { isError, isWarn } = condition; + if ...
```suggestion function useEventsAroundFocus({ ```
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -22,233 +27,338 @@ type SpanRow = { ParentSpanId: string; StatusCode?: string; ServiceName?: string; + SeverityText?: string; HyperDXEventType: 'span'; + type?: string; }; + +function textColor(condition: { isError: boolean; isWarn: boolean }): string { + const { isError, isWarn } = condition; + if ...
nit: I think this name is too non-descriptive, additionally reads awkwardly (I think hook names are usually `use${Noun}` format) maybe `useEventsData` or something. Same goes for the config function above
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -22,233 +27,338 @@ type SpanRow = { ParentSpanId: string; StatusCode?: string; ServiceName?: string; + SeverityText?: string; HyperDXEventType: 'span'; + type?: string; }; + +function textColor(condition: { isError: boolean; isWarn: boolean }): string { + const { isError, isWarn } = condition; + if ...
```suggestion // search invalid date range if no logTableModel(react hook need execute no matter what) ``` Also: you can pass in enable flags into queries, typically we expose them upwards (looks like you can pass `enable` into the second arg of `useOffsetPaginatedQuery`). If this doesn't fire a query, maybe t...
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -22,233 +27,338 @@ type SpanRow = { ParentSpanId: string; StatusCode?: string; ServiceName?: string; + SeverityText?: string; HyperDXEventType: 'span'; + type?: string; }; + +function textColor(condition: { isError: boolean; isWarn: boolean }): string { + const { isError, isWarn } = condition; + if ...
this is some inconsistency in our app but I think we're trying to use `source` instead of `model` now. so `tableSource`
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -22,233 +27,338 @@ type SpanRow = { ParentSpanId: string; StatusCode?: string; ServiceName?: string; + SeverityText?: string; HyperDXEventType: 'span'; + type?: string; }; + +function textColor(condition: { isError: boolean; isWarn: boolean }): string { + const { isError, isWarn } = condition; + if ...
wouldn't this mark every event as a span? even logs?
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -73,6 +73,7 @@ export const SelectListSchema = z.array(DerivedColumnSchema).or(z.string()); export const SortSpecificationSchema = z.intersection( RootValueExpressionSchema, z.object({ + valueExpression: z.string().optional(),
why do we need to add this?
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -22,233 +27,338 @@ type SpanRow = { ParentSpanId: string; StatusCode?: string; ServiceName?: string; + SeverityText?: string; HyperDXEventType: 'span'; + type?: string; }; + +function textColor(condition: { isError: boolean; isWarn: boolean }): string { + const { isError, isWarn } = condition; + if ...
I believe this can be a lot more readable if we do the direct boolean expression which I believe is: ``` const isRootNode = HyperDXEventType === 'span' && type !== SourceKind.Log && !nodeParentSpanId; ```
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -22,233 +27,338 @@ type SpanRow = { ParentSpanId: string; StatusCode?: string; ServiceName?: string; + SeverityText?: string; HyperDXEventType: 'span'; + type?: string; }; + +function textColor(condition: { isError: boolean; isWarn: boolean }): string { + const { isError, isWarn } = condition; + if ...
it's not clear to me what this map is being used for, on line 333 could we not pull the parent span id from the row itself?
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -22,233 +27,338 @@ type SpanRow = { ParentSpanId: string; StatusCode?: string; ServiceName?: string; + SeverityText?: string; HyperDXEventType: 'span'; + type?: string; }; + +function textColor(condition: { isError: boolean; isWarn: boolean }): string { + const { isError, isWarn } = condition; + if ...
is this id used anywhere? is it effectively just random and never used further?
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -121,7 +141,9 @@ export default function DBTracePanel({ </Flex> <Group gap="sm"> <Text size="sm" c="gray.4"> - Trace Source + {parentSourceData?.kind === SourceKind.Log + ? 'Trace Source' + : 'Correlate Log Source'}
```suggestion : 'Correlated Log Source'} ```
hyperdx
github_2023
typescript
605
hyperdxio
MikeShi42
@@ -43,20 +42,41 @@ export default function DBTracePanel({ }, }); - const { data: traceSourceData, isLoading: isTraceSourceLoading } = useSource({ - id: watch('source'), - }); + const { data: childSourceData, isLoading: isChildSourceDataLoading } = + useSource({ + id: watch('source'), + }); ...
Not 100% sure of the logic here but I'm pretty sure this is still causing a bug. If I'm searching from the trace table, and I open the Trace panel, logs do not show up. We should be using `traceSourceId` and `logSourceId` to pull up the correlated source.
hyperdx
github_2023
typescript
616
hyperdxio
MikeShi42
@@ -144,7 +166,7 @@ export function useSessions( ], from: traceSource.from, dateRange, - where: `mapContains(${traceSource.resourceAttributesExpression}, 'rum.sessionId')`, + where: `mapContains(${traceSource.resourceAttributesExpression}, 'rum.sessionId') AN...
It seems like we're better off if we use the `filters` param for the `mapContains` statement and then pass in the user input into `where` and that way we don't have to hack some weird stuff on top?
hyperdx
github_2023
typescript
616
hyperdxio
MikeShi42
@@ -89,7 +93,25 @@ export function useSessions( if (!traceSource || !sessionSource) { return []; } - // TODO: we + + let whereClauseSQL = `1=1`;
no need for fix, just a note in the future: I know we do this pattern a lot in v1, but it'd be nice in v2 if we started cleaning that up and just conditionally rendering the SQL statement since we aren't using the same SQL formatter as before.
hyperdx
github_2023
typescript
616
hyperdxio
MikeShi42
@@ -529,7 +529,7 @@ async function renderWhereExpression({ return chSql`${{ UNSAFE_RAW_SQL: _condition }}`; } -async function renderWhere( +export async function renderWhere(
let's not export this :)
hyperdx
github_2023
typescript
612
hyperdxio
MikeShi42
@@ -700,6 +700,17 @@ function CreateWebhookForm({ <form onSubmit={form.handleSubmit(onSubmit)}> <Stack mt="sm"> <Text>Create Webhook</Text> + <Radio.Group + name="service"
do we need to register this to the form to persist?
hyperdx
github_2023
typescript
610
hyperdxio
teeohhem
@@ -641,10 +646,39 @@ export function MetricTableModelForm({ setValue: UseFormSetValue<TSource>; }) { const databaseName = watch(`from.databaseName`, DEFAULT_DATABASE); - const tableName = watch(`from.tableName`); const connectionId = watch(`connection`); - const [showOptionalFields, setShowOptionalFields...
nit: Should probably toast here with `e.message`
hyperdx
github_2023
typescript
610
hyperdxio
MikeShi42
@@ -641,10 +646,43 @@ export function MetricTableModelForm({ setValue: UseFormSetValue<TSource>; }) { const databaseName = watch(`from.databaseName`, DEFAULT_DATABASE); - const tableName = watch(`from.tableName`); const connectionId = watch(`connection`); - const [showOptionalFields, setShowOptionalFields...
can we set this to TimeUnix or StartTimeUnix?
hyperdx
github_2023
typescript
601
hyperdxio
wrn14897
@@ -105,15 +128,28 @@ router.get( } }, error: (err, _req, _res) => { - console.error(err); + console.error('Proxy error:', err); + res.writeHead(500, { + 'Content-Type': 'application/json', + }); + res.end( + ...
style: can simplify this ``` res.status(500).json({ success: false, error: err.message ?? 'Failed to connect to ClickHouse server' }); ```
hyperdx
github_2023
typescript
598
hyperdxio
wrn14897
@@ -14,7 +14,7 @@ export const Source = mongoose.model<ISource>( { kind: { type: String, - enum: ['log', 'trace'], + enum: ['log', 'trace', 'metric'],
style: can we do `enum: Object.values(SourceKind)` ?
hyperdx
github_2023
typescript
598
hyperdxio
wrn14897
@@ -396,6 +396,7 @@ export enum SourceKind { Log = 'log',
Can you run `yarn changeset` and commit the changeset? since we need to bump this pkg version
hyperdx
github_2023
typescript
598
hyperdxio
wrn14897
@@ -536,6 +537,243 @@ export function TraceTableModelForm({ ); } +export function MetricTableModelForm({ + control, + watch, + setValue, +}: { + control: Control<TSource>; + watch: UseFormWatch<TSource>; + setValue: UseFormSetValue<TSource>; +}) { + const databaseName = watch(`from.databaseName`, DEFAULT_D...
I suspect we don't need the default select for metrics
hyperdx
github_2023
typescript
598
hyperdxio
wrn14897
@@ -536,6 +537,243 @@ export function TraceTableModelForm({ ); } +export function MetricTableModelForm({ + control, + watch, + setValue, +}: { + control: Control<TSource>; + watch: UseFormWatch<TSource>; + setValue: UseFormSetValue<TSource>; +}) { + const databaseName = watch(`from.databaseName`, DEFAULT_D...
The session reuses the same clickhouse log exporter, which means it should be able to share `LogTableModelForm` component
hyperdx
github_2023
typescript
599
hyperdxio
ernestii
@@ -1,112 +1,150 @@ import type { Row } from '@clickhouse/client'; +import { ClickhouseClient } from '@hyperdx/common-utils/dist/clickhouse'; +import { getMetadata } from '@hyperdx/common-utils/dist/metadata'; +import { renderChartConfig } from '@hyperdx/common-utils/dist/renderChartConfig'; import opentelemetry, { S...
super nit: I think zod should support converting to number natively with coerce: ``` z.coerce.number() ```
hyperdx
github_2023
typescript
594
hyperdxio
MikeShi42
@@ -389,6 +389,11 @@ export const RawLogTable = memo( const [scrolledToHighlightedLine, setScrolledToHighlightedLine] = useState(false); + // Reset scroll state when highlighted line changes or when table data changes + useEffect(() => { + setScrolledToHighlightedLine(false); + }, [highlight...
I'm not totally following this bug fix, I'm assuming the suspected root cause is that the `highlightedLineId` is updated from one value to another but because the `scrolledToHighlightedLine` doesn't get reset, we don't scroll to that new line id properly. I'm assuming in that case, we should probably just have this ...
hyperdx
github_2023
typescript
594
hyperdxio
MikeShi42
@@ -0,0 +1,267 @@ +import { useMemo, useState } from 'react'; +import { sq } from 'date-fns/locale'; +import ms from 'ms'; +import { useForm } from 'react-hook-form'; +import { + ChartConfigWithDateRange, + TSource, +} from '@hyperdx/common-utils/dist/types'; +import { Badge, Flex, Group, SegmentedControl } from '@ma...
nit: i'm not sure if using `filters` would be appropriate here, but it'd be nice to just call out that `filters` is the right pattern in case anyone stumbles upon this and wants to duplicate this pattern without realizing they might benefit from `filters`
hyperdx
github_2023
others
597
hyperdxio
teeohhem
@@ -115,5 +116,11 @@ services: restart: on-failure networks: - internal + healthcheck: + # "clickhouse", "client", "-u ${CLICKHOUSE_USER}", "--password ${CLICKHOUSE_PASSWORD}", "-q 'SELECT 1'" + test: wget --no-verbose --tries=1 http://127.0.0.1:8123/ping || exit 1 + interval: 10s
Do we want the interval to be that high? I imagine if they're all started around the same time, we could get away with a shorter timeframe.
hyperdx
github_2023
typescript
595
hyperdxio
MikeShi42
@@ -724,31 +731,34 @@ export function TableSourceForm({ render={({ field: { onChange, value } }) => ( <Radio.Group value={value} - onChange={v => onChange(v as 'log' | 'trace')} + onChange={v => onChange(v)} withAsterisk ...
is the intent that we'll follow up with a session model/source form later?
hyperdx
github_2023
others
586
hyperdxio
MikeShi42
@@ -29,11 +29,29 @@ processors: # 25% of limit up to 2G spike_limit_mib: 512 check_interval: 5s +connectors: + routing/logs: + default_pipelines: [logs/out-default] + error_mode: ignore + table: + - statement: route() where IsMatch(attributes["rum.sessionId"], ".*")
Do we want to match based on something a bit more robust to the session replay event itself? Like the scope name being `rum.rr-web` or attributes like `rr-web.event`? I'm just thinking it's possible in the future we'll have logs that will have that rum.sessionId attribute fwiw I'm fine if this is ticketed up for lat...
hyperdx
github_2023
typescript
582
hyperdxio
wrn14897
@@ -158,7 +158,9 @@ export default function DBRowSidePanel({ } const mainContentColumn = getEventBody(source); - const mainContent: string | undefined = normalizedRow?.['__hdx_body']; + const mainContent: string | undefined = normalizedRow?.['__hdx_body'] + ? JSON.stringify(normalizedRow['__hdx_body'])
style: I know we are using these aliases on the frontend. we should create an enum for them. Another issue here is the `JSON.stringify` generates incorrect results on a string, right? (like adding extra quotes). I think we want to do this for the object type only
hyperdx
github_2023
typescript
582
hyperdxio
wrn14897
@@ -693,7 +693,8 @@ function mergeSelectWithPrimaryAndPartitionKey( .split(',') .map(k => extractColumnReference(k.trim())) .filter((k): k is string => k != null && k.length > 0); - const primaryKeyArr = primaryKeys.split(',').map(k => k.trim()); + const primaryKeyArr =
good call on this. this doesn't rule out the string with spaces. how about ``` primaryKeys.trim() !== "" ? primaryKeys.split(',').map(k => k.trim()) : []; ```
hyperdx
github_2023
typescript
582
hyperdxio
wrn14897
@@ -207,50 +226,74 @@ export abstract class SQLSerializer implements Serializer { `(${column} ${isNegatedField ? '!' : ''}= CAST(?, 'Float64'))`, [term], ); + } else if (propertyType === 'json') {
style: can use `JSDataType` enum
hyperdx
github_2023
typescript
582
hyperdxio
wrn14897
@@ -299,6 +343,12 @@ export abstract class SQLSerializer implements Serializer { `(?? ${isNegatedField ? '!' : ''}= CAST(?, 'Float64'))`, [column, term], ); + } else if (propertyType === 'json') { + const shoudUseTokenBf = isImplicitField;
I know it's probably c + p. `shoudUseTokenBf` is misleading here since json type field doesn't have a tokenbf index. we can just do `ILIKE` for now
hyperdx
github_2023
typescript
582
hyperdxio
wrn14897
@@ -476,7 +549,8 @@ export class CustomSchemaSQLSerializerV2 extends SQLSerializer { return { column: this.implicitColumnExpression, - propertyType: 'string' as const, + columnJSON: undefined, + propertyType: JSDataType.String as const,
nit: no need for `as const`
hyperdx
github_2023
typescript
582
hyperdxio
wrn14897
@@ -66,6 +67,52 @@ export default function useRowWhere({ value, chType, ]); + case JSDataType.JSON: + // Handle case for whole json object, ex: json + return SqlString.format(`lower(hex(MD5(toString(?))))=?`, [ + SqlStr...
curious about the reason to set up this cap
hyperdx
github_2023
typescript
582
hyperdxio
wrn14897
@@ -66,6 +67,52 @@ export default function useRowWhere({ value, chType, ]); + case JSDataType.JSON: + // Handle case for whole json object, ex: json + return SqlString.format(`lower(hex(MD5(toString(?))))=?`, [ + SqlStr...
what do you think if we throw here without implementing the hack temporarily? since I'd image this query could take a significant performance hit (string casting and parsing json for each depth)
hyperdx
github_2023
typescript
582
hyperdxio
wrn14897
@@ -158,7 +158,16 @@ export default function DBRowSidePanel({ } const mainContentColumn = getEventBody(source); - const mainContent: string | undefined = normalizedRow?.['__hdx_body']; + let mainContentTypeCheck = normalizedRow?.['__hdx_body'] + ? normalizedRow['__hdx_body'] + : undefined; + if ( + ...
style: we can simplify this chunk (also using `isString` from lodash) ``` const mainContent = isString(normalizedRow?.['__hdx_body']) ? normalizedRow['__hdx_body'] : normalizedRow?.['__hdx_body'] !== undefined ? JSON.stringify(normalizedRow['__hdx_body']) : undefined; ```
hyperdx
github_2023
typescript
582
hyperdxio
wrn14897
@@ -66,6 +66,32 @@ export default function useRowWhere({ value, chType, ]); + case JSDataType.JSON: + // Handle case for whole json object, ex: json + return SqlString.format(`lower(hex(MD5(toString(?))))=?`, [ + SqlStr...
do we get the extra quotes due to JSON.stringify?
hyperdx
github_2023
typescript
528
hyperdxio
MikeShi42
@@ -564,10 +564,15 @@ function ClickhousePage() { color="gray.4" variant="subtle" onClick={() => { + // Clears the min/max latency filters that are used to filter the query results setLatencyFilter({ ...
I suspect `onSearch` should do this already, did it not work with just `onSearch` alone? The logic is a bit tricky to trace but [this useEffect](https://github.com/hyperdxio/hyperdx/blob/990e62ce0408d9c86a28405424fac13076ca6336/packages/app/src/timeQuery.ts#L500) should update it, and it's triggered by [the callback ab...
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -1,24 +1,58 @@ -import { differenceBy, uniq } from 'lodash'; +import { differenceBy, groupBy, uniq } from 'lodash'; import { z } from 'zod'; -import { DashboardWithoutIdSchema, Tile } from '@/common/commonTypes'; +import { DashboardWithoutIdSchema } from '@/common/commonTypes'; import type { ObjectId } from '@/m...
we should also add `team: teamId` filter to lock the query
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -1,24 +1,58 @@ -import { differenceBy, uniq } from 'lodash'; +import { differenceBy, groupBy, uniq } from 'lodash'; import { z } from 'zod'; -import { DashboardWithoutIdSchema, Tile } from '@/common/commonTypes'; +import { DashboardWithoutIdSchema } from '@/common/commonTypes'; import type { ObjectId } from '@/m...
double check we want to select all fields from the alert?
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -1,24 +1,58 @@ -import { differenceBy, uniq } from 'lodash'; +import { differenceBy, groupBy, uniq } from 'lodash'; import { z } from 'zod'; -import { DashboardWithoutIdSchema, Tile } from '@/common/commonTypes'; +import { DashboardWithoutIdSchema } from '@/common/commonTypes'; import type { ObjectId } from '@/m...
any reason we want to add `alert` field to `config` instead of adding it to the top level?
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -1,24 +1,58 @@ -import { differenceBy, uniq } from 'lodash'; +import { differenceBy, groupBy, uniq } from 'lodash'; import { z } from 'zod'; -import { DashboardWithoutIdSchema, Tile } from '@/common/commonTypes'; +import { DashboardWithoutIdSchema } from '@/common/commonTypes'; import type { ObjectId } from '@/m...
perf: can fire `Dashboard.findOne` and `Alert.find` concurrently
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -1,24 +1,58 @@ -import { differenceBy, uniq } from 'lodash'; +import { differenceBy, groupBy, uniq } from 'lodash'; import { z } from 'zod'; -import { DashboardWithoutIdSchema, Tile } from '@/common/commonTypes'; +import { DashboardWithoutIdSchema } from '@/common/commonTypes'; import type { ObjectId } from '@/m...
better to add `team: teamId` filter
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -29,13 +63,27 @@ export async function createDashboard( ...dashboard, team: teamId, }).save(); + + // Create related alerts + for (const tile of dashboard.tiles) { + if (!tile.config.alert) { + await Alert.findOneAndUpdate( + { + dashboard: newDashboard._id, + tileId: ...
hmm...maybe we don't want to create an alert here (SRP). I wonder if we should fire a request at the modal level instead
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -93,27 +110,54 @@ export async function updateDashboardAndAlerts( team: teamId, }, { - ...dashboard, - tags: dashboard.tags && uniq(dashboard.tags), + ...updates, + tags: updates.tags && uniq(updates.tags), }, { new: true }, ); if (updatedDashboard == null) { ...
style: I'd suggest to move all alerting mutation codes from here to another controller
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -48,41 +96,10 @@ export async function deleteDashboardAndAlerts( export async function updateDashboard(
we should write a few more integration tests for cases of updating dashboard
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -93,27 +110,54 @@ export async function updateDashboardAndAlerts( team: teamId, }, { - ...dashboard, - tags: dashboard.tags && uniq(dashboard.tags), + ...updates, + tags: updates.tags && uniq(updates.tags), }, { new: true }, ); if (updatedDashboard == null) { ...
perf: can use set here. also do we want to filter out nullish cases?
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -93,27 +110,54 @@ export async function updateDashboardAndAlerts( team: teamId, }, { - ...dashboard, - tags: dashboard.tags && uniq(dashboard.tags), + ...updates, + tags: updates.tags && uniq(updates.tags), }, { new: true }, ); if (updatedDashboard == null) { ...
safer to add teamId filter here
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -93,27 +110,54 @@ export async function updateDashboardAndAlerts( team: teamId, }, { - ...dashboard, - tags: dashboard.tags && uniq(dashboard.tags), + ...updates, + tags: updates.tags && uniq(updates.tags), }, { new: true }, ); if (updatedDashboard == null) { ...
perf: can run this concurrently
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -346,6 +347,7 @@ export const SavedChartConfigSchema = z.intersection( z.object({ name: z.string(), source: z.string(), + alert: AlertSchemaBase.optional(),
isn't this supposed to be `AlertSchema` ?
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -122,6 +123,53 @@ export const getAlertById = async ( }); }; +export const getDashboardAlerts = async ( + dashboardIds: string[] | null, + teamId: ObjectId, +) => {
style: imo, its not very readable when the 1st arg is null. I'd create two methods `getTeamDashboardAlertsByTile(teamId: ObjectId)` and `getDashboardAlertsByTile(teamId: ObjectId, dashboardId: string)`. we don't need to support the array case.
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -192,6 +192,20 @@ const Tile = forwardRef( [chart.config.source, setRowId, setRowSource], ); + const alert = chart.config.alert; + const alertIndicatorColor = useMemo(() => { + if (!alert) { + return 'transparent'; + } + if (alert.state === 'OK') {
nit: can use `AlertState`
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -122,6 +123,59 @@ export const getAlertById = async ( }); }; +export const getTeamDashboardAlertsByTile = async (teamId: ObjectId) => { + const alerts = await Alert.find({ + source: 'tile',
nit: realized this can be `AlertSource.TILE`
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -96,27 +102,42 @@ export async function updateDashboardAndAlerts( team: teamId, }, { - ...dashboard, - tags: dashboard.tags && uniq(dashboard.tags), + ...updates, + tags: updates.tags && uniq(updates.tags), }, { new: true }, ); if (updatedDashboard == null) { ...
nit: isn't `id` already string type?
hyperdx
github_2023
typescript
562
hyperdxio
wrn14897
@@ -122,6 +123,59 @@ export const getAlertById = async ( }); }; +export const getTeamDashboardAlertsByTile = async (teamId: ObjectId) => { + const alerts = await Alert.find({ + source: 'tile', + team: teamId, + }); + return groupBy(alerts, 'tileId'); +}; + +export const getDashboardAlertsByTile = async (...
nit: this `async` and `await` seem redundant
hyperdx
github_2023
typescript
572
hyperdxio
wrn14897
@@ -0,0 +1,101 @@ +import { dateParser, parseTimeRangeInput } from '../utils'; + +describe('dateParser', () => {
great tests! I wonder if we also want to bump `chrono-node` for bug fixes
hyperdx
github_2023
typescript
563
hyperdxio
wrn14897
@@ -64,6 +72,7 @@ export type SavedSearch = z.infer<typeof SavedSearchSchema>; export const SavedChartConfigSchema = z.any(); export const TileSchema = z.object({ + name: z.string().optional(),
Is this correct? `name` should be within `config` field, right?
hyperdx
github_2023
typescript
563
hyperdxio
wrn14897
@@ -67,6 +67,26 @@ export type AlertChannelType = 'webhook'; export type Alert = z.infer<typeof AlertSchema>; +export enum AlertState { + ALERT = 'ALERT', + DISABLED = 'DISABLED', + INSUFFICIENT_DATA = 'INSUFFICIENT_DATA', + OK = 'OK', +} + +export type AlertHistory = { + counts: number; + createdAt: string;...
should be able to import these from `common-utils` pkg
hyperdx
github_2023
typescript
561
hyperdxio
wrn14897
@@ -38,7 +38,7 @@ export const SavedSearchSchema = z.object({ name: z.string(), select: z.string(), where: z.string(), - whereLanguage: z.string().optional(), + whereLanguage: z.union([z.literal('sql'), z.literal('lucene')]).optional(),
should use `common-utils`
hyperdx
github_2023
typescript
561
hyperdxio
wrn14897
@@ -15,8 +16,7 @@ import { } from '@mantine/core'; import { notifications } from '@mantine/notifications'; -import { type Alert, AlertSchema } from '@/commonTypes'; -import { SQLInlineEditorControlled } from '@/components/SQLInlineEditor'; +import { type Alert, AlertSchema, SavedSearch } from '@/commonTypes';
`common-utils` (https://github.com/hyperdxio/hyperdx/pull/564)
hyperdx
github_2023
typescript
561
hyperdxio
wrn14897
@@ -77,3 +78,49 @@ export const AlertChannelForm = ({ return null; }; + +export const getAlertReferenceLines = ({ + thresholdType, + threshold, + // TODO: zScore +}: { + thresholdType: 'above' | 'below'; + threshold: number; +}) => ( + <> + {threshold != null && thresholdType === 'below' && ( + <Ref...
nit: can use `AlertThresholdType` enum https://github.com/hyperdxio/hyperdx/blob/85002c3546f9a85aab19951344131ace88d9e39e/packages/common-utils/src/types.ts#L176