Instrumentation
Hertz supports flexible enabling of basic and fine-grained Instrumentation
Stats Level
Option | Description | Enable Strategy |
---|---|---|
LevelDisabled | disable all events | When tracer is not available, enable by default. |
LevelBase | enable basic events | |
LevelDetailed | enable basic events and detailed events | When tracer is available, enable by default. |
Stats Level Control
package main
import (
"github.com/cloudwego/hertz/pkg/app/server"
"github.com/cloudwego/hertz/pkg/common/tracer/stats"
)
func main() {
h := server.Default(server.WithTraceLevel(stats.LevelBase))
h.Spin()
}
Stats introduction
Basic Stats Event
HTTPStart
: Http startHTTPFinish
: Http finish
Detailed Stats Event
ReadHeaderStart
:read header startReadHeaderFinish
:read header finishReadBodyStart
:read body startReadBodyFinish
:read body finishServerHandleStart
:server handler startServerHandleFinish
:server handler finishWriteStart
:write response startWriteFinish
: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.
Timeline
Last modified
September 20, 2024
: doc: sync User Guide to Generic Call for Streaming [on trial] (#1140) (5641fba)