Hertz supports flexible enabling of basic and fine-grained Instrumentation

Stats Level

OptionDescriptionEnable Strategy
LevelDisableddisable all eventsWhen tracer is not available, enable by default.
LevelBaseenable basic events
LevelDetailedenable basic events and detailed eventsWhen tracer is available, enable by default.

Stats Level Control

package main

import (

func main() {
    h := server.Default(server.WithTraceLevel(stats.LevelBase))

Stats introduction

Basic Stats Event

  1. HTTPStart : Http start
  2. HTTPFinish : Http finish

Detailed Stats Event

  1. ReadHeaderStart:read header start
  2. ReadHeaderFinish:read header finish
  3. ReadBodyStart:read body start
  4. ReadBodyFinish:read body finish
  5. ServerHandleStart:server handler start
  6. ServerHandleFinish:server handler finish
  7. WriteStart:write response start
  8. WriteFinish:write response finish

If you do not want to record this information, you can either not register any tracer or set the tracking strategy to LevelDisabled, and the framework will not record this information.

Setting the level of the stats for a specific node in the tracing to LevelDisabled or not registering any tracer will result in the loss of spans/metrics for that specific node and and will interrupt the tracing.



Last modified June 24, 2024 : fix: correct the file path (#1096) (b3fa1a4)