package
0.0.0-20171011010702-a7a7e747782c
Repository: https://github.com/opentracing-contrib/perfevents.git
Documentation: pkg.go.dev

# README

perfevents/go

This is the implementation of perfevents package in golang.

Standalone Installation and Usage

perfevents provides an API and a library which can be used by a go application to profile its components.

To use this package inside your go application, use :

import "github.com/opentracing-contrib/perfevents/go"

To open a list of events :

err, evs, pds := perfevents.InitOpenEventsEnableSelf("cpu-cycles,cache-misses,instructions")

This creates 3 event descriptors pds for cpu-cycles, cache-misses and instructions and enables them, so they start counting.

At any point in time, we can read the event values :

err, evs = perfevents.EventsRead(pds)

After we are done monitoring, just close out the events :

err, evs = perfevents.EventsDisableClose(pds)

That's it!

Usage with OpenTracing

OpenTracing is a vendor neutral open standard for distributed tracing, which basically means, it provides standard and vendor-neutral APIs for popular platforms, i.e., popular tracing backends implement the OpenTracing API. More on OpenTracing : http://opentracing.io/documentation/.

perfevents can be used with the popular tracing implementations like Zipkin and Jaeger via the go-observer interface.

Usage with Zipkin

In the application where zipkin is initialized, a new perfevents observer must be created. This observer is then assigned to zipkin.

First import the perfevents/go package:

import perfevents "github.com/opentracing-contrib/perfevents/go"

Initialize a perfevents observer:

observer := perfevents.NewObserver()

And then, pass this new observer as part of initialization of zipkin:

tracer, _ := zipkin.NewTracer(..., zipkin.WithObserver(observer))

Now, to start a span with metrics like cache-misses and cycles :

sp := tracer.StartSpan("name", opentracing.Tag{"perfevents", "cpu-cycles,cache-misses"})

With this, the results can be seen in zipkin's UI.

Supported Events

For now, 7 generic hardware events are supported :

  • cpu-cycles
  • instructions
  • cache-references
  • cache-misses
  • branch-instructions
  • branch-misses
  • bus-cycles

Supported Tracers

perfevents is supported with distributed tracers which:

  • is OpenTracing compliant and,
  • provide the go-observer interface.

Right now, the above conditions are satisfied by Zipkin and Jaeger, with jaeger satisfying the second condition indirectly.

TODOs

  • Support the hardware cache events.
  • Support the dynamic events exported by the kernel.

# Functions

EventsDisableClose : Disable and close all the events in the slice "eventsInfo'.
EventsRead : Read the event count for a slice of event descriptors in "eventsInfo'.
FormatDataToString converts the data for an event to string.
InitOpenEventsEnableSelf opens, enables an event list provided in "events" string.
New observer creates a new observer.
NewSpanObserver creates a new SpanObserver that can emit perfevent metrics.

# Constants

Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Starts from bit value 0.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
List of generic events supported (from linux/perf_event.h) All of these events belong to HARDWARE type events.
List of generic events supported (from linux/perf_event.h) All of these events belong to HARDWARE type events.
List of generic events supported (from linux/perf_event.h) All of these events belong to HARDWARE type events.
List of generic events supported (from linux/perf_event.h) All of these events belong to HARDWARE type events.
List of generic events supported (from linux/perf_event.h) All of these events belong to HARDWARE type events.
List of generic events supported (from linux/perf_event.h) All of these events belong to HARDWARE type events.
List of generic events supported (from linux/perf_event.h) All of these events belong to HARDWARE type events.
Perf IOCTL operations for powerpc.
Perf IOCTL operations for x86.
Perf IOCTL operations for powerpc.
Perf IOCTL operations for x86.
Perf IOCTL operations for powerpc.
Perf IOCTL operations for x86.
PMU hardware type definitions (from linux/perf_event.h) Only HARDWARE type is supported as of now.
PMU hardware type definitions (from linux/perf_event.h) Only HARDWARE type is supported as of now.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.
Bit fields for the PerfEventAttr.properties value derived from linux/perf_event.h Each of these bits specify how do we want to start our counter.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

EventConfigType : The configuration struct for an event.
TODO: Add a member to keep the list of all available events, which is initialized when NewObserver() is called.
PerfEventAttr structure is derived from linux/perf_event.h This struct defines various attributes for a perf event.
PerfEventInfo holds the file descriptor for a perf event.
PerfIOCOps stores the correct IOC operations respective to the underlying architecture.
SpanObserver collects perfevent metrics.