trace

package
v4.29.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

README

Trace

Deprecated: requests are identified by their OpenTelemetry trace ID instead of X-Ab-TraceID. Use OpenTelemetry tracing (go.opentelemetry.io/otel) to create and propagate it. This package is kept for compatibility and gets no new features.

This package contains filter for generating traceID (X-Ab-TraceID header field) if there is no X-Ab-TraceID in request header.

Usage

Importing
import "github.com/AccelByte/go-restful-plugins/v4/pkg/trace"
Filter

Filter is restful.FilterFunction for generating traceID (X-Ab-TraceID header field) if there is no X-Ab-TraceID in request header.

Example usage of filter for all endpoints

Simple initialization:

ws := new(restful.WebService)
ws.Filter(trace.Filter())

With option initialization:

ws := new(restful.WebService)
ws.Filter(trace.FilterWithOption(trace.SimpleTraceID))

Supported TraceID Type:

  • SimpleTraceID = "uuid" format
  • TimeBasedTraceID (default) = "requestTime-uuid" format

Documentation

Overview

Package trace provides a go-restful filter that sets the X-Ab-TraceID request ID: it reads the request header, generates an ID when there is none, and returns it in the response header.

Deprecated: requests are identified by their OpenTelemetry trace ID instead of X-Ab-TraceID. Use OpenTelemetry tracing (go.opentelemetry.io/otel) to create and propagate it. This package is kept for compatibility and gets no new features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter() restful.FilterFunction

func FilterWithOption added in v4.4.0

func FilterWithOption(traceIDType IDType) restful.FilterFunction

Types

type IDType added in v4.4.0

type IDType string

IDType is the type for trace_id

const (
	TraceIDKey = "X-Ab-TraceID"

	SimpleTraceID    IDType = "Simple"    // format: uuid
	TimeBasedTraceID IDType = "TimeBased" // format: requestTime-uuid
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL