Skip to content

Commit

Permalink
Merge pull request #8 from pyroscope-io/feat/lock-event-types
Browse files Browse the repository at this point in the history
feat: add support for event types for lock profiling.
  • Loading branch information
abeaumont authored Apr 5, 2022
2 parents 3c6759c + 1ac4a10 commit f73efae
Showing 1 changed file with 79 additions and 8 deletions.
87 changes: 79 additions & 8 deletions parser/event_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import (
)

var events = map[string]func() Parseable{
"jdk.ActiveRecording": func() Parseable { return new(ActiveRecording) },
"jdk.ActiveSetting": func() Parseable { return new(ActiveSetting) },
"jdk.CPUInformation": func() Parseable { return new(CPUInformation) },
"jdk.CPULoad": func() Parseable { return new(CPULoad) },
"jdk.ExecutionSample": func() Parseable { return new(ExecutionSample) },
"jdk.InitialSystemProperty": func() Parseable { return new(InitialSystemProperty) },
// TODO: jdk.JavaMonitorEnter
"jdk.ActiveRecording": func() Parseable { return new(ActiveRecording) },
"jdk.ActiveSetting": func() Parseable { return new(ActiveSetting) },
"jdk.CPUInformation": func() Parseable { return new(CPUInformation) },
"jdk.CPULoad": func() Parseable { return new(CPULoad) },
"jdk.ExecutionSample": func() Parseable { return new(ExecutionSample) },
"jdk.InitialSystemProperty": func() Parseable { return new(InitialSystemProperty) },
"jdk.JavaMonitorEnter": func() Parseable { return new(JavaMonitorEnter) },
"jdk.JVMInformation": func() Parseable { return new(JVMInformation) },
"jdk.NativeLibrary": func() Parseable { return new(NativeLibrary) },
"jdk.ObjectAllocationInNewTLAB": func() Parseable { return new(ObjectAllocationInNewTLAB) },
"jdk.ObjectAllocationOutsideTLAB": func() Parseable { return new(ObjectAllocationOutsideTLAB) },
"jdk.OSInformation": func() Parseable { return new(OSInformation) },
// TODO: jdk.ThreadPark
"jdk.ThreadPark": func() Parseable { return new(ThreadPark) },
}

func ParseEvent(r reader.Reader, classes ClassMap, cpools PoolMap) (Parseable, error) {
Expand Down Expand Up @@ -224,6 +224,40 @@ func (isp *InitialSystemProperty) Parse(r reader.Reader, classes ClassMap, cpool
return parseFields(r, classes, cpools, class, nil, true, isp.parseField)
}

type JavaMonitorEnter struct {
StartTime int64
Duration int64
EventThread *Thread
StackTrace *StackTrace
MonitorClass *Class
PreviousOwner *Thread
Address int64
}

func (jme *JavaMonitorEnter) parseField(name string, p ParseResolvable) (err error) {
switch name {
case "startTime":
jme.StartTime, err = toLong(p)
case "duration":
jme.Duration, err = toLong(p)
case "eventThread":
jme.EventThread, err = toThread(p)
case "stackTrace":
jme.StackTrace, err = toStackTrace(p)
case "monitorClass":
jme.MonitorClass, err = toClass(p)
case "previousOwner":
jme.PreviousOwner, err = toThread(p)
case "address":
jme.Address, err = toLong(p)
}
return err
}

func (jme *JavaMonitorEnter) Parse(r reader.Reader, classes ClassMap, cpools PoolMap, class ClassMetadata) error {
return parseFields(r, classes, cpools, class, nil, true, jme.parseField)
}

type JVMInformation struct {
StartTime int64
JVMName string
Expand Down Expand Up @@ -364,6 +398,43 @@ func (os *OSInformation) Parse(r reader.Reader, classes ClassMap, cpools PoolMap
return parseFields(r, classes, cpools, class, nil, true, os.parseField)
}

type ThreadPark struct {
StartTime int64
Duration int64
EventThread *Thread
StackTrace *StackTrace
ParkedClass *Class
Timeout int64
Until int64
Address int64
}

func (tp *ThreadPark) parseField(name string, p ParseResolvable) (err error) {
switch name {
case "startTime":
tp.StartTime, err = toLong(p)
case "duration":
tp.Duration, err = toLong(p)
case "eventThread":
tp.EventThread, err = toThread(p)
case "stackTrace":
tp.StackTrace, err = toStackTrace(p)
case "parkedClass":
tp.ParkedClass, err = toClass(p)
case "timeout":
tp.Timeout, err = toLong(p)
case "until":
tp.Until, err = toLong(p)
case "address":
tp.Address, err = toLong(p)
}
return err
}

func (tp *ThreadPark) Parse(r reader.Reader, classes ClassMap, cpools PoolMap, class ClassMetadata) error {
return parseFields(r, classes, cpools, class, nil, true, tp.parseField)
}

type UnsupportedEvent struct{}

func (ue *UnsupportedEvent) parseField(name string, p ParseResolvable) error {
Expand Down

0 comments on commit f73efae

Please sign in to comment.