component.go 668 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package mhayaGops
  2. import (
  3. "github.com/google/gops/agent"
  4. mhayaFacade "github.com/mhaya/facade"
  5. mhayaLogger "github.com/mhaya/logger"
  6. )
  7. // Component gops 监听进程数据
  8. type Component struct {
  9. mhayaFacade.Component
  10. options agent.Options
  11. }
  12. func New(options ...agent.Options) *Component {
  13. component := &Component{}
  14. if len(options) > 0 {
  15. component.options = options[0]
  16. }
  17. return component
  18. }
  19. func (c *Component) Name() string {
  20. return "gops_component"
  21. }
  22. func (c *Component) Init() {
  23. if err := agent.Listen(c.options); err != nil {
  24. mhayaLogger.Error(err)
  25. }
  26. }
  27. func (c *Component) OnAfterInit() {
  28. }
  29. func (c *Component) OnStop() {
  30. //agent.Close()
  31. }