Skip to content

Commit

Permalink
update to new tsprofiler with periods
Browse files Browse the repository at this point in the history
  • Loading branch information
cha87de committed Feb 20, 2019
1 parent 7d1ee0c commit f853bac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions profiler/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"fmt"

"github.com/cha87de/kvmtop/printers"
"github.com/cha87de/tsprofiler/spec"
"github.com/cha87de/tsprofiler/models"
)

type profilerOutput struct {
Profile spec.TSProfile `json:"profile"`
Profile models.TSProfile `json:"profile"`
}

func profileOutput(data spec.TSProfile) {
func profileOutput(data models.TSProfile) {
// text := printTransitMatrix(data.TXMatrix)
profilerOutput := profilerOutput{
Profile: data,
Expand Down
26 changes: 14 additions & 12 deletions profiler/profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"sync"
"time"

"github.com/cha87de/tsprofiler/impl"
"github.com/cha87de/tsprofiler/spec"
tsprofilerApi "github.com/cha87de/tsprofiler/api"
tsprofilerModels "github.com/cha87de/tsprofiler/models"
tsprofiler "github.com/cha87de/tsprofiler/profiler"

"github.com/cha87de/kvmtop/config"
"github.com/cha87de/kvmtop/models"
Expand Down Expand Up @@ -48,24 +49,25 @@ func pickup() {

// get or create profiler
profilerRaw, found := domainProfiler.Load(uuid)
var profiler spec.TSProfiler
var profiler tsprofilerApi.TSProfiler
if found {
profiler = profilerRaw.(spec.TSProfiler)
profiler = profilerRaw.(tsprofilerApi.TSProfiler)
} else {
profiler = impl.NewProfiler(spec.Settings{
profiler = tsprofiler.NewProfiler(tsprofilerModels.Settings{
Name: uuid,
BufferSize: config.Options.Profiler.BufferSize,
States: config.Options.Profiler.States,
History: config.Options.Profiler.History,
BufferSize: config.Options.Profiler.BufferSize, // default: 10, with default 1s frequency => every 10s
States: config.Options.Profiler.States, // default: 4
History: config.Options.Profiler.History, // default: 1
FilterStdDevs: config.Options.Profiler.FilterStdDevs,
FixBound: config.Options.Profiler.FixedBound,
OutputFreq: config.Options.Profiler.OutputFreq,
OutputCallback: profileOutput,
PeriodSize: []int{6, 60}, // 1min, 1h
})
}

// pick up collector measurement
metrics := make([]spec.TSDataMetric, 0)
metrics := make([]tsprofilerModels.TSInputMetric, 0)
models.Collection.Collectors.Map.Range(func(nameRaw interface{}, collectorRaw interface{}) bool {
name := nameRaw.(string)
var util, min, max int
Expand All @@ -77,7 +79,7 @@ func pickup() {
util, min, max = pickupNet(domain)
}

metrics = append(metrics, spec.TSDataMetric{
metrics = append(metrics, tsprofilerModels.TSInputMetric{
Name: name,
Value: float64(util),
FixedMin: float64(min),
Expand All @@ -87,7 +89,7 @@ func pickup() {
})

// send measurement to profiler
tsdata := spec.TSData{
tsdata := tsprofilerModels.TSInput{
Metrics: metrics,
}
profiler.Put(tsdata)
Expand All @@ -105,7 +107,7 @@ func pickup() {
for _, uuid := range domIDs {
profilerRaw, found := domainProfiler.Load(uuid)
if found {
profiler := profilerRaw.(spec.TSProfiler)
profiler := profilerRaw.(tsprofilerApi.TSProfiler)
profiler.Terminate()
}
domainProfiler.Delete(uuid)
Expand Down

0 comments on commit f853bac

Please sign in to comment.