-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add autocomplete of metrics attributes #623
base: warren/metrics-mvp
Are you sure you want to change the base?
Conversation
|
import { getClickhouseClient } from '@/clickhouse'; | ||
import { formatAttributeClause } from '@/utils'; | ||
|
||
const METRIC_FETCH_LIMIT = 25; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just an arbitrary limit I chose. Happy to adjust as needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be able to safely set this into the thousands?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok cool. I started low to error on the side of caution. I also saw in V1 there was a top 10 suggestion limit of some sort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure which limit but if it's something as low as 10 it's probably just a rendering limit to keep the DOM happy, we're usually relatively aggressive with these limits if the user can't tweak them on their own so it's less likely whatever they're looking for won't appear.
@@ -339,6 +317,7 @@ export function SQLInlineEditorControlled({ | |||
table={table} | |||
value={field.value || props.defaultValue} | |||
connectionId={connectionId} | |||
additionalSuggestions={additionalSuggestions} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds the ability to arbitrarily add suggestions to autocomplete that aren't already based on a source. I didn't see a way to do this, but correct me if I'm wrong!
? `ResourceAttributes['${field}'] = '${value}'` | ||
: `ResourceAttributes.${field}:"${value}"`; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just moving this function into utils so it can be used in other places as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few nice to have improvements that we can follow up with later
import { getClickhouseClient } from '@/clickhouse'; | ||
import { formatAttributeClause } from '@/utils'; | ||
|
||
const METRIC_FETCH_LIMIT = 25; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be able to safely set this into the thousands?
const clickhouseClient = getClickhouseClient(); | ||
|
||
const sql = chSql` | ||
SELECT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to do select distinct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated in latest commit, as well as increasing the initial limit
query_params: sql.params, | ||
format: 'JSON', | ||
abort_signal: signal, | ||
connectionId: tableSource!.connection, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it may be nice to also add a row scan limit
hyperdx/packages/common-utils/src/metadata.ts
Lines 428 to 431 in 4529dfe
clickhouse_settings: { | |
max_rows_to_read: DEFAULT_SAMPLE_SIZE, | |
read_overflow_mode: 'break', | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New ticket created: HDX-1410
@@ -17,6 +17,7 @@ export default function SearchInputV2({ | |||
connectionId, | |||
enableHotkey, | |||
onSubmit, | |||
additionalSuggestions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that idea. Will add a ticket to follow up on this and the other suggestions. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New ticket created: HDX-1410
FROM ${tableName} | ||
WHERE MetricName='${metricName}' | ||
LIMIT ${METRIC_FETCH_LIMIT.toString()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: we want to parameterize query like
FROM ${tableExpr({ database: databaseName, table: tableName })}
WHERE MetricName=${{ String: metricName }}
LIMIT ${{ Int32: METRIC_FETCH_LIMIT}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in latest commit
abort_signal: signal, | ||
connectionId: tableSource!.connection, | ||
}) | ||
.then(res => res.json())) as ResponseJSON<{ Attributes: object }>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{
ScopeAttributes?: Record<string, string>;
ResourceAttributes?: Record<string, string>;
Attributes?: Record<string, string>;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in latest commit
Adds backend call to grab attributes for a metric + adds them to autocomplete suggestions.
Ref: HDX-1402