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
aerugo
github_2023
others
2
n7space
SteelPh0enix
@@ -0,0 +1,43 @@ +/// Handle to an event. +/// +/// Handle is used in the system to access an event. +use crate::aerugo::error::RuntimeError; +use crate::event::Event; + +/// Event handle. +#[derive(Copy, Clone)] +pub struct EventHandle { + /// Reference to the event. + _event: &'static Event, +} + +impl EventHan...
I'm not sure if using `f64` as time unit is a good choice. That should be a separate type (i've seen `enum`s used for this kind of thing), because as it is right now, i have no idea what time unit is used. Also, floating-point operations should generally be avoided on MCUs, if possible. In our case it's not a big de...
aerugo
github_2023
others
2
n7space
Lurkerpas
@@ -0,0 +1,141 @@ +//! System control and interface for the user to interact with it. + +pub mod error; + +mod configuration; + +pub use self::configuration::TaskletConfiguration; + +use bare_metal::CriticalSection; + +use crate::api::{InitApi, RuntimeApi}; +use crate::boolean_condition::{BooleanConditionSet, BooleanCo...
cyclic execution? period?
aerugo
github_2023
others
2
n7space
Lurkerpas
@@ -0,0 +1,141 @@ +//! System control and interface for the user to interact with it. + +pub mod error; + +mod configuration; + +pub use self::configuration::TaskletConfiguration; + +use bare_metal::CriticalSection; + +use crate::api::{InitApi, RuntimeApi}; +use crate::boolean_condition::{BooleanConditionSet, BooleanCo...
Still looks like a float used for time....
aerugo
github_2023
others
2
n7space
Lurkerpas
@@ -0,0 +1,135 @@ +/// System initialization API. +/// +/// This API is used for the system initialization, before the scheduler is started. +use crate::boolean_condition::{BooleanConditionSet, BooleanConditionStorage}; +use crate::event::{EventHandle, EventStorage}; +use crate::message_queue::MessageQueueStorage; +use...
Still looks like a float used for time....
hyperdx
github_2023
typescript
715
hyperdxio
knudtty
@@ -0,0 +1,1302 @@ +import * as React from 'react'; +import dynamic from 'next/dynamic'; +import Head from 'next/head'; +import Link from 'next/link'; +import cx from 'classnames'; +import sub from 'date-fns/sub'; +import { + parseAsFloat, + parseAsStringEnum, + useQueryState, + useQueryStates, +} from 'nuqs'; +imp...
I know there's some funky keys below for row, but is there some way to avoid using 'any' here?
hyperdx
github_2023
typescript
715
hyperdxio
knudtty
@@ -0,0 +1,1302 @@ +import * as React from 'react'; +import dynamic from 'next/dynamic'; +import Head from 'next/head'; +import Link from 'next/link'; +import cx from 'classnames'; +import sub from 'date-fns/sub'; +import { + parseAsFloat, + parseAsStringEnum, + useQueryState, + useQueryStates, +} from 'nuqs'; +imp...
This shows up pretty dark, maybe make it consistent with the message for the latest warning table? ![image](https://github.com/user-attachments/assets/de53ed7c-07e0-49e4-afad-8574253ad577)
hyperdx
github_2023
typescript
713
hyperdxio
wrn14897
@@ -467,6 +463,37 @@ export type Field = { jsType: JSDataType | null; }; +export type TableConnection = { + databaseName: string; + tableName: string; + connectionId: string; +}; + +export function isTableConnection(obj: any): obj is TableConnection {
`any` is dangerous. if its used to tell the obj is array or not, I'd do ``` export function isTableConnection( obj: TableConnection | TableConnection[], ): obj is TableConnection { return ( !Array.isArray(obj) && typeof obj?.databaseName === 'string' && typeof obj?.tableName === 'string' && ...
hyperdx
github_2023
typescript
713
hyperdxio
wrn14897
@@ -38,16 +38,15 @@ export default function SearchInputV2({ const ref = useRef<HTMLInputElement>(null); - const { data: fields } = useAllFields( - { - databaseName: database ?? '', - tableName: table ?? '', - connectionId: connectionId ?? '', - }, - { - enabled: !!database && !!tabl...
can you explain more why do we want to accept either a single TableConnection or an array of them? Can't we just do array?
hyperdx
github_2023
typescript
713
hyperdxio
wrn14897
@@ -36,26 +41,39 @@ export function useColumns( } export function useAllFields( - { - databaseName, - tableName, - connectionId, - }: { - databaseName: string; - tableName: string; - connectionId: string; - }, + _tableConnections: TableConnection | TableConnection[], options?: Partial<UseQu...
we better leave the metadata (caching singleton) init outside the function so its not reinit for every queryFn calls
hyperdx
github_2023
typescript
713
hyperdxio
wrn14897
@@ -36,26 +41,39 @@ export function useColumns( } export function useAllFields( - { - databaseName, - tableName, - connectionId, - }: { - databaseName: string; - tableName: string; - connectionId: string; - }, + _tableConnections: TableConnection | TableConnection[], options?: Partial<UseQu...
can just use `objectHash` ``` const _key = objectHash.sha1(field) ```
hyperdx
github_2023
typescript
713
hyperdxio
wrn14897
@@ -886,9 +906,7 @@ function DBDashboardPage({ presetConfig }: { presetConfig?: Dashboard }) { render={({ field }) => field.value === 'sql' ? ( <SQLInlineEditorControlled - connectionId={defaultSource?.connection} - database={defaultDatabaseName} - ...
imo, its confusing we pass tableConnections as `tableConnection` prop
hyperdx
github_2023
typescript
713
hyperdxio
wrn14897
@@ -506,6 +511,28 @@ function DBDashboardPage({ presetConfig }: { presetConfig?: Dashboard }) { const { data: sources } = useSources(); const [highlightedTileId] = useQueryState('highlightedTileId'); + const tableConnections = useMemo(() => { + if (!dashboard) return []; + const tc: TableConnection[] = [...
theoretically, we can go through each select to pull the table name, right? fwiw, there will be only 3 tables total for a single source (you can find them in `source.metricTables`)
hyperdx
github_2023
typescript
713
hyperdxio
wrn14897
@@ -36,26 +42,27 @@ export function useColumns( } export function useAllFields( - { - databaseName, - tableName, - connectionId, - }: { - databaseName: string; - tableName: string; - connectionId: string; - }, + _tableConnections: TableConnection | TableConnection[], options?: Partial<UseQu...
nit: `deduplicate2dArray<Field>(fields2d)`
hyperdx
github_2023
typescript
713
hyperdxio
wrn14897
@@ -0,0 +1,107 @@ +// @ts-ignore +import { deduplicate2dArray } from '../useMetadata'; + +describe('deduplicate2dArray', () => { + // Test basic deduplication + it('should remove duplicate objects across 2D array', () => { + const input = [ + [ + { id: 1, name: 'Alice' }, + { id: 2, name: 'Bob' ...
Lol...like test until it timeout or what?
hyperdx
github_2023
typescript
713
hyperdxio
wrn14897
@@ -115,3 +122,21 @@ export function useGetKeyValues({ placeholderData: keepPreviousData, }); } + +function deduplicate2dArray<T extends object>(array2d: T[][]): T[] { + const array: T[] = []; + const set = new Set<string>(); + for (const _array of array2d) { + for (const elem of _array) { + const k...
we probably don't set the node env for unit test (also you want to use `IS_CI` flag instead). I think we can just export this function
hyperdx
github_2023
typescript
716
hyperdxio
wrn14897
@@ -458,7 +458,12 @@ export function chSqlToAliasMap( ast.columns.forEach(column => { if (column.as != null) { if (column.type === 'expr' && column.expr.type === 'column_ref') { - aliasMap[column.as] = column.expr.column.expr.value; + aliasMap[column.as] =
this hot fix is good for now. I wonder if we could find how the node-sql-parser rebuilds the sql and use that function instead
hyperdx
github_2023
others
692
hyperdxio
wrn14897
@@ -64,7 +64,7 @@ exports[`renderChartConfig should generate sql for a single histogram metric 1`] arrayElement(ExplicitBounds, BucketLowIdx - 1) + (arrayElement(ExplicitBounds, BucketLowIdx) - arrayElement(ExplicitBounds, BucketLowIdx - 1)) * IF(arrayElement(CumRates, BucketLowI...
Trying to understand this change. Does this mean we take the bound bucket if the value exceeds the boundaries? Also wonder what would happen in the old codes?
hyperdx
github_2023
typescript
692
hyperdxio
wrn14897
@@ -608,5 +671,294 @@ describe('renderChartConfig', () => { ); expect(await queryData(maxQuery)).toMatchSnapshot('maxSum'); }); + + it('two_timestamps_bounded histogram (p50)', async () => { + /*
Thanks for adding these comments. They are extremely helpful!
hyperdx
github_2023
typescript
692
hyperdxio
wrn14897
@@ -608,5 +671,294 @@ describe('renderChartConfig', () => { ); expect(await queryData(maxQuery)).toMatchSnapshot('maxSum'); }); + + it('two_timestamps_bounded histogram (p50)', async () => { + /* + This test starts with 2 data points with bounds of [10, 30]: + t0: [0, 0, 0] + ...
is this intentional?
hyperdx
github_2023
typescript
709
hyperdxio
knudtty
@@ -16,60 +16,6 @@ import { LimitedSizeQueue } from '@/utils/queue'; const router = express.Router(); -router.get('/', async (req, res, next) => {
Has this endpoint been deprecated entirely? Anything that previously used this uses clickhouseProxy now?
hyperdx
github_2023
typescript
698
hyperdxio
ernestii
@@ -10,9 +10,11 @@ import { Stack, Tabs, Text, + TextInput, Tooltip, UnstyledButton, } from '@mantine/core'; +import { IconSearch } from '@tabler/icons-react';
heck yeah
hyperdx
github_2023
typescript
698
hyperdxio
ernestii
@@ -66,6 +70,7 @@ export const FilterCheckbox = ({ // taken care by the onClick in the group, triggering here will double fire emptyFn } + indeterminate={value === 'excluded'}
nit: maybe also change the color of the checkbox when it's `excluded`?
hyperdx
github_2023
typescript
698
hyperdxio
ernestii
@@ -0,0 +1,158 @@ +import { render, screen, within } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; + +import { FilterGroup, type FilterGroupProps } from '../DBSearchPageFilters'; + +describe('FilterGroup', () => { + const defaultProps: FilterGroupProps = { + name: 'Test Filter...
👀 noice
hyperdx
github_2023
others
698
hyperdxio
ernestii
@@ -1,11 +1,37 @@ @import './variables'; +/* stylelint-disable selector-pseudo-class-no-unknown */ .filtersPanel { width: 220px; max-height: 100%; background-color: #00000030; flex-shrink: 0; word-break: break-all; + + :global {
nit: this is probably better to move to a global 'mantine-overrides.scss' file? otherwise there might be wrong styling when SearchPage isn't imported
hyperdx
github_2023
typescript
697
hyperdxio
wrn14897
@@ -23,15 +26,27 @@ export default function DBTableChart({ queryKeyPrefix?: string; enabled?: boolean; }) { - const queriedConfig = omit(config, ['granularity']); - const { data, isLoading, isError, error } = useQueriedChartConfig( - queriedConfig, - { - placeholderData: (prev: any) => prev, - ...
since we introduced the offset, we need to add the sorting criteria (by group-by) or the results could be incorrect. This should also address the case when group-by ordering matters, for example, counts by timestamp <img width="535" alt="image" src="https://github.com/user-attachments/assets/106b1c2d-0187-46ca-a275-28...
hyperdx
github_2023
typescript
697
hyperdxio
wrn14897
@@ -31,6 +31,9 @@ export default function DBTableChart({ _config.limit = { limit: 200, }; + if (_config.groupBy && typeof _config.groupBy === 'string') { + _config.orderBy = _config.groupBy;
eventually, we probably want to let users to specify the orderBy (like which fields + asc/desc)
hyperdx
github_2023
typescript
699
hyperdxio
teeohhem
@@ -63,6 +70,41 @@ export default function DBRowSidePanelHeader({ [bodyExpanded, mainContent], ); + const headerRef = useRef<HTMLDivElement>(null); + const [headerHeight, setHeaderHeight] = useState(0); + useEffect(() => { + if (!headerRef.current) return;
nit: DRY `const el = headerRef.current`
hyperdx
github_2023
typescript
699
hyperdxio
teeohhem
@@ -63,6 +70,41 @@ export default function DBRowSidePanelHeader({ [bodyExpanded, mainContent], ); + const headerRef = useRef<HTMLDivElement>(null); + const [headerHeight, setHeaderHeight] = useState(0); + useEffect(() => { + if (!headerRef.current) return; + + const updateHeight = () => { + if (...
not sure you need this safeguard since the null check is on the first line. Since the ResizeObserver only "works" when an element is in the DOM and is resized, I think it's a safe assumption that it's not null.
hyperdx
github_2023
typescript
699
hyperdxio
teeohhem
@@ -63,6 +70,41 @@ export default function DBRowSidePanelHeader({ [bodyExpanded, mainContent], ); + const headerRef = useRef<HTMLDivElement>(null); + const [headerHeight, setHeaderHeight] = useState(0); + useEffect(() => { + if (!headerRef.current) return; + + const updateHeight = () => { + if (...
nit: ``` const resizeObserver = new ResizeObserver(updateHeight); ```
hyperdx
github_2023
typescript
699
hyperdxio
teeohhem
@@ -63,6 +70,41 @@ export default function DBRowSidePanelHeader({ [bodyExpanded, mainContent], ); + const headerRef = useRef<HTMLDivElement>(null); + const [headerHeight, setHeaderHeight] = useState(0); + useEffect(() => { + if (!headerRef.current) return; + + const updateHeight = () => { + if (...
You return immediately if the ref isn't valid already
hyperdx
github_2023
typescript
699
hyperdxio
teeohhem
@@ -63,6 +70,41 @@ export default function DBRowSidePanelHeader({ [bodyExpanded, mainContent], ); + const headerRef = useRef<HTMLDivElement>(null); + const [headerHeight, setHeaderHeight] = useState(0); + useEffect(() => { + if (!headerRef.current) return; + + const updateHeight = () => { + if (...
same here
hyperdx
github_2023
typescript
699
hyperdxio
teeohhem
@@ -97,16 +139,40 @@ export default function DBRowSidePanelHeader({ p="xs" mt="sm" style={{ - maxHeight: 120, + maxHeight: expandSidebarHeader ? maxBoxHeight : undefined, overflow: 'auto', overflowWrap: 'break-word', }} + ...
wait aren't these backwards? Am I reading this correctly? if `expandSidebarHeader` is true wouldn't you show the contract icon?
hyperdx
github_2023
typescript
699
hyperdxio
teeohhem
@@ -97,16 +139,40 @@ export default function DBRowSidePanelHeader({ p="xs" mt="sm" style={{ - maxHeight: 120, + maxHeight: expandSidebarHeader ? maxBoxHeight : undefined,
Isn't this backwards too? If expandSidebarHeader is true, shouldn't max height be undefined?
hyperdx
github_2023
typescript
690
hyperdxio
wrn14897
@@ -16,6 +17,25 @@ import { IS_MTVIEWS_ENABLED } from '@/config'; import { buildMTViewSelectQuery } from '@/hdxMTViews'; import { getMetadata } from '@/metadata'; +export const replaceBracketQuery = (query: any) => { + // sql-formatter throw error when query include brackets, ex: ResourceAttributes['telemetry.sdk....
I think this hurts the sql readability. Ideally we can make the formatter work with bracket
hyperdx
github_2023
typescript
690
hyperdxio
wrn14897
@@ -0,0 +1,462 @@ +// custom dialect ref: https://github.com/sql-formatter-org/sql-formatter/blob/master/docs/dialect.md#custom-dialect-configuration-experimental
Have we checked this dialect is clickhouse compatible? I'd love us to maintain this going forward and contribute to the upstream later :)
hyperdx
github_2023
typescript
693
hyperdxio
teeohhem
@@ -0,0 +1,133 @@ +import { useEffect, useState } from 'react'; +import { UseFormGetValues, UseFormSetValue } from 'react-hook-form'; +import { z } from 'zod'; + +export const SearchConfigSchema = z.object({ + select: z.string(), + source: z.string(), + where: z.string(), + whereLanguage: z.enum(['sql', 'lucene']),...
nit: you could probably just move this to above the loop since this only supports sql suggestions. Can probably just simplify it to ```if (getValues('whereLanguage') == 'sql') return;``` Select and GroupBy conditions don't have any quotes at all, so we probably shouldn't be sending them through the rec engine here...
hyperdx
github_2023
typescript
693
hyperdxio
teeohhem
@@ -0,0 +1,133 @@ +import { useEffect, useState } from 'react'; +import { UseFormGetValues, UseFormSetValue } from 'react-hook-form'; +import { z } from 'zod'; + +export const SearchConfigSchema = z.object({ + select: z.string(), + source: z.string(), + where: z.string(), + whereLanguage: z.enum(['sql', 'lucene']),...
Nice change. I would love to see some unit tests for this.
hyperdx
github_2023
typescript
693
hyperdxio
teeohhem
@@ -136,6 +142,10 @@ export function useQueriedChartConfig( refetchOnWindowFocus: false, ...options, }); + useEffect(() => { + if (options?.onError && query.isError) options.onError(query.error); + }, [query.isError]); + return query;
Just curious why you're using `useEffect` here? Seems like this would be fine..or are you just trying to make sure that onError only gets called once? ``` if (query.isError && options?.onError) { options.onError(query.error); } ```
hyperdx
github_2023
typescript
695
hyperdxio
MikeShi42
@@ -291,6 +292,14 @@ export const MemoChart = memo(function MemoChart({ const color = lineColors[i] ?? _color; + const StackedBarWithOverlap = (props: BarProps) => {
hrm this is weird, there shouldn't be a gap, do we know why there is one?
hyperdx
github_2023
typescript
694
hyperdxio
wrn14897
@@ -258,7 +258,7 @@ export default function DBDeltaChart({ with: [ { name: 'PartIds', - sql: {
something wrong with the type? because this sql supposes to be ChSql type. I wonder why TS didn't pick this up
hyperdx
github_2023
typescript
687
hyperdxio
MikeShi42
@@ -82,76 +81,81 @@ router.get( return; } - const newPath = req.params[0]; - const qparams = new URLSearchParams(req.query); - qparams.delete('hyperdx_connection_id'); - - return createProxyMiddleware({ - target: connection.host, - changeOrigin: true, - pathFil...
if host is undefined, it'll fall back to this URL, which may be undesirable (ex. an instance the user is not supposed to access via firewall policy) we should probably make the `target` some sort of invalid destination just in case, or make sure the `router` fn always returns something truthy (same idea)
hyperdx
github_2023
typescript
687
hyperdxio
MikeShi42
@@ -1,10 +1,23 @@ +import { getHyperDXMetricReader } from '@hyperdx/node-opentelemetry/build/src/metrics'; +import { HostMetrics } from '@opentelemetry/host-metrics'; +import { MeterProvider, MetricReader } from '@opentelemetry/sdk-metrics'; import { serializeError } from 'serialize-error'; import * as config from ...
this doesn't seem to attach any useful identifying resource attributes either, is it because we're not using the `NodeSDK` for metrics?
hyperdx
github_2023
typescript
686
hyperdxio
wrn14897
@@ -125,7 +125,13 @@ export const SelectSQLStatementSchema = z.object({ .array( z.object({ name: z.string(), - sql: z.lazy(() => ChSqlSchema.or(ChartConfigSchema)), + + // Need to specify either a sql or chartConfig instance. To avoid + // the schema falling into an any type, t...
curious the reason we use z.lazy here?
hyperdx
github_2023
typescript
686
hyperdxio
wrn14897
@@ -133,7 +133,7 @@ describe('renderChartConfig', () => { query_params: query.params, format: 'JSON', }) - .then(res => res.json<any>()); + .then(res => res.json() as any);
I don't think we need to type it here (by default its unknown)
hyperdx
github_2023
typescript
666
hyperdxio
wrn14897
@@ -734,23 +734,50 @@ function renderLimit( // CTE (Common Table Expressions) isn't exported at this time. It's only used internally // for metric SQL generation. type ChartConfigWithOptDateRangeEx = ChartConfigWithOptDateRange & { - with?: { name: string; sql: ChSql }[]; includedDataInterval?: string; }; -fu...
This conflicts with the change in another PR to enable aliases (https://github.com/hyperdxio/hyperdx/pull/659/files#diff-baa4dde970c49e5ffe3667e2fe8bbc58b29e3055834c734871343dbe3cd66e56R748). Maybe we can merge that PR first. There is a case we want to treat sql as a function or variable
hyperdx
github_2023
typescript
666
hyperdxio
wrn14897
@@ -734,23 +734,50 @@ function renderLimit( // CTE (Common Table Expressions) isn't exported at this time. It's only used internally // for metric SQL generation. type ChartConfigWithOptDateRangeEx = ChartConfigWithOptDateRange & { - with?: { name: string; sql: ChSql }[]; includedDataInterval?: string; }; -fu...
claude? I got a similar results Lol. I realized once the `ChSqlSchema` is defined. we can just use zod to do the validation
hyperdx
github_2023
typescript
666
hyperdxio
wrn14897
@@ -734,23 +734,50 @@ function renderLimit( // CTE (Common Table Expressions) isn't exported at this time. It's only used internally // for metric SQL generation. type ChartConfigWithOptDateRangeEx = ChartConfigWithOptDateRange & { - with?: { name: string; sql: ChSql }[]; includedDataInterval?: string; }; -fu...
better not to use `UNSAFE_RAW_SQL` if possible. I wonder in this case we want to do `${{ identifier: sql }}`
hyperdx
github_2023
typescript
666
hyperdxio
wrn14897
@@ -734,23 +734,50 @@ function renderLimit( // CTE (Common Table Expressions) isn't exported at this time. It's only used internally // for metric SQL generation. type ChartConfigWithOptDateRangeEx = ChartConfigWithOptDateRange & { - with?: { name: string; sql: ChSql }[]; includedDataInterval?: string; }; -fu...
better to verify if sql is a valid chart config and throw if nothing matches
hyperdx
github_2023
typescript
666
hyperdxio
wrn14897
@@ -341,9 +344,24 @@ export const _ChartConfigSchema = z.object({ metricTables: MetricTableSchema.optional(), }); +export const CteExpressions = z.object({ + with: z + .array( + z.object({ + name: z.string(), + sql: z + .string() + .or(SelectSQLStatementSchema) + ...
does this do any validation? I suspect we want to infer ChSql from the zod schema instead. Like ``` const ChSqlSchema = z.object({ sql: z.string(), params: z.record(z.any()), }); export type ChSql = z.infer<typeof ChSqlSchema>; ```
hyperdx
github_2023
typescript
666
hyperdxio
wrn14897
@@ -737,21 +735,49 @@ type ChartConfigWithOptDateRangeEx = ChartConfigWithOptDateRange & { includedDataInterval?: string; }; -function renderWith( +async function renderWith( chartConfig: ChartConfigWithOptDateRangeEx, metadata: Metadata, -): ChSql | undefined { +): Promise<ChSql | undefined> { const { w...
style: not a blocker. this isn't very readable imo. I wonder if we could split fields for `with` like ``` { name: string; sql?: string; chSql?: ChSql; chartConfig?: ChartConfig; } ```
hyperdx
github_2023
typescript
666
hyperdxio
wrn14897
@@ -737,21 +735,49 @@ type ChartConfigWithOptDateRangeEx = ChartConfigWithOptDateRange & { includedDataInterval?: string; }; -function renderWith( +async function renderWith( chartConfig: ChartConfigWithOptDateRangeEx, metadata: Metadata, -): ChSql | undefined { +): Promise<ChSql | undefined> { const { w...
I feel this should be passed from the 'with', no?
hyperdx
github_2023
typescript
666
hyperdxio
wrn14897
@@ -102,6 +102,12 @@ export const LimitSchema = z.object({ limit: z.number().optional(), offset: z.number().optional(), }); + +export const ChSqlSchema = z.object({ + sql: z.string(), + params: z.record(z.string(), z.any()), +});
👍
hyperdx
github_2023
typescript
675
hyperdxio
MikeShi42
@@ -1106,7 +1106,7 @@ export async function renderChartConfig( return concatChSql(' ', [ chSql`${withClauses?.sql ? chSql`WITH ${withClauses}` : ''}`, - chSql`SELECT ${select}`, + chSql`SELECT ${select?.sql ? select : '*'}`,
this feels pretty dangerous, we should fail loudly instead of silently adding '*' IMO, this logic is used everywhere in our app.
hyperdx
github_2023
typescript
675
hyperdxio
MikeShi42
@@ -494,7 +494,7 @@ export const renderAlertTemplate = async ({ displayType: DisplayType.Search, dateRange: [startTime, endTime], from: source.from, - select: savedSearch.select ?? source.defaultTableSelectExpression, + select: savedSearch.select || source.defaultTableSelectExpression || ...
ah that's great, imo we should not fall back to '*' here but the `||` fix is great
hyperdx
github_2023
typescript
673
hyperdxio
wrn14897
@@ -36,6 +36,17 @@ export function RowOverviewPanel({ const resourceAttributes = firstRow?.__hdx_resource_attributes ?? EMPTY_OBJ; const eventAttributes = firstRow?.__hdx_event_attributes ?? EMPTY_OBJ; + const dataAttributes = + source.kind === 'log'
style: can use `SourceKind` enum
hyperdx
github_2023
typescript
673
hyperdxio
wrn14897
@@ -36,6 +36,17 @@ export function RowOverviewPanel({ const resourceAttributes = firstRow?.__hdx_resource_attributes ?? EMPTY_OBJ; const eventAttributes = firstRow?.__hdx_event_attributes ?? EMPTY_OBJ; + const dataAttributes = + source.kind === 'log' + ? firstRow?.['LogAttributes'] && + Object.k...
we should use `eventAttributesExpression` from source instead of hard-coded attribute here
hyperdx
github_2023
typescript
673
hyperdxio
wrn14897
@@ -49,17 +60,24 @@ export function RowOverviewPanel({ ); const isHttpRequest = useMemo(() => { - return eventAttributes?.['http.url'] != null; - }, [eventAttributes]); + const attributes = + dataAttributes?.LogAttributes || dataAttributes?.SpanAttributes; + return attributes?.['http.url'] != nul...
Same thing here
hyperdx
github_2023
typescript
673
hyperdxio
wrn14897
@@ -25,6 +25,10 @@ export function RowOverviewPanel({ const { onPropertyAddClick, generateSearchUrl } = useContext(RowSidePanelContext); + const eventAttributesExpr = + source.eventAttributesExpression ?? + (source.kind === SourceKind.Log ? 'LogAttributes' : 'SpanAttributes');
Not sure if we want to use the hard-coded values. can we bypass it if the attribute expression isn't specified?
hyperdx
github_2023
typescript
673
hyperdxio
wrn14897
@@ -49,17 +59,23 @@ export function RowOverviewPanel({ ); const isHttpRequest = useMemo(() => { - return eventAttributes?.['http.url'] != null; - }, [eventAttributes]); + const attributes = + eventAttributesExpr && dataAttributes?.[eventAttributesExpr]; + return attributes?.['http.url'] != null;
I want to point out this is trace specific attribute (https://github.com/open-telemetry/opentelemetry-js/blob/eaebf765d8408b29264af5c50e51ce494781455e/semantic-conventions/src/trace/SemanticAttributes.ts#L91). I'd suggest to import these attributes from semantic convention library
hyperdx
github_2023
typescript
659
hyperdxio
wrn14897
@@ -746,7 +745,12 @@ function renderWith( if (withClauses) { return concatChSql( ',', - withClauses.map(clause => chSql`${clause.name} AS (${clause.sql})`), + withClauses.map(clause => { + if (clause.isSubquery) { + return chSql`${{ Identifier: clause.name }} AS (${clause.sql})`...
using with variable to bypass alias is quite clever! 🤯
hyperdx
github_2023
typescript
659
hyperdxio
wrn14897
@@ -115,6 +115,23 @@ export const SelectSQLStatementSchema = z.object({ havingLanguage: SearchConditionLanguageSchema.optional(), orderBy: SortSpecificationListSchema.optional(), limit: LimitSchema.optional(), + with: z + .array( + z.object({ + name: z.string(), + sql: z.object({ + ...
style: maybe we can call it `isVariable`
hyperdx
github_2023
typescript
659
hyperdxio
wrn14897
@@ -531,7 +531,14 @@ export class CustomSchemaSQLSerializerV2 extends SQLSerializer { throw new Error('Unsupported column type for prefix match'); } - throw new Error(`Column not found: ${field}`); + // It might be an alias, let's just try the column + // TODO: Verify aliases
I'm not sure if this would cause weird behaviors (things like sql injection). Also, the error message is different if users search with an unexisting field. I think we can ticket it and move on. I just want to keep it on the radar.
hyperdx
github_2023
typescript
668
hyperdxio
wrn14897
@@ -426,10 +428,12 @@ export class Metadata { query: sql.sql, query_params: sql.params, connectionId: chartConfig.connection, - clickhouse_settings: { - max_rows_to_read: DEFAULT_SAMPLE_SIZE, - read_overflow_mode: 'break', - }, + clickhouse_settings: !di...
I'm a bit worried about the performance impact. I wonder if we want to enable caching for this method (using `this.cache.getOrFetch`). Besides, I wish the column type is `LowCardinality`
hyperdx
github_2023
typescript
664
hyperdxio
MikeShi42
@@ -445,5 +446,9 @@ export type Field = { jsType: JSDataType | null; }; +const __LOCAL_CACHE__ = new MetadataCache();
i think it's okay if we just name this normally (ex. `cache`)
hyperdx
github_2023
typescript
664
hyperdxio
MikeShi42
@@ -13,7 +13,7 @@ import type { ChartConfigWithDateRange } from '@/types'; const DEFAULT_SAMPLE_SIZE = 1e6; -class MetadataCache {
extra export?
hyperdx
github_2023
typescript
658
hyperdxio
wrn14897
@@ -2,4 +2,7 @@ import { getMetadata as _getMetadata } from '@hyperdx/common-utils/dist/metadata import { getClickhouseClient } from '@/clickhouse'; -export const getMetadata = () => _getMetadata(getClickhouseClient()); +const _metadata = _getMetadata(getClickhouseClient()); + +// TODO: Get rid of this function an...
the reason this is not a singleton because the client host might be set in the local mode (https://github.com/hyperdxio/hyperdx/blob/53f150685bf1100a18e154bc369a9b5448d9523e/packages/app/src/clickhouse.ts#L27-L40)
hyperdx
github_2023
typescript
658
hyperdxio
wrn14897
@@ -0,0 +1,497 @@ +import { useCallback, useEffect, useRef, useState } from 'react';
I assume these are c+p
hyperdx
github_2023
typescript
658
hyperdxio
wrn14897
@@ -1,25 +1,20 @@ -import { useCallback, useEffect, useRef, useState } from 'react'; +// ================================ +// NOTE: +// This file should only hold functions that relate to the clickhouse client +// not specific querying/functionality logic +// please move app-specific functions elsewhere in the app
Thanks for adding the comment
hyperdx
github_2023
typescript
657
hyperdxio
LYHuang
@@ -32,19 +79,66 @@ export function useQueriedChartConfig( console.log('mtViewDDL:', mtViewDDL); query = await renderMTViewConfig(); } - if (query == null) { - query = await renderChartConfig(config, getMetadata()); + + const queries: ChSql[] = await Promise.all( + split...
Are we also care the case when there is only one resultSet and `resultSet.meta` is missing `timestampColumn`?
hyperdx
github_2023
typescript
657
hyperdxio
MikeShi42
@@ -13,6 +15,49 @@ import { IS_MTVIEWS_ENABLED } from '@/config'; import { buildMTViewSelectQuery } from '@/hdxMTViews'; import { getMetadata } from '@/metadata'; +export const isMetric = (config: ChartConfigWithOptDateRange) => + config.metricTables != null; + +// TODO: apply this to all chart configs +export con...
what other queries would we want to do this on?
hyperdx
github_2023
typescript
657
hyperdxio
MikeShi42
@@ -13,6 +15,49 @@ import { IS_MTVIEWS_ENABLED } from '@/config'; import { buildMTViewSelectQuery } from '@/hdxMTViews'; import { getMetadata } from '@/metadata'; +export const isMetric = (config: ChartConfigWithOptDateRange) => + config.metricTables != null; + +// TODO: apply this to all chart configs +export con...
why are we adding this to non-metrics queries? it's currently breaking the row side panel and it's not clear to me why we need this
hyperdx
github_2023
typescript
657
hyperdxio
MikeShi42
@@ -13,6 +15,49 @@ import { IS_MTVIEWS_ENABLED } from '@/config'; import { buildMTViewSelectQuery } from '@/hdxMTViews'; import { getMetadata } from '@/metadata'; +export const isMetric = (config: ChartConfigWithOptDateRange) => + config.metricTables != null; + +// TODO: apply this to all chart configs
why do we want to overwrite all aliases?
hyperdx
github_2023
typescript
555
hyperdxio
MikeShi42
@@ -1,440 +1,5 @@ -import { - ChSql, - chSql, - ColumnMeta, - convertCHDataTypeToJSType, - filterColumnMetaByType, - JSDataType, - sendQuery, - tableExpr, -} from '@/clickhouse'; +import { getMetadata as _getMetadata } from '@hyperdx/common-utils/dist/metadata'; -import { - ChartConfigWithDateRange, - rende...
why did we change this from a singleton? aren't we creating a ton of new metadata objects without reason?
hyperdx
github_2023
typescript
656
hyperdxio
LYHuang
@@ -57,11 +61,59 @@ export function RowOverviewPanel({ return eventAttributes; }, [eventAttributes, isHttpRequest]); + const exceptionValues = useMemo(() => { + const parsedEvents = + firstRow?.__hdx_events_exception_attributes ?? EMPTY_OBJ; + const stacktrace = + parsedEvents?.['exception.st...
if `firstRow['__hdx_body'] = null`, it will return string `null`, unless that is what we want. ``` const mainContent = isString(firstRow?.['__hdx_body']) ? firstRow['__hdx_body'] : firstRow?.['__hdx_body'] !=null // so null and undefined will all pass ? JSON.stringify(firstRow['__hdx_body']) :...
hyperdx
github_2023
typescript
656
hyperdxio
LYHuang
@@ -0,0 +1,677 @@ +import React, { useMemo } from 'react'; +import cx from 'classnames'; +import { ErrorBoundary } from 'react-error-boundary'; +import { Button, Text, Tooltip } from '@mantine/core'; +import { Group, Loader } from '@mantine/core'; +import { ColumnDef, Row, Table as TanstackTable } from '@tanstack/react...
nit: prob use `firstException?.stacktrace?.frames` at here.
hyperdx
github_2023
typescript
652
hyperdxio
MikeShi42
@@ -118,6 +120,14 @@ function getConfig(source: TSource, traceId: string) { }, ] : []), + ...(alias.SpanAttributes
I think it's preferable in general performance-wise for us to specifically pull out the values `http.url`, etc. This in theory will also help if we do things like materialized columns on those values and whatnot.
hyperdx
github_2023
typescript
652
hyperdxio
MikeShi42
@@ -391,19 +404,24 @@ export function DBTraceWaterfallChartContainer({ const start = startOffset - minOffset; const end = start + tookMs; - const body = result.Body; - const serviceName = result.ServiceName; - const type = result.type; + const { Body: body, ServiceName: serviceName, id, type } =...
Just realizing, I think we want to condition this on spanKind client? that way it's only shown for HTTP requests from a client (since servers should be handled elsewhere in the logic iirc)
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -816,36 +816,51 @@ function translateMetricChartConfig( whereLanguage: 'sql', }; } else if (metricType === MetricsDataType.Sum && metricName) { + const time_bucket_col = '`__hdx_time_bucket2`'; + const value_high_col = '`__hdx_value_high`'; + const value_high_prev_col = '`__hdx_value_high_pre...
style: this sql is a bit hard to read. I wonder if we could do multiple CTEs and also break each select fields into one line
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -104,28 +104,32 @@ describe('renderChartConfig', () => { const generatedSql = await renderChartConfig(config, mockMetadata); const actual = parameterizedQueryToSql(generatedSql); expect(actual).toBe( - 'WITH RawSum AS (SELECT *,\n' + - ' any(Value) OVER (ROWS BETWEEN 1 PRECED...
I suspect we don't need a unit test for this given the integration tests cover most of the use cases
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -816,36 +816,51 @@ function translateMetricChartConfig( whereLanguage: 'sql', }; } else if (metricType === MetricsDataType.Sum && metricName) { + const time_bucket_col = '`__hdx_time_bucket2`'; + const value_high_col = '`__hdx_value_high`'; + const value_high_prev_col = '`__hdx_value_high_pre...
style: maybe we can rename this sub table to something other than 'a'
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -816,36 +816,51 @@ function translateMetricChartConfig( whereLanguage: 'sql', }; } else if (metricType === MetricsDataType.Sum && metricName) { + const time_bucket_col = '`__hdx_time_bucket2`'; + const value_high_col = '`__hdx_value_high`'; + const value_high_prev_col = '`__hdx_value_high_pre...
My understanding of this query is we compute rates and sum them into accumulative values, and then compute rates again. I wonder if its more efficient to use accumulative values at the beginning (if `AggregationTemporality` is 1, then adding values up) given most of sum metrics are likely to be accumulative
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -816,36 +816,80 @@ function translateMetricChartConfig( whereLanguage: 'sql', }; } else if (metricType === MetricsDataType.Sum && metricName) { + const time_bucket_col = '`__hdx_time_bucket2`'; + const value_high_col = '`__hdx_value_high`'; + const value_high_prev_col = '`__hdx_value_high_pre...
style: we use camel-case across the ts codebase :)
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -816,36 +816,80 @@ function translateMetricChartConfig( whereLanguage: 'sql', }; } else if (metricType === MetricsDataType.Sum && metricName) { + const time_bucket_col = '`__hdx_time_bucket2`'; + const value_high_col = '`__hdx_value_high`'; + const value_high_prev_col = '`__hdx_value_high_pre...
nit: can be `time_bucket_col`
hyperdx
github_2023
others
650
hyperdxio
wrn14897
@@ -21,15 +21,41 @@ Array [ ] `; +exports[`renderChartConfig Query Metrics calculates min_rate/max_rate correctly for sum metrics: maxSum 1`] = `
🔥 🔥 🔥
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -430,12 +430,23 @@ describe('renderChartConfig', () => { expect(await queryData(query)).toMatchSnapshot(); }); - // FIXME: here are the expected values - // [0, 1, 8, 8, 15, 15, 23, 25, 25, 67] - // [0, 2, 9, 9, 24, 34, 44, 66, 66, 158] - // min -> [15, 52] - // max -> [24, 134] - it....
Thanks for adding more context here
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -816,36 +816,80 @@ function translateMetricChartConfig( whereLanguage: 'sql', }; } else if (metricType === MetricsDataType.Sum && metricName) { + const time_bucket_col = '`__hdx_time_bucket2`'; + const value_high_col = '`__hdx_value_high`'; + const value_high_prev_col = '`__hdx_value_high_pre...
I think we want to do the time range filtering here so db won't scan the whole table (`TimeUnix` is the partition key)
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -443,23 +445,23 @@ async function timeFilterExpr({ ); } + const startTimeCond = includedDataInterval + ? chSql`toStartOfInterval(fromUnixTimestamp64Milli(${{ Int64: startTime }}), INTERVAL ${includedDataInterval}) - INTERVAL ${includedDataInterval}` + : chSql`fromUnixTimestamp64M...
style: do you think it would be slightly cleaner if we pass the extended date range instead? since I'd imagine this is only used for metrics
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -872,36 +876,95 @@ async function translateMetricChartConfig( timestampValueExpression: timeBucketCol, }; } else if (metricType === MetricsDataType.Sum && metricName) { + const timeBucketCol = '__hdx_time_bucket2'; + const valueHighCol = '`__hdx_value_high`'; + const valueHighPrevCol = '`__hd...
style: can use `DEFAULT_METRIC_TABLE_TIME_COLUMN`
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -872,36 +876,95 @@ async function translateMetricChartConfig( timestampValueExpression: timeBucketCol, }; } else if (metricType === MetricsDataType.Sum && metricName) { + const timeBucketCol = '__hdx_time_bucket2'; + const valueHighCol = '`__hdx_value_high`'; + const valueHighPrevCol = '`__hd...
do we need to extend both ends or only the start ?
hyperdx
github_2023
typescript
650
hyperdxio
wrn14897
@@ -872,36 +876,95 @@ async function translateMetricChartConfig( timestampValueExpression: timeBucketCol, }; } else if (metricType === MetricsDataType.Sum && metricName) { + const timeBucketCol = '__hdx_time_bucket2'; + const valueHighCol = '`__hdx_value_high`'; + const valueHighPrevCol = '`__hd...
double check this still handles counter reset. it's very clean and I'm kinda surprised
hyperdx
github_2023
typescript
626
hyperdxio
wrn14897
@@ -61,6 +65,8 @@ export default function SessionSubpanel({ start: Date; end: Date; initialTs?: number; + where?: string; + whereLanguage?: 'sql' | 'lucene';
style: can use `SearchConditionLanguage`
hyperdx
github_2023
typescript
648
hyperdxio
teeohhem
@@ -142,6 +145,17 @@ const Line = React.memo( // mounting it for potentially hundreds of lines const { ref, hovered } = useHover<HTMLDivElement>(); + const isCollapsibleString = + isString(value) && + (value.split('\n').length > 1 || + value.length > STRING_COLLAPSE_THRESHOLD); + cons...
It would be neat if we could use mantine's Spoiler component for this: https://mantine.dev/core/spoiler/
hyperdx
github_2023
typescript
647
hyperdxio
wrn14897
@@ -167,6 +167,19 @@ export function LogTableModelForm({ connectionId={connectionId} /> </FormRow> + <FormRow
Can we move this to 'optional fields'?
hyperdx
github_2023
typescript
642
hyperdxio
teeohhem
@@ -152,7 +152,8 @@ export const SessionEventList = ({ const isNavigation = spanName === 'routeChange' || spanName === 'documentLoad'; - const isError = event.severity_text === 'error' || statusCode > 499; + const isError = + event.severity_text.toLowerCase() === 'error' || ...
nit: `event.severity_text?.toLowerCase()`
hyperdx
github_2023
typescript
625
hyperdxio
wrn14897
@@ -484,3 +496,41 @@ export default function SessionsPage() { } SessionsPage.getLayout = withAppNav; + +function SessionSetupInstructions() { + return ( + <> + <Stack w={500} mx="auto" mt="xl" gap="xxs"> + <i className="bi bi-laptop text-slate-600 fs-1"></i> + <Text c="gray" fw={500} size="xs...
do we want to point the doc link?
hyperdx
github_2023
typescript
625
hyperdxio
wrn14897
@@ -481,3 +493,41 @@ export default function SessionsPage() { } SessionsPage.getLayout = withAppNav; + +function SessionSetupInstructions() { + return ( + <> + <Stack w={500} mx="auto" mt="xl" gap="xxs"> + <i className="bi bi-laptop text-slate-600 fs-1"></i> + <Text c="gray" fw={500} size="xs...
Looks good!
hyperdx
github_2023
typescript
637
hyperdxio
wrn14897
@@ -61,10 +58,45 @@ function getTableBody(tableModel: TSource) { } } -function getConfig(source: TSource, traceId: string) { +function useSortKey(source: TSource): string { + let rowSortTimestamp = source.timestampValueExpression; + const { data: sourceCols } = useColumns({
I think we want to use `useAllFields` (https://github.com/hyperdxio/hyperdx/blob/e80630c1075d381f91dde43301dfceb92b95100e/packages/app/src/hooks/useMetadata.tsx#L38) instead
hyperdx
github_2023
typescript
637
hyperdxio
wrn14897
@@ -61,10 +58,45 @@ function getTableBody(tableModel: TSource) { } } -function getConfig(source: TSource, traceId: string) { +function useSortKey(source: TSource): string { + let rowSortTimestamp = source.timestampValueExpression; + const { data: sourceCols } = useColumns({ + connectionId: source.connection,...
use `jsType` for type comparison
hyperdx
github_2023
typescript
637
hyperdxio
wrn14897
@@ -61,10 +58,45 @@ function getTableBody(tableModel: TSource) { } } -function getConfig(source: TSource, traceId: string) { +function useSortKey(source: TSource): string { + let rowSortTimestamp = source.timestampValueExpression; + const { data: sourceCols } = useColumns({ + connectionId: source.connection,...
we still need to keep `getDisplayedTimestampValueExpression`
hyperdx
github_2023
typescript
637
hyperdxio
wrn14897
@@ -61,10 +58,45 @@ function getTableBody(tableModel: TSource) { } } -function getConfig(source: TSource, traceId: string) { +function useSortKey(source: TSource): string { + let rowSortTimestamp = source.timestampValueExpression; + const { data: sourceCols } = useColumns({ + connectionId: source.connection,...
we want to keep `getDisplayedTimestampValueExpression(source)` as a fallback option