ionhttp

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package http provides HTTP server and client instrumentation using OpenTelemetry.

Server middleware creates spans for incoming requests:

mux := http.NewServeMux()
mux.HandleFunc("/api", handler)
instrumented := ionhttp.Handler(mux, "my-service")
http.ListenAndServe(":8080", instrumented)

Client instrumentation wraps an http.Client:

client := ionhttp.Client()
resp, err := client.Get("https://api.example.com")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(opts ...Option) *http.Client

Client returns an HTTP client instrumented with OpenTelemetry. Each request creates a client span linked to the current trace context.

func Handler

func Handler(handler http.Handler, operation string, opts ...Option) http.Handler

Handler wraps an http.Handler with OpenTelemetry instrumentation. It creates spans for each incoming request with attributes for: - HTTP method - URL path - Status code - Request/response size

func Transport

func Transport(base http.RoundTripper) http.RoundTripper

Transport returns an http.RoundTripper instrumented with OpenTelemetry. Use this to instrument custom transports.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures HTTP instrumentation.

func WithFilter

func WithFilter(filter func(r *http.Request) bool) Option

WithFilter sets a filter function to exclude requests from tracing. Return true to include the request, false to skip.

Example:

ionhttp.Handler(mux, "api", ionhttp.WithFilter(func(r *http.Request) bool {
    return r.URL.Path != "/health"
}))

Jump to

Keyboard shortcuts

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