Skip to content

Commit 99c7881

Browse files
authored
feat(ourlogs): Add a count unique function (#93852)
This lets you show how many unique values exist for a given parameter
1 parent 0a55cd2 commit 99c7881

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

static/app/views/explore/logs/logsToolbar.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ const TOOLBAR_AGGREGATES = [
1919
label: t('count'),
2020
value: AggregationKey.COUNT,
2121
},
22+
{
23+
label: t('count unique'),
24+
value: AggregationKey.COUNT_UNIQUE,
25+
},
2226
{
2327
label: t('sum'),
2428
value: AggregationKey.SUM,
@@ -69,15 +73,21 @@ export function LogsToolbar({stringTags, numberTags}: LogsToolbarProps) {
6973
const setLogsPageParams = useSetLogsPageParams();
7074
const functionArgRef = useRef<HTMLDivElement>(null);
7175

72-
const aggregatableKeys = Object.keys(numberTags ?? {}).map(key => ({
76+
let aggregatableKeys = Object.keys(numberTags ?? {}).map(key => ({
7377
label: prettifyTagKey(key),
7478
value: key,
7579
}));
76-
if (aggregateFunction === 'count') {
77-
aggregatableKeys.length = 0;
78-
aggregatableKeys.unshift({label: t('logs'), value: 'logs'});
80+
81+
if (aggregateFunction === AggregationKey.COUNT) {
82+
aggregatableKeys = [{label: t('logs'), value: 'logs'}];
7983
aggregateParam = 'logs';
8084
}
85+
if (aggregateFunction === AggregationKey.COUNT_UNIQUE) {
86+
aggregatableKeys = Object.keys(stringTags ?? {}).map(key => ({
87+
label: prettifyTagKey(key),
88+
value: key,
89+
}));
90+
}
8191

8292
return (
8393
<Container>

static/app/views/explore/logs/types.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export interface EventsLogsResult {
9292

9393
export type OurLogsAggregate =
9494
| AggregationKey.COUNT
95+
| AggregationKey.COUNT_UNIQUE
9596
| AggregationKey.SUM
9697
| AggregationKey.AVG
9798
| AggregationKey.P50

0 commit comments

Comments
 (0)