14
14
15
15
from sentry .exceptions import InvalidSearchQuery
16
16
from sentry .search .eap import constants
17
- from sentry .search .events .constants import SPAN_MODULE_CATEGORY_VALUES
17
+ from sentry .search .events .constants import DURATION_UNITS , SIZE_UNITS , SPAN_MODULE_CATEGORY_VALUES
18
18
from sentry .search .events .types import SnubaParams
19
19
from sentry .search .utils import DEVICE_CLASS
20
20
from sentry .utils .validators import is_event_id , is_span_id
@@ -74,9 +74,14 @@ def proto_definition(self) -> AttributeKey:
74
74
)
75
75
76
76
77
+ SIZE_TYPE : set [constants .SearchType ] = set (SIZE_UNITS .keys ())
78
+
79
+ DURATION_TYPE : set [constants .SearchType ] = set (DURATION_UNITS .keys ())
80
+
81
+
77
82
@dataclass
78
83
class ArgumentDefinition :
79
- argument_types : list [constants .SearchType ] | None = None
84
+ argument_types : set [constants .SearchType ] | None = None
80
85
# The public alias for the default arg, the SearchResolver will resolve this value
81
86
default_arg : str | None = None
82
87
# Whether this argument is completely ignored, used for `count()`
@@ -505,7 +510,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
505
510
default_search_type = "duration" ,
506
511
arguments = [
507
512
ArgumentDefinition (
508
- argument_types = [ "byte " , "duration " , "millisecond" , "number" ] ,
513
+ argument_types = { "duration " , "number " , * SIZE_TYPE , * DURATION_TYPE } ,
509
514
default_arg = "span.duration" ,
510
515
)
511
516
],
@@ -515,7 +520,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
515
520
default_search_type = "duration" ,
516
521
arguments = [
517
522
ArgumentDefinition (
518
- argument_types = [ "byte " , "duration " , "millisecond " , "number" , "percentage" ] ,
523
+ argument_types = { "duration " , "number " , "percentage " , * SIZE_TYPE , * DURATION_TYPE } ,
519
524
default_arg = "span.duration" ,
520
525
)
521
526
],
@@ -525,7 +530,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
525
530
default_search_type = "duration" ,
526
531
arguments = [
527
532
ArgumentDefinition (
528
- argument_types = [ "byte " , "duration " , "millisecond " , "number" , "percentage" ] ,
533
+ argument_types = { "duration " , "number " , "percentage " , * SIZE_TYPE , * DURATION_TYPE } ,
529
534
default_arg = "span.duration" ,
530
535
)
531
536
],
@@ -537,7 +542,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
537
542
default_search_type = "integer" ,
538
543
arguments = [
539
544
ArgumentDefinition (
540
- argument_types = [ "byte " , "duration " , "millisecond" , "number" ] ,
545
+ argument_types = { "duration " , "number " , * SIZE_TYPE , * DURATION_TYPE } ,
541
546
default_arg = "span.duration" ,
542
547
)
543
548
],
@@ -548,7 +553,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
548
553
default_search_type = "integer" ,
549
554
arguments = [
550
555
ArgumentDefinition (
551
- argument_types = [ "byte " , "duration " , "millisecond" , "number" ] ,
556
+ argument_types = { "duration " , "number " , * SIZE_TYPE , * DURATION_TYPE } ,
552
557
default_arg = "span.duration" ,
553
558
)
554
559
],
@@ -559,7 +564,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
559
564
default_search_type = "duration" ,
560
565
arguments = [
561
566
ArgumentDefinition (
562
- argument_types = [ "byte " , "duration " , "millisecond" , "number" ] ,
567
+ argument_types = { "duration " , "number " , * SIZE_TYPE , * DURATION_TYPE } ,
563
568
default_arg = "span.duration" ,
564
569
)
565
570
],
@@ -569,7 +574,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
569
574
default_search_type = "duration" ,
570
575
arguments = [
571
576
ArgumentDefinition (
572
- argument_types = [ "byte " , "duration " , "millisecond" , "number" ] ,
577
+ argument_types = { "duration " , "number " , * SIZE_TYPE , * DURATION_TYPE } ,
573
578
default_arg = "span.duration" ,
574
579
)
575
580
],
@@ -580,7 +585,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
580
585
default_search_type = "duration" ,
581
586
arguments = [
582
587
ArgumentDefinition (
583
- argument_types = [ "byte " , "duration " , "millisecond" , "number" ] ,
588
+ argument_types = { "duration " , "number " , * SIZE_TYPE , * DURATION_TYPE } ,
584
589
default_arg = "span.duration" ,
585
590
)
586
591
],
@@ -590,7 +595,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
590
595
default_search_type = "duration" ,
591
596
arguments = [
592
597
ArgumentDefinition (
593
- argument_types = [ "byte " , "duration " , "millisecond" , "number" ] ,
598
+ argument_types = { "duration " , "number " , * SIZE_TYPE , * DURATION_TYPE } ,
594
599
default_arg = "span.duration" ,
595
600
)
596
601
],
@@ -600,7 +605,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
600
605
default_search_type = "duration" ,
601
606
arguments = [
602
607
ArgumentDefinition (
603
- argument_types = [ "byte " , "duration " , "millisecond" , "number" ] ,
608
+ argument_types = { "duration " , "number " , * SIZE_TYPE , * DURATION_TYPE } ,
604
609
default_arg = "span.duration" ,
605
610
)
606
611
],
@@ -610,7 +615,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
610
615
default_search_type = "duration" ,
611
616
arguments = [
612
617
ArgumentDefinition (
613
- argument_types = [ "byte " , "duration " , "millisecond" , "number" ] ,
618
+ argument_types = { "duration " , "number " , * SIZE_TYPE , * DURATION_TYPE } ,
614
619
default_arg = "span.duration" ,
615
620
)
616
621
],
@@ -620,7 +625,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
620
625
default_search_type = "duration" ,
621
626
arguments = [
622
627
ArgumentDefinition (
623
- argument_types = [ "byte " , "duration " , "millisecond" , "number" ] ,
628
+ argument_types = { "duration " , "number " , * SIZE_TYPE , * DURATION_TYPE } ,
624
629
default_arg = "span.duration" ,
625
630
)
626
631
],
@@ -630,7 +635,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
630
635
default_search_type = "duration" ,
631
636
arguments = [
632
637
ArgumentDefinition (
633
- argument_types = [ "byte " , "duration " , "millisecond " , "number" , "percentage" ] ,
638
+ argument_types = { "duration " , "number " , "percentage " , * SIZE_TYPE , * DURATION_TYPE } ,
634
639
default_arg = "span.duration" ,
635
640
)
636
641
],
@@ -640,7 +645,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
640
645
default_search_type = "duration" ,
641
646
arguments = [
642
647
ArgumentDefinition (
643
- argument_types = [ "byte " , "duration " , "millisecond " , "number" , "percentage" ] ,
648
+ argument_types = { "duration " , "number " , "percentage " , * SIZE_TYPE , * DURATION_TYPE } ,
644
649
default_arg = "span.duration" ,
645
650
)
646
651
],
@@ -650,7 +655,7 @@ def module_context_constructor(params: SnubaParams) -> VirtualColumnContext:
650
655
default_search_type = "number" ,
651
656
arguments = [
652
657
ArgumentDefinition (
653
- argument_types = [ "string" ] ,
658
+ argument_types = { "string" } ,
654
659
)
655
660
],
656
661
),
0 commit comments