Repository navigation
Expand file tree
/
Copy pathinterface.go
More file actions
79 lines (67 loc) · 2.86 KB
/
Copy pathinterface.go
File metadata and controls
79 lines (67 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Package storage provides the storage client for the controllers package
package storage
import "github.com/iter8-tools/iter8/base"
// SummarizedMetric is a metric summary
type SummarizedMetric struct {
Count uint64
Mean float64
StdDev float64
Min float64
Max float64
}
// MetricSummary contains metric summary for all metrics as well as cumulative metrics per user
type MetricSummary struct {
// all transactions
SummaryOverTransactions SummarizedMetric
// cumulative metrics per user
SummaryOverUsers SummarizedMetric
}
// VersionMetricSummary is a metric summary for a given app version
type VersionMetricSummary struct {
NumUsers uint64
// key = metric name; value is the metric summary
MetricSummaries map[string]MetricSummary
}
// VersionMetrics contains all the metrics over transactions and over users
// key = metric name
type VersionMetrics map[string]struct {
MetricsOverTransactions []float64
MetricsOverUsers []float64
}
// Interface enables interaction with a storage entity
// Can be mocked in unit tests with fake implementation
type Interface interface {
// GetMerics returns all metrics for an app/version
// Returned result is a nested map of the metrics data
// Example:
// {
// "my-metric": {
// "MetricsOverTransactions": [1, 1, 3, 4, 5]
// "MetricsOverUsers": [2, 7, 5]
// }
// }
//
// NOTE: for users that have not produced any metrics (for example, via lookup()), GetMetrics() will add 0s for the extra users in metricsOverUsers
// Example, given 5 total users:
//
// {
// "my-metric": {
// "MetricsOverTransactions": [1, 1, 3, 4, 5]
// "MetricsOverUsers": [2, 7, 5, 0, 0]
// }
// }
GetMetrics(applicationName string, version int, signature string) (*VersionMetrics, error)
// SetMetric records a metric value
// Called by the A/B/n SDK gRPC API implementation (SDK for application clients)
// Example key: kt-metric::my-app::0::my-signature::my-metric::my-user::my-transaction-id -> my-metric-value (get the metric value with all the provided information)
SetMetric(applicationName string, version int, signature, metric, user, transaction string, metricValue float64) error
// SetUser records the name of user
// Example key: kt-users::my-app::0::my-signature::my-user -> true
SetUser(applicationName string, version int, signature, user string) error
// GetExperimentResult returns the experiment result for a particular namespace and experiment
GetExperimentResult(namespace, experiment string) (*base.ExperimentResult, error)
// SetExperimentResult records an expeirment result
// called by the A/B/n SDK gRPC API implementation (SDK for application clients)
// Example key: kt-metric::my-app::0::my-signature::my-metric::my-user::my-transaction-id -> my-metric-value (get the metric value with all the provided information)
SetExperimentResult(namespace, experiment string, data *base.ExperimentResult) error
}