Documentation
¶
Overview ¶
Package go11y provides observability features including logging, tracing, and database logging of roundtrip requests to third-party APIs.
Index ¶
- Constants
- Variables
- func AddToContext(ctx context.Context, o *Observer) context.Context
- func DeduplicateArgs(args []any) (deduped []any)
- func Error(msg string, err error, severity string, ephemeralArgs ...any)
- func Fatal(msg string, err error, exitCode int, ephemeralArgs ...any)
- func GetMetricsMiddlewareMux(ctx context.Context, opts MetricsMiddlewareMuxOpts) (metricsMiddleware mux.MiddlewareFunc, fault error)
- func GetRequestID(ctx context.Context) string
- func InContext(ctx context.Context) (response bool)
- func NewHTTPWriter(w http.ResponseWriter) http.ResponseWriter
- func ObserverMiddleware(ctxWithObserver context.Context) (observerMiddleware mux.MiddlewareFunc, fault error)
- func Panic(msg string, err error, ephemeralArgs ...any)
- func RedactBody(jsonBlob []byte) []byte
- func RedactHeaders(headers http.Header) http.Header
- func RedactSecret(secretStr string, reveal int) string
- func RequestLoggerMiddlewareMux(ctxWithObserver context.Context) (loggerMiddleware mux.MiddlewareFunc, fault error)
- func Reset(ctxWithGo11y context.Context) (ctxWithResetObservability context.Context)
- func SetRequestIDMiddleware(next http.Handler) http.Handler
- func StringToLevel(level string) slog.Level
- type Configuration
- type Configurator
- type DBStorer
- type Fields
- type HTTPClient
- func (c *HTTPClient) AddDBStore(ctxWithObserver context.Context, dbStorer DBStorer) (fault error)
- func (c *HTTPClient) AddLogging(ctxWithObserver context.Context) (fault error)
- func (c *HTTPClient) AddMetrics(recorder MetricsRecorder, pathMaskFunc PathMask) (fault error)
- func (c *HTTPClient) AddPropagation(ctxWithObserver context.Context) (fault error)
- func (c *HTTPClient) AddTracing(ctxWithObserver context.Context) (fault error)
- type HTTPWriter
- type HTTPWriterFlusher
- type MetricsMiddlewareMuxOpts
- type MetricsRecorder
- type MiddlewareResponseWriter
- type Observer
- func Expand(ctx context.Context, tracer otelTrace.Tracer, spanName string, ...) (ctxWithSpan context.Context, observer *Observer, fault error)
- func Extend(ctx context.Context, newArgs ...any) (ctxWithGo11y context.Context, observer *Observer, fault error)
- func Get(ctx context.Context) (ctxWithObserver context.Context, observer *Observer, fault error)
- func Initialise(ctx context.Context, cfg Configurator, logOutput, errOutput io.Writer, ...) (ctxWithGo11y context.Context, observer *Observer, fault error)
- func InitialiseTestLogger(ctx context.Context, level slog.Level, logOut, logErr io.Writer) (ctxWithObserver context.Context, observer *Observer, fault error)
- func InitialiseTestTracer(ctx context.Context, level slog.Level, logOut, logErr io.Writer, ...) (ctxWithObserver context.Context, observer *Observer, fault error)
- func Span(ctx context.Context, tracer otelTrace.Tracer, spanName string, ...) (ctxWithSpan context.Context, observer *Observer, fault error)
- func (o *Observer) AddArgs(args ...any) (filteredArgs []any)
- func (o *Observer) Close()
- func (o *Observer) Debug(msg string, ephemeralArgs ...any)
- func (o *Observer) Develop(msg string, ephemeralArgs ...any)
- func (o *Observer) End()
- func (o *Observer) Error(msg string, err error, severity string, ephemeralArgs ...any)
- func (o *Observer) Fatal(msg string, err error, ephemeralArgs ...any)
- func (o *Observer) IncreaseDistance(distance int)
- func (o *Observer) Info(msg string, ephemeralArgs ...any)
- func (o *Observer) Notice(msg string, ephemeralArgs ...any)
- func (o *Observer) Panic(msg string, err error, ephemeralArgs ...any)
- func (o *Observer) Tracer(name string, opts ...otelTrace.TracerOption) otelTrace.Tracer
- func (o *Observer) Warn(msg string, ephemeralArgs ...any)
- func (o *Observer) Warning(msg string, ephemeralArgs ...any)
- type Origin
- type PathMask
- type ReverseProxy
- func (r *ReverseProxy) AddDBStore(ctxWithObserver context.Context, dbStorer DBStorer) (fault error)
- func (r *ReverseProxy) AddLogging(ctxWithObserver context.Context) (fault error)
- func (r *ReverseProxy) AddPropagation(ctxWithObserver context.Context) (fault error)
- func (r *ReverseProxy) AddTracing(ctxWithObserver context.Context) (fault error)
- type RoundTripperFunc
- type Tracer
- type TracerOption
Constants ¶
const FieldCallDuration = "call_duration"
FieldCallDuration is the structured log field name for "call_duration"
const FieldEnvironment = "environment"
FieldEnvironment is the structured log field name for "environment"
const FieldRemoteSpanID = "remote_span_id"
FieldRemoteSpanID is the structured log field name for "remote_span_id"
const FieldRemoteTraceID = "remote_trace_id"
FieldRemoteTraceID is the structured log field name for "remote_trace_id"
const FieldRequestBody = "request_body"
FieldRequestBody is the structured log field name for "request_body"
const FieldRequestHeaders = "request_headers"
FieldRequestHeaders is the structured log field name for "request_headers"
const FieldRequestID = "request_id"
FieldRequestID is the structured log field name for "request_id"
const FieldRequestMethod = "request_method"
FieldRequestMethod is the structured log field name for "request_method"
const FieldRequestPath = "request_path"
FieldRequestPath is the structured log field name for "request_path"
const FieldRequestURL = "request_url"
FieldRequestURL is the structured log field name for "request_url"
const FieldResponseBody = "response_body"
FieldResponseBody is the structured log field name for "response_body"
const FieldResponseHeaders = "response_headers"
FieldResponseHeaders is the structured log field name for "response_headers"
const FieldSpanID = "span_id"
FieldSpanID is the structured log field name for "span_id"
const FieldStatusCode = "status_code"
FieldStatusCode is the structured log field name for "status_code"
const FieldTraceID = "trace_id"
FieldTraceID is the structured log field name for "trace_id"
const LevelDebug = slog.Level(-4)
LevelDebug represents debug-level logging
const LevelDevelop = slog.Level(-8)
LevelDevelop is a custom level for development only logging, will be disabled in staging and production
const LevelError = slog.Level(8)
LevelError represents error-level logging
const LevelFatal = slog.Level(32)
LevelFatal represents fatal-level logging
const LevelInfo = slog.Level(0)
LevelInfo represents informational-level logging
const LevelNotice = slog.Level(2)
LevelNotice represents notice-level logging
const LevelPanic = slog.Level(16)
LevelPanic represents panic-level logging
const LevelWarning = slog.Level(4)
LevelWarning represents warning-level logging
const RequestIDHeader string = "X-Swoop-RequestID"
RequestIDHeader is a constant for the HTTP header used to store the request ID
const RequestIDInstance requestIDKey = "requestID"
RequestIDInstance is a constant for the context key used to store the request ID
const SeverityHigh string = "high"
SeverityHigh errors will cause disruption to system/process operation - something outside the user's control will need to be fixed
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
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
const SeverityLowest string = "lowest"
SeverityLowest errors pose no threat to system/process operation - the user can fix this themselves and continue this one operation
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
const SpanKindClient = otelTrace.SpanKindClient
SpanKindClient is a constant that aliases otelTrace.SpanKindClient
const SpanKindConsumer = otelTrace.SpanKindConsumer
SpanKindConsumer is a constant that aliases otelTrace.SpanKindConsumer
const SpanKindInternal = otelTrace.SpanKindInternal
SpanKindInternal is a constant that aliases otelTrace.SpanKindInternal
const SpanKindProducer = otelTrace.SpanKindProducer
SpanKindProducer is a constant that aliases otelTrace.SpanKindProducer
const SpanKindServer = otelTrace.SpanKindServer
SpanKindServer is a constant that aliases otelTrace.SpanKindServer
Variables ¶
var RequestTimes *prometheus.HistogramVec
RequestTimes is the metric for the amount of time the calling service has taken to handle requests
var Requests *prometheus.CounterVec
Requests is the metric for the number of requests the calling service has handled
Functions ¶
func AddToContext ¶ added in v0.8.4
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
DeduplicateArgs removes duplicate keys from a list of key-value pairs.
func Error ¶ added in v0.5.9
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
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 ¶
GetRequestID retrieves the request ID from the context.
func InContext ¶ added in v0.5.9
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
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
RedactBody redacts sensitive information from a JSON body.
func RedactHeaders ¶
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
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 SetRequestIDMiddleware ¶ added in v0.7.0
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 ¶
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 HTTPClient ¶ added in v0.8.0
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
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 ¶
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 ¶
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) Develop ¶
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 ¶
Error logs an error message, records the error in the span if available, and sets the severity.
func (*Observer) Fatal ¶
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
IncreaseDistance increases the caller skip distance for logging purposes. This is useful when wrapping go11y (such as the go-common splitLog)
func (*Observer) Info ¶
Info logs an informational message and adds an event to the span if available.
func (*Observer) Panic ¶ added in v0.9.0
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 ¶
Tracer gets a Tracer with the given name and options using the Observer's tracer provider.
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
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 ¶
RoundTripperFunc type is an adapter to allow the use of ordinary functions as http.RoundTripper
type 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
Source Files
¶
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. |