Skip to content

Commit 5f83cd9

Browse files
aryans1204leokondrashov
authored andcommitted
Moved Metrics scraper to metric pkg
Signed-off-by: aryans1204 <arshar1204@gmail.com>
1 parent 0adb44c commit 5f83cd9

File tree

6 files changed

+111
-10
lines changed

6 files changed

+111
-10
lines changed

.github/workflows/unit-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ jobs:
7171
run: pip install -r ./requirements.txt
7272

7373
- name: Run loader tests
74-
run: go test -v -cover -race ./pkg/${{ matrix.module }}
74+
run: go test -v -cover -race -timeout 720s ./pkg/${{ matrix.module }}

pkg/common/trace_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ type Function struct {
116116
YAMLPath string
117117
PredeploymentPath []string
118118
Specification *FunctionSpecification
119+
Invoker Invoker
119120

120121
// used only for dirigent workflows
121122
WorkflowMetadata *WorkflowMetadata
122-
Invoker Invoker
123123
}
124124

125125
type Node struct {

pkg/driver/trace_driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ func (d *Driver) RunExperiment() {
504504

505505
go failure.ScheduleFailure(d.Configuration.LoaderConfiguration.Platform, d.Configuration.FailureConfiguration)
506506

507-
//Generate clients
507+
// Generate clients
508508
d.generateInvokers()
509509
// Generate load
510510
d.internalRun()

pkg/driver/trace_driver_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,35 @@ func TestDriverCompletely(t *testing.T) {
535535
withWarmup: true,
536536
expectedInvocations: 10,
537537
},
538+
{
539+
testName: "without_warmup_second_granularity",
540+
experimentDurationMin: 1,
541+
invocationStats: []int{
542+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
543+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
544+
},
545+
traceGranularity: common.SecondGranularity,
546+
expectedInvocations: 60,
547+
},
548+
{
549+
testName: "with_warmup_second_granularity",
550+
experimentDurationMin: 2,
551+
invocationStats: []int{
552+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
553+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
554+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
555+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
556+
},
557+
traceGranularity: common.SecondGranularity,
558+
withWarmup: true,
559+
expectedInvocations: 120,
560+
},
561+
{
562+
testName: "without_warmup_sleep_1min_then_invoke",
563+
experimentDurationMin: 2,
564+
invocationStats: []int{0, 5},
565+
expectedInvocations: 5,
566+
},
538567
}
539568

540569
for _, test := range tests {

pkg/metric/cluster_metrics.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package metric
2+
3+
type DeploymentScale struct {
4+
Timestamp int64 `csv:"timestamp" json:"timestamp"`
5+
Function string `csv:"function" json:"function"`
6+
DesiredPods int `csv:"desired_pods" json:"desired_pods"`
7+
RunningPods int `csv:"running_pods" json:"running_pods"`
8+
UnreadyPods int `csv:"unready_pods" json:"unready_pods"`
9+
PendingPods int `csv:"pending_pods" json:"pending_pods"`
10+
TerminatingPods int `csv:"terminating_pods" json:"terminating_pods"`
11+
ActivatorQueue float64 `csv:"activator_queue" json:"activator_queue"`
12+
}
13+
14+
type KnStats struct {
15+
Timestamp int64 `csv:"timestamp" json:"timestamp"`
16+
17+
DesiredPods int `csv:"desired_pods" json:"desired_pods"`
18+
UnreadyPods int `csv:"unready_pods" json:"unready_pods"`
19+
PendingPods int `csv:"pending_pods" json:"pending_pods"`
20+
RequestedPods int `csv:"requested_pods" json:"requested_pods"`
21+
RunningPods int `csv:"running_pods" json:"running_pods"`
22+
23+
ActivatorQueue float64 `csv:"activator_queue" json:"activator_queue"`
24+
ActivatorRequestCount int `csv:"activator_request_count" json:"activator_request_count"`
25+
AutoscalerStableQueue float64 `csv:"autoscaler_stable_queue" json:"autoscaler_stable_queue"`
26+
AutoscalerPanicQueue float64 `csv:"autoscaler_panic_queue" json:"autoscaler_panic_queue"`
27+
28+
SchedulingP95 float64 `csv:"scheduling_p95" json:"scheduling_p95"`
29+
SchedulingP50 float64 `csv:"scheduling_p50" json:"scheduling_p50"`
30+
E2ePlacementP95 float64 `csv:"e2e_placement_p95" json:"e2e_placement_p95"`
31+
E2ePlacementP50 float64 `csv:"e2e_placement_p50" json:"e2e_placement_p50"`
32+
}
33+
34+
type ClusterUsage struct {
35+
Timestamp int64 `csv:"timestamp" json:"timestamp"`
36+
MasterCpuPct float64 `csv:"master_cpu_pct" json:"master_cpu_pct"`
37+
MasterCpuReq float64 `csv:"master_cpu_req" json:"master_cpu_req"`
38+
MasterCpuLim float64 `csv:"master_cpu_lim" json:"master_cpu_lim"`
39+
MasterMemoryPct float64 `csv:"master_mem_pct" json:"master_mem_pct"`
40+
MasterMemoryReq float64 `csv:"master_mem_req" json:"master_mem_req"`
41+
MasterMemoryLim float64 `csv:"master_mem_lim" json:"master_mem_lim"`
42+
MasterPods int `csv:"master_pods" json:"master_pods"`
43+
Cpu []string `csv:"cpu" json:"cpu"`
44+
CpuReq []float64 `csv:"cpu_req" json:"cpu_req"`
45+
CpuLim []float64 `csv:"cpu_lim" json:"cpu_lim"`
46+
CpuPctAvg float64 `csv:"cpu_pct_avg" json:"cpu_pct_avg"`
47+
CpuPctMax float64 `csv:"cpu_pct_max" json:"cpu_pct_max"`
48+
CpuPctActiveAvg float64 `csv:"cpu_pct_active_avg" json:"cpu_pct_active_avg"`
49+
Memory []string `csv:"memory" json:"memory"`
50+
MemoryReq []float64 `csv:"memory_req" json:"memory_req"`
51+
MemoryLim []float64 `csv:"memory_lim" json:"memory_lim"`
52+
MemoryPctAvg float64 `csv:"memory_pct" json:"memory_pct"`
53+
PodCpu []string `csv:"pod_cpu" json:"pod_cpu"`
54+
PodMemory []string `csv:"pod_memory" json:"pod_mem"`
55+
Pods []int `csv:"pods" json:"pods"`
56+
LoaderCpu float64 `csv:"loader_cpu" json:"loader_cpu"`
57+
LoaderMem float64 `csv:"loader_mem" json:"loader_mem"`
58+
}
59+
60+
type AdfResult struct {
61+
TestStats float64 `json:"statistic"`
62+
Pvalue float64 `json:"pvalue"`
63+
Lag int `json:"usedlag"`
64+
NumObs int `json:"nobs"`
65+
CriticalVals TValues `json:"critical_vals"`
66+
IcBest float64 `json:"icbest"`
67+
}
68+
69+
type TValues struct {
70+
Pct1 float64 `json:"1%"`
71+
Pct5 float64 `json:"5%"`
72+
Pct10 float64 `json:"10%"`
73+
}

pkg/metric/knative_metrics.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,16 @@ import (
2929
"os/exec"
3030

3131
log "github.com/sirupsen/logrus"
32-
"github.com/vhive-serverless/loader/pkg/common"
3332
)
3433

35-
func ScrapeDeploymentScales() []common.DeploymentScale {
34+
func ScrapeDeploymentScales() []DeploymentScale {
3635
cmd := exec.Command("python3", "pkg/metric/scrape_scales.py")
3736
out, err := cmd.CombinedOutput()
3837
if err != nil {
3938
log.Warn("Fail to scrape deployment scales: ", err)
4039
}
4140

42-
var results []common.DeploymentScale
41+
var results []DeploymentScale
4342
err = json.Unmarshal(out, &results)
4443
if err != nil {
4544
log.Warn("Fail to parse deployment scales: ", string(out[:]), err)
@@ -48,7 +47,7 @@ func ScrapeDeploymentScales() []common.DeploymentScale {
4847
return results
4948
}
5049

51-
func ScrapeKnStats() common.KnStats {
50+
func ScrapeKnStats() KnStats {
5251
cmd := exec.Command(
5352
"python3",
5453
"pkg/metric/scrape_kn.py",
@@ -58,7 +57,7 @@ func ScrapeKnStats() common.KnStats {
5857
log.Warn("Fail to scrape Knative: ", err)
5958
}
6059

61-
var result common.KnStats
60+
var result KnStats
6261
err = json.Unmarshal(out, &result)
6362
if err != nil {
6463
log.Warn("Fail to parse Knative: ", string(out[:]), err)
@@ -67,14 +66,14 @@ func ScrapeKnStats() common.KnStats {
6766
return result
6867
}
6968

70-
func ScrapeClusterUsage() common.ClusterUsage {
69+
func ScrapeClusterUsage() ClusterUsage {
7170
cmd := exec.Command("python3", "pkg/metric/scrape_infra.py")
7271
out, err := cmd.CombinedOutput()
7372
if err != nil {
7473
log.Warn("Fail to scrape cluster usage: ", err)
7574
}
7675

77-
var result common.ClusterUsage
76+
var result ClusterUsage
7877
err = json.Unmarshal(out, &result)
7978
if err != nil {
8079
log.Warn("Fail to parse cluster usage: ", string(out[:]), err)

0 commit comments

Comments
 (0)