@@ -12,6 +12,7 @@ import (
1212
1313type RecordingConfigTable struct {
1414 table table.Model
15+ samplingMode string
1516 samplingRate string
1617 exportSpans bool
1718 enableEnvVarRecording bool
@@ -20,7 +21,7 @@ type RecordingConfigTable struct {
2021 cursor int
2122}
2223
23- func NewRecordingConfigTable (samplingRate string , exportSpans , enableEnvVarRecording bool ) * RecordingConfigTable {
24+ func NewRecordingConfigTable (samplingMode , samplingRate string , exportSpans , enableEnvVarRecording bool ) * RecordingConfigTable {
2425 columns := []table.Column {
2526 {Title : "Setting" , Width : 35 },
2627 {Title : "Value" , Width : 25 },
@@ -48,8 +49,12 @@ func NewRecordingConfigTable(samplingRate string, exportSpans, enableEnvVarRecor
4849
4950 t .SetStyles (s )
5051
52+ if samplingMode == "" {
53+ samplingMode = "adaptive"
54+ }
5155 rct := & RecordingConfigTable {
5256 table : t ,
57+ samplingMode : samplingMode ,
5358 samplingRate : samplingRate ,
5459 exportSpans : true , // Required for cloud onboarding
5560 enableEnvVarRecording : enableEnvVarRecording ,
@@ -64,7 +69,7 @@ func NewRecordingConfigTable(samplingRate string, exportSpans, enableEnvVarRecor
6469func (rct * RecordingConfigTable ) updateRows () {
6570 rate , _ := strconv .ParseFloat (rct .samplingRate , 64 )
6671 rateDisplay := fmt .Sprintf ("%.2f (%.0f%%)" , rate , rate * 100 )
67- if rct .EditMode && rct .cursor == 0 {
72+ if rct .EditMode && rct .cursor == 1 {
6873 rateDisplay = "→ " + rct .samplingRate + "_"
6974 }
7075
@@ -76,7 +81,8 @@ func (rct *RecordingConfigTable) updateRows() {
7681 }
7782
7883 rows := []table.Row {
79- {"Sampling Rate" , rateDisplay },
84+ {"Sampling Mode" , rct .samplingMode },
85+ {"Base Sampling Rate" , rateDisplay },
8086 {"Export Spans" , formatBool (rct .exportSpans )},
8187 {"Record Environment Variables" , formatBool (rct .enableEnvVarRecording )},
8288 }
@@ -92,7 +98,7 @@ func (rct *RecordingConfigTable) Update(msg tea.Msg) (*RecordingConfigTable, tea
9298 switch msg := msg .(type ) {
9399 case tea.KeyMsg :
94100 // If in edit mode (typing sampling rate)
95- if rct .EditMode && rct .cursor == 0 {
101+ if rct .EditMode && rct .cursor == 1 {
96102 switch msg .String () {
97103 case "tab" , "esc" :
98104 rct .EditMode = false
@@ -127,7 +133,7 @@ func (rct *RecordingConfigTable) Update(msg tea.Msg) (*RecordingConfigTable, tea
127133 return rct , nil
128134
129135 case "down" , "j" :
130- if rct .cursor < 2 {
136+ if rct .cursor < 3 {
131137 rct .cursor ++
132138 rct .table .MoveDown (1 )
133139 }
@@ -136,18 +142,24 @@ func (rct *RecordingConfigTable) Update(msg tea.Msg) (*RecordingConfigTable, tea
136142
137143 case "tab" , " " :
138144 switch rct .cursor {
145+ case 0 :
146+ if rct .samplingMode == "adaptive" {
147+ rct .samplingMode = "fixed"
148+ } else {
149+ rct .samplingMode = "adaptive"
150+ }
139151 case 1 :
140- rct .exportSpans = ! rct . exportSpans
152+ rct .EditMode = true
141153 case 2 :
154+ rct .exportSpans = ! rct .exportSpans
155+ case 3 :
142156 rct .enableEnvVarRecording = ! rct .enableEnvVarRecording
143- case 0 :
144- rct .EditMode = true
145157 }
146158 rct .updateRows ()
147159 return rct , nil
148160
149161 case "e" :
150- if rct .cursor == 0 {
162+ if rct .cursor == 1 {
151163 rct .EditMode = true
152164 rct .updateRows ()
153165 return rct , nil
@@ -169,9 +181,9 @@ func (rct *RecordingConfigTable) View() string {
169181 )
170182}
171183
172- func (rct * RecordingConfigTable ) GetValues () (samplingRate float64 , exportSpans , enableEnvVarRecording bool ) {
184+ func (rct * RecordingConfigTable ) GetValues () (samplingMode string , samplingRate float64 , exportSpans , enableEnvVarRecording bool ) {
173185 rate , _ := strconv .ParseFloat (rct .samplingRate , 64 )
174- return rate , rct .exportSpans , rct .enableEnvVarRecording
186+ return rct . samplingMode , rate , rct .exportSpans , rct .enableEnvVarRecording
175187}
176188
177189func (rct * RecordingConfigTable ) SetFocused (focused bool ) {
0 commit comments