go11y

package module
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 34 Imported by: 0

README

go11y1 for observability in Go

Opinionated but simple Go implementation of structured logging and open telemetry tracing for your application.

Features

Structured Logging

go11y wraps the Go standard lib slog package, so it's structured logging with JSON from the outset, just more convenient.

_, o, _ := go11y.Initialise(ctx, nil, os.Stdout, "arg1", "val1")
o.Info("structured logging", nil, "arg2", "val2")
{
    "time":"2025-08-04T10:14:19.780509481+08:00",
    "level":"INFO",
    "source":{
        "function":"main.main",
        "file":"/home/user/demo/main.go",
        "line":81
    },
    "msg":"structured logging",
    "arg1": "val1",
    "arg2": "val2",
}
Tracing

go11y doesn't handle the tracing for you (yet) but it does leave room for it so you don't need to go to too much effort to integrate it.

_, o, _ := go11y.Initialise(ctx, nil, os.Stdout)

ctx, span := otel.Tracer("packageName").Start(ctx, "functionName", trace.WithSpanKind(trace.SpanKindClient))

o.Info("structured logging", span)
Roundtrippers
Middleware

Configuration

Hard Coded - BYO or Built in
Environment Variables

Examples

Used by

Todo

  • Implement integration tests for log ingestion and tracing with Grafana-LGTM testcontainer
  • Expand GoDoc details and add examples
  • Try to get tracing integrated into go11y so there is less boilerplate needed

Notes

1 sounds like golly

Documentation

Overview

Package go11y provides observability features including logging, tracing, and database logging of roundtrip requests to third-party APIs.

Index

Constants

View Source
const FieldCallDuration = "call_duration"

FieldCallDuration is the structured log field name for "call_duration"

View Source
const FieldEnvironment = "environment"

FieldEnvironment is the structured log field name for "environment"

View Source
const FieldRemoteSpanID = "remote_span_id"

FieldRemoteSpanID is the structured log field name for "remote_span_id"

View Source
const FieldRemoteTraceID = "remote_trace_id"

FieldRemoteTraceID is the structured log field name for "remote_trace_id"

View Source
const FieldRequestBody = "request_body"

FieldRequestBody is the structured log field name for "request_body"

View Source
const FieldRequestHeaders = "request_headers"

FieldRequestHeaders is the structured log field name for "request_headers"

View Source
const FieldRequestID = "request_id"

FieldRequestID is the structured log field name for "request_id"

View Source
const FieldRequestMethod = "request_method"

FieldRequestMethod is the structured log field name for "request_method"

View Source
const FieldRequestPath = "request_path"

FieldRequestPath is the structured log field name for "request_path"

View Source
const FieldRequestURL = "request_url"

FieldRequestURL is the structured log field name for "request_url"

View Source
const FieldResponseBody = "response_body"

FieldResponseBody is the structured log field name for "response_body"

View Source
const FieldResponseHeaders = "response_headers"

FieldResponseHeaders is the structured log field name for "response_headers"

View Source
const FieldSpanID = "span_id"

FieldSpanID is the structured log field name for "span_id"

View Source
const FieldStatusCode = "status_code"

FieldStatusCode is the structured log field name for "status_code"

View Source
const FieldTraceID = "trace_id"

FieldTraceID is the structured log field name for "trace_id"

View Source
const LevelDebug = slog.Level(-4)

LevelDebug represents debug-level logging

View Source
const LevelDevelop = slog.Level(-8)

LevelDevelop is a custom level for development only logging, will be disabled in staging and production

View Source
const LevelError = slog.Level(8)

LevelError represents error-level logging

View Source
const LevelFatal = slog.Level(32)

LevelFatal represents fatal-level logging

View Source
const LevelInfo = slog.Level(0)

LevelInfo represents informational-level logging

View Source
const LevelNotice = slog.Level(2)

LevelNotice represents notice-level logging

View Source
const LevelPanic = slog.Level(16)

LevelPanic represents panic-level logging

View Source
const LevelWarning = slog.Level(4)

LevelWarning represents warning-level logging

View Source
const RequestIDHeader string = "X-Swoop-RequestID"

RequestIDHeader is a constant for the HTTP header used to store the request ID

View Source
const RequestIDInstance requestIDKey = "requestID"

RequestIDInstance is a constant for the context key used to store the request ID

View Source
const SeverityHigh string = "high"

SeverityHigh errors will cause disruption to system/process operation - something outside the user's control will need to be fixed

View Source
const SeverityHighest string = "highest"

SeverityHighest errors will cause major disruption to system/process operation - something outside the user's control

will need to be fixed, and there may be wider implications for the system/process as a whole
View Source
const SeverityLow string = "low"

SeverityLow errors pose no threat to system/process operation - the user can fix this themselves but will need to restart the operation

View Source
const SeverityLowest string = "lowest"

SeverityLowest errors pose no threat to system/process operation - the user can fix this themselves and continue this one operation

View Source
const SeverityMedium string = "medium"

SeverityMedium errors may cause some disruption to system/process operation - the user may be able to fix this themselves but may need support

View Source
const SpanKindClient = otelTrace.SpanKindClient

SpanKindClient is a constant that aliases otelTrace.SpanKindClient

View Source
const SpanKindConsumer = otelTrace.SpanKindConsumer

SpanKindConsumer is a constant that aliases otelTrace.SpanKindConsumer

View Source
const SpanKindInternal = otelTrace.SpanKindInternal

SpanKindInternal is a constant that aliases otelTrace.SpanKindInternal

View Source
const SpanKindProducer = otelTrace.SpanKindProducer

SpanKindProducer is a constant that aliases otelTrace.SpanKindProducer

View Source
const SpanKindServer = otelTrace.SpanKindServer

SpanKindServer is a constant that aliases otelTrace.SpanKindServer

Variables

View Source
var RequestTimes *prometheus.HistogramVec

RequestTimes is the metric for the amount of time the calling service has taken to handle requests

Requests is the metric for the number of requests the calling service has handled

Functions

func AddToContext added in v0.8.4

func AddToContext(ctx context.Context, o *Observer) context.Context

AddToContext adds the Observer to the provided context. This is useful for reducing boilerplate in handlers and middlewares.

func DeduplicateArgs added in v0.5.8

func DeduplicateArgs(args []any) (deduped []any)

DeduplicateArgs removes duplicate keys from a list of key-value pairs.

func Error added in v0.5.9

func Error(msg string, err error, severity string, ephemeralArgs ...any)

Error is intended to be called before the observer has been configured. It will log the error to stderr in the JSON format used by go11y.

func Fatal added in v0.5.4

func Fatal(msg string, err error, exitCode int, ephemeralArgs ...any)

Fatal is intended to be called before the observer has been configured. It will log the fatal error to stderr in the JSON format used by go11y and exit the application abruptly.

func GetMetricsMiddlewareMux added in v0.7.0

func GetMetricsMiddlewareMux(ctx context.Context, opts MetricsMiddlewareMuxOpts) (metricsMiddleware mux.MiddlewareFunc, fault error)

GetMetricsMiddlewareMux initialises a promhttp metrics route on the provided mux router with a path of /internal/metrics and returns a mux middleware that records request-count and request-time Prometheus metrics for incoming HTTP requests and publishes the values on the endpoint/route.

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID retrieves the request ID from the context.

func InContext added in v0.5.9

func InContext(ctx context.Context) (response bool)

InContext can be used to check if go11y has been added to a context before calling go11y.Get() This is useful for other packages imported by services that use go11y as well as other services that still use the go-logging package.

func NewHTTPWriter added in v0.11.0

func NewHTTPWriter(w http.ResponseWriter) http.ResponseWriter

NewHTTPWriter creates a new HTTPWriter that wraps the provided http.ResponseWriter. If the underlying writer

func ObserverMiddleware added in v0.8.4

func ObserverMiddleware(ctxWithObserver context.Context) (observerMiddleware mux.MiddlewareFunc, fault error)

ObserverMiddleware is a middleware that adds the go11y Observer to the request context This allows us to use the go11y Observer in downstream handlers and middlewares without initializing it again or passing it explicitly If the Observer cannot be retrieved from the provided context, an error is returned.

func Panic added in v0.9.0

func Panic(msg string, err error, ephemeralArgs ...any)

Panic is intended to be called before the observer has been configured. It will log the fatal error to stderr in the JSON format used by go11y and exit the application cleanly

func RedactBody added in v0.9.2

func RedactBody(jsonBlob []byte) []byte

RedactBody redacts sensitive information from a JSON body.

func RedactHeaders

func RedactHeaders(headers http.Header) http.Header

RedactHeaders redacts sensitive information from HTTP headers such as Authorization and Cookie. It applies RedactSecret to the values of these headers.

func RedactSecret added in v0.5.8

func RedactSecret(secretStr string, reveal int) string

RedactSecret converts secrets to character-length-character notation, with variable length for the number of characters to reveal on each side, up to a maximum of an eighth on each side. Minimum secret length is to get character-length-character notation is 8, below that but above 4 characters in length or if the reveal is set to 0, the secret will be redacted with *-length-* examples: with a reveal value of 1 - "accessibility" becomes "a[11]y"

"internationalisation" becomes "i[18]n"
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij" becomes "A[34]j"
"ABCD" becomes "****"
"ABCDE" becomes "*3*"
"ABCDEF" becomes "*4*"
"ABCDEFG" becomes "*5*"
"ABCDEFGH" becomes "A[6]H"

with a reveal value of 2 - "observability" remains "o[11]y"

"internationalisation" becomes "in[16]on"
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij" becomes "AB[32]ij"

with a reveal value of 4 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij" becomes "ABCD[28]ghij" See ./config_test.go for more examples

func RequestLoggerMiddlewareMux added in v0.8.0

func RequestLoggerMiddlewareMux(ctxWithObserver context.Context) (loggerMiddleware mux.MiddlewareFunc, fault error)

RequestLoggerMiddlewareMux is a middleware that logs incoming HTTP requests and their details It extracts tracing information from the request headers and starts a new span for the request It also logs the request details using go11y, adding the go11y Observer to the request context in the process If the Observer cannot be retrieved from the provided context, an error is returned. If the request context does not already contain a go11y Observer, it is added to the context.

func Reset

func Reset(ctxWithGo11y context.Context) (ctxWithResetObservability context.Context)

Reset resets the Observer in the context to its initial state.

func SetRequestIDMiddleware added in v0.7.0

func SetRequestIDMiddleware(next http.Handler) http.Handler

SetRequestIDMiddleware is a middleware that sets a unique request ID for each incoming HTTP request It generates a new UUID for the request ID, sets it in the request context, and adds it to the response headers

func StringToLevel

func StringToLevel(level string) slog.Level

StringToLevel maps a string representation of a log level to its corresponding slog.Level.

Types

type Configuration

type Configuration struct {
	// contains filtered or unexported fields
}

Configuration is a struct that holds the reference configuration for go11y.

func CreateConfig

func CreateConfig(logLevel slog.Level, otelURL, dbConStr, serviceName string, trimModules, trimPaths []string) *Configuration

CreateConfig creates a new Configuration instance populated with the provided parameters. This is intended to be used for when you want to create a config without loading from environment variables. The Configuration returned satisfies the Configurator interface, allowing it to be used interchangeably with configurations loaded from environment variables.

func LoadConfig

func LoadConfig() (cfg *Configuration, fault error)

LoadConfig loads the configuration from environment variables. It returns a Configuration instance that implements the Configurator interface. If any required environment variable is missing or invalid, it returns an error.

func (*Configuration) LogLevel

func (c *Configuration) LogLevel() slog.Level

LogLevel returns the configured log level for the observer. This method is part of the Configurator interface.

func (*Configuration) OtelURL added in v0.5.8

func (c *Configuration) OtelURL() string

OtelURL returns the configured OpenTelemetry URL (scheme, host, port, path). This method is part of the Configurator interface.

func (*Configuration) ServiceName

func (c *Configuration) ServiceName() string

ServiceName returns the configured service name for OpenTelemetry. This method is part of the Configurator interface.

func (*Configuration) TrimModules

func (c *Configuration) TrimModules() []string

TrimModules returns the configured strings to be trimmed from the source.function attribute. This method is part of the Configurator interface.

func (*Configuration) TrimPaths

func (c *Configuration) TrimPaths() []string

TrimPaths returns the configured strings to be trimmed from the source.file attribute. This method is part of the Configurator interface.

type Configurator

type Configurator interface {
	LogLevel() slog.Level
	OtelURL() string
	ServiceName() string
	TrimPaths() []string
	TrimModules() []string
}

Configurator is an interface that defines the methods required for configuration of go11y. It is used to abstract the configuration details from the observer implementation. This allows for different implementations of configuration, such as loading from environment variables or using a custom configuration struct - ideal for our unit tests or when you want to use a your own bespoke configuration source

type DBStorer added in v0.8.0

type DBStorer interface {
	SetURL(string)
	SetMethod(string)
	SetRequestHeaders([]byte)
	SetRequestBody(pgtype.Text)
	SetResponseTimeMS(int64)
	SetResponseHeaders([]byte)
	SetResponseBody(pgtype.Text)
	SetStatusCode(int32)
	Exec(ctx context.Context) error
}

DBStorer interface defines methods for storing HTTP request and response details in a database

type Fields

type Fields map[string]any

Fields represents a set of key-value pairs for logging.

type HTTPClient added in v0.8.0

type HTTPClient struct {
	*http.Client
}

HTTPClient is a wrapper around http.Client that provides methods to add OpenTelemetry tracing, propagation, logging, metrics, and database storage functionality.

func (*HTTPClient) AddDBStore added in v0.8.0

func (c *HTTPClient) AddDBStore(ctxWithObserver context.Context, dbStorer DBStorer) (fault error)

AddDBStore wraps a http.Client's transporter with database storage functionality This allows us to store request and response details in a database for auditing and analysis purposes Note: Ensure that the database connection and storage system are properly initialized before using this client

func (*HTTPClient) AddLogging added in v0.8.0

func (c *HTTPClient) AddLogging(ctxWithObserver context.Context) (fault error)

AddLogging wraps a http.Client's transporter with logging functionality This allows us to log request and response details for debugging and monitoring purposes Note: Ensure that the logging system is properly initialized before using this client

func (*HTTPClient) AddMetrics added in v0.8.0

func (c *HTTPClient) AddMetrics(recorder MetricsRecorder, pathMaskFunc PathMask) (fault error)

AddMetrics wraps a http.Client's transporter with metrics recording functionality $recorder is the function that actually records the metrics - if it is nil an error is returned This allows us to record metrics for request and response details for monitoring purposes

func (*HTTPClient) AddPropagation added in v0.8.0

func (c *HTTPClient) AddPropagation(ctxWithObserver context.Context) (fault error)

AddPropagation wraps a http.Client's transporter with OpenTelemetry propagation This allows us to propagate tracing context across service boundaries Note: Ensure that the OpenTelemetry SDK and propagation package are properly initialized before using this client

func (*HTTPClient) AddTracing added in v0.8.0

func (c *HTTPClient) AddTracing(ctxWithObserver context.Context) (fault error)

AddTracing wraps a http.Client's transporter with OpenTelemetry instrumentation This allows us to capture request and response details in our telemetry data Note: Ensure that the OpenTelemetry SDK and otelhttp package are properly initialized before using this client

type HTTPWriter added in v0.11.0

type HTTPWriter struct {
	// contains filtered or unexported fields
}

HTTPWriter is a wrapper around http.ResponseWriter that allows us to capture the response body for logging purposes. It implements the http.ResponseWriter interface and optionally the http.Flusher interface if the underlying writer supports it.

func (*HTTPWriter) Header added in v0.11.0

func (w *HTTPWriter) Header() http.Header

Header returns the header map that will be sent by WriteHeader.

func (*HTTPWriter) Write added in v0.11.0

func (w *HTTPWriter) Write(data []byte) (int, error)

Write writes the data to the connection as part of an HTTP reply.

func (*HTTPWriter) WriteHeader added in v0.11.0

func (w *HTTPWriter) WriteHeader(statusCode int)

WriteHeader sends an HTTP response header with the provided status code.

type HTTPWriterFlusher added in v0.11.0

type HTTPWriterFlusher struct {
	*HTTPWriter  // wrap our "normal" writer
	http.Flusher // keep a ref to the wrapped Flusher
}

HTTPWriterFlusher is a wrapper around HTTPWriter that also implements the http.Flusher interface if the underlying http.ResponseWriter supports it. This allows us to use the Flush method to flush the response buffer when needed.

func (*HTTPWriterFlusher) Flush added in v0.11.0

func (w *HTTPWriterFlusher) Flush()

Flush sends any buffered data to the client.

type MetricsMiddlewareMuxOpts added in v0.7.0

type MetricsMiddlewareMuxOpts struct {
	Service      string      // required - the name of the service being instrumented
	Router       *mux.Router // required - the router for the service being instrumented. This is used to register the /internal/metrics endpoint.
	PathMaskFunc PathMask    // required - function to remove variable parts of the path for metrics aggregation. If nil, the path for metrics will not me masked
	Swagger      *openapi3.T // optional - the swagger spec for the service being instrumented. This is used to get the endpoint names. If nil, the raw request paths are used.
	// contains filtered or unexported fields
}

MetricsMiddlewareMuxOpts are the options used to initialise the metrics middleware for a mux.Router

var RuntimeOpts MetricsMiddlewareMuxOpts

RuntimeOpts are the options used to initialise the metrics middleware

type MetricsRecorder added in v0.7.0

type MetricsRecorder func(statusCode int, method, path string, startTime time.Time)

MetricsRecorder is a function type for recording metrics.

type MiddlewareResponseWriter added in v0.7.2

type MiddlewareResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

MiddlewareResponseWriter is a custom http.ResponseWriter that captures the status code of the response.

func (*MiddlewareResponseWriter) Write added in v0.7.2

func (mrw *MiddlewareResponseWriter) Write(b []byte) (int, error)

Write writes the data to the connection as part of an HTTP reply. If WriteHeader has not yet been called, Write calls WriteHeader(http.StatusOK) before writing the data. Thus, explicit calls to WriteHeader are mainly used to send error codes.

func (*MiddlewareResponseWriter) WriteHeader added in v0.7.2

func (mrw *MiddlewareResponseWriter) WriteHeader(code int)

WriteHeader sends an HTTP response header with the provided status code.

type Observer

type Observer struct {
	// contains filtered or unexported fields
}

Observer is the main struct for observability, containing loggers, tracer providers, and database connections.

func Expand

func Expand(
	ctx context.Context,
	tracer otelTrace.Tracer,
	spanName string,
	spanKind otelTrace.SpanKind,
	newArgs ...any,
) (
	ctxWithSpan context.Context,
	observer *Observer,
	fault error,
)

Expand retrieves the Observer from the context, starts a new tracing span with the given name, and adds new arguments to its logger. If no Observer exists in the context, it initializes a new one with default settings and adds the arguments.

func Extend

func Extend(ctx context.Context, newArgs ...any) (ctxWithGo11y context.Context, observer *Observer, fault error)

Extend retrieves the Observer from the context and adds new arguments to its logger. If no Observer exists in the context, it initializes a new one with default settings and adds the arguments.

func Get

func Get(ctx context.Context) (ctxWithObserver context.Context, observer *Observer, fault error)

Get retrieves the Observer from the context. If none exists, it initializes a new one with default settings.

func Initialise

func Initialise(
	ctx context.Context,
	cfg Configurator,
	logOutput, errOutput io.Writer,
	initialArgs ...any,
) (
	ctxWithGo11y context.Context,
	observer *Observer,
	fault error,
)

Initialise sets up the Observer with the provided configuration, log outputs, and initial arguments.

func InitialiseTestLogger added in v0.5.0

func InitialiseTestLogger(ctx context.Context, level slog.Level, logOut, logErr io.Writer) (ctxWithObserver context.Context, observer *Observer, fault error)

InitialiseTestLogger set up a logger for use in tests - no tracing, no db logging

func InitialiseTestTracer added in v0.5.0

func InitialiseTestTracer(ctx context.Context, level slog.Level, logOut, logErr io.Writer, otelURL, serviceName string) (ctxWithObserver context.Context, observer *Observer, fault error)

InitialiseTestTracer set up a tracer for use in tests - with tracing, but no db logging

func Span

func Span(
	ctx context.Context,
	tracer otelTrace.Tracer,
	spanName string,
	spanKind otelTrace.SpanKind,
) (
	ctxWithSpan context.Context,
	observer *Observer,
	fault error,
)

Span gets the Observer from the context and starts a new tracing span with the given name. If no Observer exists in the context, it initializes a new one with default settings and starts the span. The tracing equivalent of Get()

func (*Observer) AddArgs

func (o *Observer) AddArgs(args ...any) (filteredArgs []any)

AddArgs processes the provided arguments, ensuring that they are stable and formatted correctly.

func (*Observer) Close

func (o *Observer) Close()

Close ends all active spans and shuts down the trace provider to ensure all traces are flushed.

func (*Observer) Debug

func (o *Observer) Debug(msg string, ephemeralArgs ...any)

Debug logs a debug message and adds an event to the span if available.

func (*Observer) Develop

func (o *Observer) Develop(msg string, ephemeralArgs ...any)

Develop logs a development-only message and adds an event to the span if available.

func (*Observer) End

func (o *Observer) End()

End ends the current tracing span and reverts to the previous span in the stack.

func (*Observer) Error

func (o *Observer) Error(msg string, err error, severity string, ephemeralArgs ...any)

Error logs an error message, records the error in the span if available, and sets the severity.

func (*Observer) Fatal

func (o *Observer) Fatal(msg string, err error, ephemeralArgs ...any)

Fatal logs a fatal error message with the highest severity, records the error in the span if available, and then exits the application abruptly.

func (*Observer) IncreaseDistance added in v0.5.10

func (o *Observer) IncreaseDistance(distance int)

IncreaseDistance increases the caller skip distance for logging purposes. This is useful when wrapping go11y (such as the go-common splitLog)

func (*Observer) Info

func (o *Observer) Info(msg string, ephemeralArgs ...any)

Info logs an informational message and adds an event to the span if available.

func (*Observer) Notice

func (o *Observer) Notice(msg string, ephemeralArgs ...any)

Notice logs a notice message and adds an event to the span if available.

func (*Observer) Panic added in v0.9.0

func (o *Observer) Panic(msg string, err error, ephemeralArgs ...any)

Panic logs a fatal error message with the highest severity, records the error in the span if available, and then exits the application cleanly.

func (*Observer) Tracer

func (o *Observer) Tracer(name string, opts ...otelTrace.TracerOption) otelTrace.Tracer

Tracer gets a Tracer with the given name and options using the Observer's tracer provider.

func (*Observer) Warn

func (o *Observer) Warn(msg string, ephemeralArgs ...any)

Warn a backward compatibility alias for Warning.

func (*Observer) Warning

func (o *Observer) Warning(msg string, ephemeralArgs ...any)

Warning logs a warning message and adds an event to the span if available.

type Origin

type Origin struct {
	ClientIP  string `json:"client_ip"`
	UserAgent string `json:"user_agent"`
	Method    string `json:"method"`
	Path      string `json:"path"`
}

Origin represents the origin details of an HTTP request

type PathMask added in v0.7.0

type PathMask func(path string) (maskedPath string)

PathMask is a function that takes a path string and returns a masked path string This can be used to remove variable parts of the path for metrics aggregation

type ReverseProxy added in v0.8.0

type ReverseProxy struct {
	*httputil.ReverseProxy
}

ReverseProxy is a wrapper around httputil.ReverseProxy that provides methods to add OpenTelemetry tracing, propagation, logging, and database storage functionality.

func (*ReverseProxy) AddDBStore added in v0.8.0

func (r *ReverseProxy) AddDBStore(ctxWithObserver context.Context, dbStorer DBStorer) (fault error)

AddDBStore wraps a httputil.ReverseProxy's transporter with database storage functionality This allows us to store request and response details in a database for auditing and analysis purposes Note: Ensure that the database connection and storage system are properly initialized before using this client

func (*ReverseProxy) AddLogging added in v0.8.0

func (r *ReverseProxy) AddLogging(ctxWithObserver context.Context) (fault error)

AddLogging wraps a httputil.ReverseProxy's transporter with logging functionality This allows us to log request and response details for debugging and monitoring purposes Note: Ensure that the logging system is properly initialized before using this client

func (*ReverseProxy) AddPropagation added in v0.8.0

func (r *ReverseProxy) AddPropagation(ctxWithObserver context.Context) (fault error)

AddPropagation wraps a httputil.ReverseProxy's transporter with OpenTelemetry propagation This allows us to propagate tracing context across service boundaries Note: Ensure that the OpenTelemetry SDK and propagation package are properly initialized before using this client

func (*ReverseProxy) AddTracing added in v0.8.0

func (r *ReverseProxy) AddTracing(ctxWithObserver context.Context) (fault error)

AddTracing wraps a httputil.ReverseProxy's transporter with OpenTelemetry instrumentation This allows us to capture request and response details in our telemetry data Note: Ensure that the OpenTelemetry SDK and otelhttp package are properly initialized before using this client

type RoundTripperFunc

type RoundTripperFunc func(*http.Request) (*http.Response, error)

RoundTripperFunc type is an adapter to allow the use of ordinary functions as http.RoundTripper

func (RoundTripperFunc) RoundTrip

func (rt RoundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip calls the RoundTripperFunc with the given request for each RoundTripper

type Tracer

type Tracer otelTrace.Tracer // Tracer is an alias for otelTrace.Tracer

func NewTracer

func NewTracer(packageAddress string, options ...TracerOption) Tracer

NewTracer creates a new Tracer with the given package address and options.

type TracerOption

type TracerOption otelTrace.TracerOption // TracerOption is an alias for otelTrace.TracerOption

Directories

Path Synopsis
Package cleaner provides functionality to purge API request and response records stored in a PostgreSQL database that were created by go11y's AddDBStorer transport middleware.
Package cleaner provides functionality to purge API request and response records stored in a PostgreSQL database that were created by go11y's AddDBStorer transport middleware.
Package storer provides functionality to store API request and response details in a PostgreSQL database for use by go11y's AddDBStorer transport middleware.
Package storer provides functionality to store API request and response details in a PostgreSQL database for use by go11y's AddDBStorer transport middleware.
tests
containers
Package containers provides utilities for setting up testing containers.
Package containers provides utilities for setting up testing containers.
db
Package db provides database migration functionality using embedded filesystem for migration files.
Package db provides database migration functionality using embedded filesystem for migration files.
etc/migrations
Package migrations provides functionality to manage database migrations using embedded SQL files.
Package migrations provides functionality to manage database migrations using embedded SQL files.

Jump to

Keyboard shortcuts

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