@@ -16,14 +16,17 @@ interface UseGroupByFieldsProps {
1616 */
1717 groupBys : string [ ] ;
1818 tags : TagCollection ;
19- prefix ?: string ;
19+ hideEmptyOption ?: boolean ;
2020}
2121
22- export function useGroupByFields ( { tags, groupBys} : UseGroupByFieldsProps ) {
22+ export function useGroupByFields ( {
23+ tags,
24+ groupBys,
25+ hideEmptyOption,
26+ } : UseGroupByFieldsProps ) {
2327 const options : Array < SelectOption < string > > = useMemo ( ( ) => {
2428 const potentialOptions = [
25- // We do not support grouping by span id, we have a dedicated sample mode for that
26- ...Object . keys ( tags ) . filter ( key => key !== 'id' ) ,
29+ ...Object . keys ( tags ) . filter ( key => ! DISALLOWED_GROUP_BY_FIELDS . has ( key ) ) ,
2730
2831 // These options aren't known to exist on this project but it was inserted into
2932 // the group bys somehow so it should be a valid options in the group bys.
@@ -36,11 +39,15 @@ export function useGroupByFields({tags, groupBys}: UseGroupByFieldsProps) {
3639
3740 return [
3841 // hard code in an empty option
39- {
40- label : < Disabled > { t ( '\u2014' ) } </ Disabled > ,
41- value : UNGROUPED ,
42- textValue : t ( '\u2014' ) ,
43- } ,
42+ ...( hideEmptyOption
43+ ? [ ]
44+ : [
45+ {
46+ label : < Disabled > { t ( '\u2014' ) } </ Disabled > ,
47+ value : UNGROUPED ,
48+ textValue : t ( '\u2014' ) ,
49+ } ,
50+ ] ) ,
4451 ...potentialOptions . map ( key => {
4552 const kind = FieldKind . TAG ;
4653 return {
@@ -53,11 +60,15 @@ export function useGroupByFields({tags, groupBys}: UseGroupByFieldsProps) {
5360 } ;
5461 } ) ,
5562 ] ;
56- } , [ tags , groupBys ] ) ;
63+ } , [ tags , groupBys , hideEmptyOption ] ) ;
5764
5865 return options ;
5966}
6067
68+ // Some fields don't make sense to allow users to group by as they create
69+ // very high cardinality groupings and is not useful.
70+ const DISALLOWED_GROUP_BY_FIELDS = new Set ( [ 'id' , 'timestamp' ] ) ;
71+
6172const Disabled = styled ( 'span' ) `
6273 color: ${ p => p . theme . subText } ;
6374` ;
0 commit comments