From 05a1f77787abe0d588df233257014251a96f6774 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Fri, 31 Aug 2018 20:22:53 -0400 Subject: [PATCH 1/4] Revert "Since it seems that the gcloud source repo mirror does include tags after all, tweak the cloudbuild script to remove the explicit tagging." This reverts commit da1de8152f3ecf8d5a356f12fd59d2c0e153dfed. --- cloudbuild.release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudbuild.release.yaml b/cloudbuild.release.yaml index e7fb392..f1b200e 100644 --- a/cloudbuild.release.yaml +++ b/cloudbuild.release.yaml @@ -34,7 +34,7 @@ steps: entrypoint: /bin/sh dir: gopath/src/github.com env: ['GOPATH=/workspace/gopath'] - args: ['-c', 'cd ncabatoff/process-exporter && git tag && /goreleaser' ] + args: ['-c', 'cd ncabatoff/process-exporter && git tag $TAG_NAME && /goreleaser' ] secretEnv: ['GITHUB_TOKEN'] secrets: From d1c35c3e4243c214ea687a4f3ad71825a48e5149 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Fri, 31 Aug 2018 20:24:23 -0400 Subject: [PATCH 2/4] Fix #58: correctly report the aggregate context switches for all the threads in the process. --- proc/tracker.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/proc/tracker.go b/proc/tracker.go index 52bf1c0..aab2a37 100644 --- a/proc/tracker.go +++ b/proc/tracker.go @@ -221,12 +221,22 @@ func (t *Tracker) handleProc(proc Proc, updateTime time.Time) (*IDInfo, CollectE } return nil, cerrs } - cerrs.Partial += softerrors var threads []Thread - if t.trackThreads { - threads, _ = proc.GetThreads() + threads, err = proc.GetThreads() + if err != nil { + softerrors |= 1 } + cerrs.Partial += softerrors + + if len(threads) > 0 { + metrics.Counts.CtxSwitchNonvoluntary, metrics.Counts.CtxSwitchVoluntary = 0, 0 + for _, thread := range threads { + metrics.Counts.CtxSwitchNonvoluntary += thread.Counts.CtxSwitchNonvoluntary + metrics.Counts.CtxSwitchVoluntary += thread.Counts.CtxSwitchVoluntary + } + } + var newProc *IDInfo if known { last.update(metrics, updateTime, &cerrs, threads) From 1b02466113ce919b15ef310b255283fec8d0e85a Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Sat, 1 Sep 2018 10:02:19 -0400 Subject: [PATCH 3/4] Create failing test. --- proc/read_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/proc/read_test.go b/proc/read_test.go index b2bb9ed..2470510 100644 --- a/proc/read_test.go +++ b/proc/read_test.go @@ -220,3 +220,7 @@ func TestIterator(t *testing.T) { t.Errorf("procs differs: (-got +want)\n%s", diff) } } + +func TestFail(t *testing.T) { + t.Fail() +} From c752cac19ec2269f1eb6282674556b80be594865 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Sat, 1 Sep 2018 10:32:34 -0400 Subject: [PATCH 4/4] Try again. --- proc/read_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/proc/read_test.go b/proc/read_test.go index 2470510..b71903d 100644 --- a/proc/read_test.go +++ b/proc/read_test.go @@ -221,6 +221,7 @@ func TestIterator(t *testing.T) { } } +// Fail, to test checks API func TestFail(t *testing.T) { t.Fail() }