@@ -28,7 +28,7 @@ import { useDebouncedCallback } from '@mantine/hooks';
28
28
import { notifications } from '@mantine/notifications' ;
29
29
30
30
import { SourceSelectControlled } from '@/components/SourceSelect' ;
31
- import { IS_SESSIONS_ENABLED } from '@/config' ;
31
+ import { IS_METRICS_ENABLED , IS_SESSIONS_ENABLED } from '@/config' ;
32
32
import { useConnections } from '@/connection' ;
33
33
import {
34
34
inferTableSourceConfig ,
@@ -537,6 +537,100 @@ export function TraceTableModelForm({
537
537
) ;
538
538
}
539
539
540
+ export function SessionTableModelForm ( {
541
+ control,
542
+ watch,
543
+ setValue,
544
+ } : {
545
+ control : Control < TSource > ;
546
+ watch : UseFormWatch < TSource > ;
547
+ setValue : UseFormSetValue < TSource > ;
548
+ } ) {
549
+ const databaseName = watch ( `from.databaseName` , DEFAULT_DATABASE ) ;
550
+ const tableName = watch ( `from.tableName` ) ;
551
+ const connectionId = watch ( `connection` ) ;
552
+
553
+ const [ showOptionalFields , setShowOptionalFields ] = useState ( false ) ;
554
+
555
+ return (
556
+ < >
557
+ < Stack gap = "sm" >
558
+ < FormRow label = { 'Server Connection' } >
559
+ < ConnectionSelectControlled control = { control } name = { `connection` } />
560
+ </ FormRow >
561
+ < FormRow label = { 'Database' } >
562
+ < DatabaseSelectControlled
563
+ control = { control }
564
+ name = { `from.databaseName` }
565
+ connectionId = { connectionId }
566
+ />
567
+ </ FormRow >
568
+ < FormRow label = { 'Table' } >
569
+ < DBTableSelectControlled
570
+ database = { databaseName }
571
+ control = { control }
572
+ name = { `from.tableName` }
573
+ connectionId = { connectionId }
574
+ rules = { { required : 'Table is required' } }
575
+ />
576
+ </ FormRow >
577
+ < FormRow
578
+ label = { 'Timestamp Column' }
579
+ helpText = "DateTime column or expression that is part of your table's primary key."
580
+ >
581
+ < SQLInlineEditorControlled
582
+ database = { databaseName }
583
+ table = { tableName }
584
+ control = { control }
585
+ name = "timestampValueExpression"
586
+ disableKeywordAutocomplete
587
+ connectionId = { connectionId }
588
+ />
589
+ </ FormRow >
590
+ < FormRow label = { 'Log Attributes Expression' } >
591
+ < SQLInlineEditorControlled
592
+ database = { databaseName }
593
+ table = { tableName }
594
+ control = { control }
595
+ name = "eventAttributesExpression"
596
+ placeholder = "LogAttributes"
597
+ connectionId = { connectionId }
598
+ />
599
+ </ FormRow >
600
+ < FormRow label = { 'Resource Attributes Expression' } >
601
+ < SQLInlineEditorControlled
602
+ database = { databaseName }
603
+ table = { tableName }
604
+ control = { control }
605
+ name = "resourceAttributesExpression"
606
+ placeholder = "ResourceAttributes"
607
+ connectionId = { connectionId }
608
+ />
609
+ </ FormRow >
610
+ < FormRow
611
+ label = { 'Correlated Trace Source' }
612
+ helpText = "HyperDX Source for traces associated with sessions. Required"
613
+ >
614
+ < SourceSelectControlled control = { control } name = "traceSourceId" />
615
+ </ FormRow >
616
+ < FormRow
617
+ label = { 'Implicit Column Expression' }
618
+ helpText = "Column used for full text search if no property is specified in a Lucene-based search. Typically the message body of a log."
619
+ >
620
+ < SQLInlineEditorControlled
621
+ database = { databaseName }
622
+ table = { tableName }
623
+ control = { control }
624
+ name = "implicitColumnExpression"
625
+ placeholder = "Body"
626
+ connectionId = { connectionId }
627
+ />
628
+ </ FormRow >
629
+ </ Stack >
630
+ </ >
631
+ ) ;
632
+ }
633
+
540
634
export function MetricTableModelForm ( {
541
635
control,
542
636
watch,
@@ -746,7 +840,6 @@ function TableModelForm({
746
840
} ) {
747
841
switch ( kind ) {
748
842
case SourceKind . Log :
749
- case SourceKind . Session :
750
843
return (
751
844
< LogTableModelForm
752
845
control = { control }
@@ -762,6 +855,14 @@ function TableModelForm({
762
855
setValue = { setValue }
763
856
/>
764
857
) ;
858
+ case SourceKind . Session :
859
+ return (
860
+ < SessionTableModelForm
861
+ control = { control }
862
+ watch = { watch }
863
+ setValue = { setValue }
864
+ />
865
+ ) ;
765
866
case SourceKind . Metric :
766
867
return (
767
868
< MetricTableModelForm
@@ -974,7 +1075,9 @@ export function TableSourceForm({
974
1075
< Group >
975
1076
< Radio value = { SourceKind . Log } label = "Log" />
976
1077
< Radio value = { SourceKind . Trace } label = "Trace" />
977
- < Radio value = { SourceKind . Metric } label = "Metric" />
1078
+ { IS_METRICS_ENABLED && (
1079
+ < Radio value = { SourceKind . Metric } label = "Metric" />
1080
+ ) }
978
1081
{ IS_SESSIONS_ENABLED && (
979
1082
< Radio value = { SourceKind . Session } label = "Session" />
980
1083
) }
0 commit comments