netgolang.org/x/net/quic/qlog Index | Files

package qlog

import "golang.org/x/net/quic/qlog"

Package qlog serializes qlog events.

Index

Constants

const (
	// VantageEndpoint traces contain events not specific to a single connection.
	VantageEndpoint = Vantage("endpoint")

	// VantageClient traces follow a connection from the client's perspective.
	VantageClient = Vantage("client")

	// VantageServer traces follow a connection from the server's perspective.
	VantageServer = Vantage("server")
)

Functions

func NewJSONHandler

func NewJSONHandler(opts HandlerOptions) slog.Handler

NewJSONHandler returns a handler which serializes qlog events to JSON.

The handler will write an endpoint-wide trace, and a separate trace for each connection. The HandlerOptions control the location traces are written.

It uses the streamable JSON Text Sequences mapping (JSON-SEQ) defined in draft-ietf-quic-qlog-main-schema-04, Section 6.2.

A JSONHandler may be used as the handler for a quic.Config.QLogLogger. It is not a general-purpose slog handler, and may not properly handle events from other sources.

Types

type HandlerOptions

type HandlerOptions struct {
	// Level reports the minimum record level that will be logged.
	// If Level is nil, the handler assumes QLogLevelEndpoint.
	Level slog.Leveler

	// Dir is the directory in which to create trace files.
	// The handler will create one file per connection.
	// If NewTrace is non-nil or Dir is "", the handler will not create files.
	Dir string

	// NewTrace is called to create a new trace.
	// If NewTrace is nil and Dir is set,
	// the handler will create a new file in Dir for each trace.
	NewTrace func(TraceInfo) (io.WriteCloser, error)
}

HandlerOptions are options for a JSONHandler.

type TraceInfo

type TraceInfo struct {
	// Vantage is the vantage point of the trace.
	Vantage Vantage

	// GroupID identifies the logical group the trace belongs to.
	// For a connection trace, the group will be the same for
	// both the client and server vantage points.
	GroupID string
}

TraceInfo contains information about a trace.

type Vantage

type Vantage string

Vantage is the vantage point of a trace.

Source Files

handler.go json_writer.go qlog.go

Version
v0.35.0 (latest)
Published
Feb 10, 2025
Platform
linux/amd64
Imports
11 packages
Last checked
14 minutes ago

Tools for package owners.