这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Conversation

@kylebrandt
Copy link
Member

No description provided.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these variable names are not descriptive enough to indicate what is going on here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i,ts,t,v -> total,lastTimestamp, time, value

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oldTs and ts? i to total?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

type tsIntegrator struct{
   data map[string]struct{
      total floats64
      lastTime
   }
   sync.Mutex
}

?

then you can do cpuIntegrator.Add(key, now, val) and cpuIntegrator.Total(key). Hide all of the mutexing and map stuff inside the integrator.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking there might be use cases where you don't want to use it in
the map, so this would make it more reusable

On Thu, Dec 3, 2015 at 10:23 AM, Craig Peterson notifications@github.com
wrote:

In cmd/scollector/collectors/collectors.go
#1494 (comment):

@@ -325,3 +325,17 @@ func skipMetric(index string) bool {
}
return true
}
+
+type tsIntegrator func(int64, float64) float64
+
+func getTsIntegrator() tsIntegrator {

  • var i float64

How about

type tsIntegrator struct{
data map[string]struct{
total floats64
lastTime
}
sync.Mutex
}

?

then you can do cpuIntegrator.Add(key, now, val) and
cpuIntegrator.Total(key). Hide all of the mutexing and map stuff inside
the integrator.


Reply to this email directly or view it on GitHub
https://github.com/bosun-monitor/bosun/pull/1494/files#r46564464.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you make the integrator here and pass it into c_cisco_cpu, you may not need the map or mutex at all.

@kylebrandt kylebrandt force-pushed the intCpu branch 2 times, most recently from f98348d to 5da18a0 Compare December 3, 2015 15:47
@kylebrandt kylebrandt merged commit f4d9667 into master Dec 3, 2015
@gbrayut gbrayut deleted the intCpu branch December 30, 2015 01:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants