Skip to content

Commit

Permalink
A/B testing - extract and store dashboard id (#914)
Browse files Browse the repository at this point in the history
  • Loading branch information
nablaone authored Oct 24, 2024
1 parent 09d6740 commit 30fb255
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions quesma/ab_testing/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type EnrichedResults struct {
QuesmaVersion string `json:"quesma_version"`
QuesmaBuildHash string `json:"quesma_hash"`
Errors []string `json:"errors,omitempty"`

KibanaDashboardId string `json:"kibana_dashboard_id,omitempty"`
}

type pipelineProcessor interface {
Expand Down Expand Up @@ -78,6 +80,7 @@ func NewCollector(ctx context.Context, healthQueue chan<- ab_testing.HealthMessa
cancelFunc: cancel,
pipeline: []pipelineProcessor{
&probabilisticSampler{ratio: 1},
&extractKibanaIds{},
&unifySyncAsyncResponse{},
&diffTransformer{},
//&ppPrintFanout{},
Expand Down
32 changes: 32 additions & 0 deletions quesma/ab_testing/collector/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"quesma/quesma/types"
"regexp"
)

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

return in, false, nil
}

type extractKibanaIds struct {
}

func (t *extractKibanaIds) name() string {
return "extractKibanaIds"
}

var opaqueIdKibanaDashboardIdRegexp = regexp.MustCompile(`dashboards:([0-9a-f-]+)`)

func (t *extractKibanaIds) process(in EnrichedResults) (out EnrichedResults, drop bool, err error) {

opaqueId := in.OpaqueID

// TODO maybe we should extract panel id as well

if opaqueId == "" {
in.KibanaDashboardId = "n/a"
return in, false, nil
}

matches := opaqueIdKibanaDashboardIdRegexp.FindStringSubmatch(opaqueId)

if len(matches) < 2 {
in.KibanaDashboardId = "n/a"
return in, false, nil
}

in.KibanaDashboardId = matches[1]
return in, false, nil
}

0 comments on commit 30fb255

Please sign in to comment.