performancecopilot / speed

A Go implementation of the PCP instrumentation API
MIT License
37 stars 6 forks source link

implement an agent in go to export metrics from the API directly #7

Open suyash opened 8 years ago

suyash commented 8 years ago

similar to parfait-agent

saurvs commented 7 years ago

I'm guessing this need cgo bindings to libpcp_pmda so we can build a daemon PMDA in Go?

suyash commented 7 years ago

No, actually parfait-agent (in the java project) is a standalone Java application that on launch with an application automatically starts exporting important stuff about the application. @natoscott would have more knowledge since he maintains the project. From what I remember correctly it makes use of the JVM instrumentation API and the premain functionality. https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/package-summary.html

natoscott commented 7 years ago

@suyash @saurvs there's two modes of operation for the Java parfait-agent:

  1. Running as a -javaagent jar (i.e. running directly inside the instrumented application)
  2. "Proxy" mode, where parfait-agent runs as a separate process to the instrumented application, and communicates to the application using JMX protocol.

Both modes use parfait-core, and parfait/dxm to generate MMV format. It is all pure Java code - no native bindings or anything like that.

saurvs commented 7 years ago

@natoscott Thanks for the clarification.

There is apparently no equivalent of -javaagent for Go, so we can't profile an unmodified Go binary. We could instead implement a PCPInstanceMetric like I mentioned in https://github.com/performancecopilot/speed/issues/42, which updates runtime metrics periodically, and which the user can start or stop anywhere in their code.

There's also https://github.com/davecheney/gmx, which is similar to Java's jmx. When it's imported into a Go program, the package automatically opens a UNIX socket that we can query for runtime metrics from a different process and write them to an MMV file.