-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
metrics: add support for PCP #354
Comments
Neat! I'll take a look in the next few days.
This is also true of Prometheus! Just make sure the With invocations are storing the label-values in a way that's retrievable by the observe method, and have the observe method pass the values to the underlying implementation. You can be permissive, and say that required unspecified dimensions get an "unknown" value, and non-required erroneously-specified dimensions are ignored. Or, you can be super strict, and panic on either condition. Either one is fine from my POV. |
Global state is always a bad idea, and in Go kit it's strictly forbidden. So you'll need to find a way to arrange things so that you don't have a package global registry and client. I haven't dug too deeply, but one way might be by encapsulating them in a pcp.Reporter struct, and have the NewMetric constructors be methods on that type. |
@peterbourgon I have updated my fork. Now, metrics are created using a Regarding My approach to this was that all the labels passed in the parameters would first be serialized using some mechanism to one single string. Then that serialized string will be used as the key, with the value being the actual value for those keys. I thought of doing this using the current usage of an instance metric, say a c, err := speed.NewPCPCounterVector(
map[string]uint64{
"instance1": 0,
"instance2": 1,
}, "another.simple.counter"
)
i1val := c.Val("instance1") // gets value for instance1 here a From what I understand about prometheus, labels are external properties for metrics and not a part of metrics values themselves. PCP metrics have only 2 external properties, the 2 optional description strings. Also, another thing to note is that the data type for all instances in an InstanceMetric is fixed, and can only be selected from a fixed subset (https://github.com/performancecopilot/speed/blob/master/metrics.go#L17-L26), so we can't add labels as instance values for an instance metric Another solution I can think of is passing all "label sets" beforehand, so the possible sets for stringsvc2 will be
and using serialization, but that seems infeasible for large applications |
Great! The design of the new package looks reasonable from a high level. But—I'd like to have a conversation with you about the design of PCP before I get into more details of what Go kit integration would look like. Something lower-latency than GitHub issues would be ideal: are you on the Gophers Slack? We can also have it here if that's easier for you. |
@peterbourgon I have joined the slack channel To give a general overview of the design, PCP is a low level system monitoring toolkit, the individual systems are monitored through system specific agents, which are programmed in a manner in which they know what to monitor for useful information. Metrics can be of 2 types, singleton and instance. A singleton metric is just a single value of a particular type. with particular semantics and unit. An instance metric has specific instances with string names, each having a particular value, but all instances should have the same type, semantics and unit. The metric names are of form The most commonly used and installed agent by default is the linux agent, exposing a bunch of filesystem, network and kernel related metrics like To see all agents that ship with PCP, see https://github.com/performancecopilot/pcp/tree/master/src/pmdas PCP supports instrumentation through an especially configured agent called MMV, which monitors for memory mapped files in The PCP daemon binds to port There are a couple of books, a users and administrators guide to get familiar with the client tools, and a programmers guide to understand the agent and instrumentation API and possibly write your own agents. Pinging @natoscott and @lberk in case I missed something |
Thanks to @suyash and his patient explanations on Slack, I have a pretty good understanding of how PCP works. Let me summarize, primarily for my own retrospective edification :) Instrumented applications import the speed client, which typically opens a memory-mapped file that's shared by the PCP daemon. Metric observations are simple writes to that file, which are picked up by the daemon. The data model has two concepts. A singleton metric, which is a single set of label values and a concomitant value; most analagous to a Graphite dotted.notation.metric and value. And an instance metric, which is the same but parameterized in one dimension; for example, http.request.[get_foo,post_foo].count would be an instance metric with get_foo and post_foo instances. So I think the closest thing to this would be package metrics/graphite. There are some problematic aspects to the speed client package re: global state and init functions, but since it's sequestered in metrics/pcp those problems are effectively opt-in and I'm fine with it. So I'd be happy to accept a PR along those lines. I hope that's enough to go on; please feel free to ping me with any further questions! :) |
@peterbourgon just a couple of things
Once you are happy with the above points I would be happy to send a PR :) |
Ah, OK! I'll update my comment above. That means you need only the one constructor.
Here's what I mean:
In effect, any global variable or any use of |
closing this as #363 was merged |
I was a part of this year's Google Summer of Code with the Performance Co-Pilot organization. PCP, although principally built for reporting low level application specific metrics, also supports instrumentation through a specially configured agent, mmv. My project was to build an instrumentation client library for that API, and it is currently at performancecopilot/speed.
One of the goals of the project was to demonstrate real world usage of the implemented client library, and I am trying to fulfill that requirement by implementing PCP support for this library. My fork contains a pcp subpackage inside metrics at https://github.com/suyash/kit.
I have also modified 3 examples to report metrics to PCP instead of prometheus and they are implemented in a separate tree. For stringsvc2, I have added some screenshots.
Currently I cannot support
With
labels for metrics, because while we do have a similar concept (https://github.com/performancecopilot/speed#instancemetric), it requires all labels to be specified upfront, and reinitializing a new metric each time seemed overkill. Instead I am trying to explore supporting mutating instancesAnyways, in line with the contributing guidelines, I am opening this issue for discussion
The text was updated successfully, but these errors were encountered: