Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 30fb255

Browse files
authored
A/B testing - extract and store dashboard id (#914)
1 parent 09d6740 commit 30fb255

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

quesma/ab_testing/collector/collector.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ type EnrichedResults struct {
3434
QuesmaVersion string `json:"quesma_version"`
3535
QuesmaBuildHash string `json:"quesma_hash"`
3636
Errors []string `json:"errors,omitempty"`
37+
38+
KibanaDashboardId string `json:"kibana_dashboard_id,omitempty"`
3739
}
3840

3941
type pipelineProcessor interface {
@@ -78,6 +80,7 @@ func NewCollector(ctx context.Context, healthQueue chan<- ab_testing.HealthMessa
7880
cancelFunc: cancel,
7981
pipeline: []pipelineProcessor{
8082
&probabilisticSampler{ratio: 1},
83+
&extractKibanaIds{},
8184
&unifySyncAsyncResponse{},
8285
&diffTransformer{},
8386
//&ppPrintFanout{},

quesma/ab_testing/collector/processors.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"fmt"
88
"quesma/quesma/types"
9+
"regexp"
910
)
1011

1112
// unifySyncAsyncResponse is a processor that processes that removes async "wrapper" from the response
@@ -58,3 +59,34 @@ func (t *unifySyncAsyncResponse) process(in EnrichedResults) (out EnrichedResult
5859

5960
return in, false, nil
6061
}
62+
63+
type extractKibanaIds struct {
64+
}
65+
66+
func (t *extractKibanaIds) name() string {
67+
return "extractKibanaIds"
68+
}
69+
70+
var opaqueIdKibanaDashboardIdRegexp = regexp.MustCompile(`dashboards:([0-9a-f-]+)`)
71+
72+
func (t *extractKibanaIds) process(in EnrichedResults) (out EnrichedResults, drop bool, err error) {
73+
74+
opaqueId := in.OpaqueID
75+
76+
// TODO maybe we should extract panel id as well
77+
78+
if opaqueId == "" {
79+
in.KibanaDashboardId = "n/a"
80+
return in, false, nil
81+
}
82+
83+
matches := opaqueIdKibanaDashboardIdRegexp.FindStringSubmatch(opaqueId)
84+
85+
if len(matches) < 2 {
86+
in.KibanaDashboardId = "n/a"
87+
return in, false, nil
88+
}
89+
90+
in.KibanaDashboardId = matches[1]
91+
return in, false, nil
92+
}

0 commit comments

Comments
 (0)