Allow dumping stacks via ETW capture state
Signed-off-by: Kevin Parsons <kevpar@microsoft.com>
This commit is contained in:
parent
05dd66b2e6
commit
78f3dc433c
@ -24,7 +24,9 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
winio "github.com/Microsoft/go-winio"
|
winio "github.com/Microsoft/go-winio"
|
||||||
|
"github.com/Microsoft/go-winio/pkg/etw"
|
||||||
"github.com/Microsoft/go-winio/pkg/etwlogrus"
|
"github.com/Microsoft/go-winio/pkg/etwlogrus"
|
||||||
|
"github.com/Microsoft/go-winio/pkg/guid"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/services/server"
|
"github.com/containerd/containerd/services/server"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -91,11 +93,25 @@ func setupDumpStacks() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func etwCallback(sourceID *guid.GUID, state etw.ProviderState, level etw.Level, matchAnyKeyword uint64, matchAllKeyword uint64, filterData uintptr) {
|
||||||
// Provider ID: {2acb92c0-eb9b-571a-69cf-8f3410f383ad}
|
if state == etw.ProviderStateCaptureState {
|
||||||
// Hook isn't closed explicitly, as it will exist until process exit.
|
dumpStacks()
|
||||||
// GUID is generated based on name - see Microsoft/go-winio/tools/etw-provider-gen.
|
}
|
||||||
if hook, err := etwlogrus.NewHook("ContainerD"); err == nil {
|
}
|
||||||
logrus.AddHook(hook)
|
|
||||||
|
func init() {
|
||||||
|
// Provider ID: 2acb92c0-eb9b-571a-69cf-8f3410f383ad
|
||||||
|
// Provider and hook aren't closed explicitly, as they will exist until
|
||||||
|
// process exit. GUID is generated based on name - see
|
||||||
|
// Microsoft/go-winio/tools/etw-provider-gen.
|
||||||
|
provider, err := etw.NewProvider("ContainerD", etwCallback)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
} else {
|
||||||
|
if hook, err := etwlogrus.NewHookFromProvider(provider); err == nil {
|
||||||
|
logrus.AddHook(hook)
|
||||||
|
} else {
|
||||||
|
logrus.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user