Documentation
¶
Overview ¶
Package sdk holds the primitives shared by the logging, httpclient, metrics and health subpackages: the correlation ID that lets a single request be grepped across every service it touches, before any real distributed tracing backend is in place.
Index ¶
Constants ¶
View Source
const TraceIDHeader = "X-Trace-Id"
TraceIDHeader is the header a service reads an inbound correlation ID from, and the header httpclient.New's transport sets on outbound requests so the ID survives service boundaries.
Variables ¶
This section is empty.
Functions ¶
func TraceIDFromContext ¶
TraceIDFromContext returns the correlation ID stored on ctx, if any.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package apperr is the shared application-error type used to carry an HTTP status code, a public-facing message, and an internal error (with stack trace, via github.com/pkg/errors) in one value.
|
Package apperr is the shared application-error type used to carry an HTTP status code, a public-facing message, and an internal error (with stack trace, via github.com/pkg/errors) in one value. |
|
Package health provides standard liveness and readiness endpoints.
|
Package health provides standard liveness and readiness endpoints. |
|
Package httpclient provides an *http.Client that automatically forwards the correlation ID from the outgoing request's context (set by logging.Middleware on the way in) as the X-Trace-Id header on every outbound request — this is what makes a request's log lines findable across every service it touches, not just the one that received it first.
|
Package httpclient provides an *http.Client that automatically forwards the correlation ID from the outgoing request's context (set by logging.Middleware on the way in) as the X-Trace-Id header on every outbound request — this is what makes a request's log lines findable across every service it touches, not just the one that received it first. |
|
Package logging provides the shared Gin request-logging middleware: a zerolog logger carrying a correlation ID (read from an inbound X-Trace-Id header if the caller already had one, otherwise minted here) injected into the request context, structured request/response logging, and stack-trace-aware error logging for errors built with the apperr package.
|
Package logging provides the shared Gin request-logging middleware: a zerolog logger carrying a correlation ID (read from an inbound X-Trace-Id header if the caller already had one, otherwise minted here) injected into the request context, structured request/response logging, and stack-trace-aware error logging for errors built with the apperr package. |
|
Package metrics provides shared Prometheus request metrics and Gin instrumentation middleware, so every service can adopt the same pattern without re-deriving it.
|
Package metrics provides shared Prometheus request metrics and Gin instrumentation middleware, so every service can adopt the same pattern without re-deriving it. |
Click to show internal directories.
Click to hide internal directories.