This document provides a complete reference for the GoVisual API.
func Wrap(handler http.Handler, opts ...Option) http.HandlerWraps an HTTP handler with GoVisual middleware to enable request visualization.
Parameters:
handler http.Handler: The original HTTP handler to wrapopts ...Option: Configuration options
Returns:
http.Handler: The wrapped handler
Example:
wrapped := govisual.Wrap(originalHandler, options...)func WithMaxRequests(max int) OptionSets the maximum number of requests to store in memory.
Parameters:
max int: Maximum number of requests to store
Example:
govisual.WithMaxRequests(500)func WithDashboardPath(path string) OptionSets the URL path where the dashboard will be accessible.
Parameters:
path string: URL path for the dashboard
Example:
govisual.WithDashboardPath("/__debug")func WithRequestBodyLogging(enabled bool) OptionEnables or disables logging of request bodies.
Parameters:
enabled bool: Whether to log request bodies
Example:
govisual.WithRequestBodyLogging(true)func WithResponseBodyLogging(enabled bool) OptionEnables or disables logging of response bodies.
Parameters:
enabled bool: Whether to log response bodies
Example:
govisual.WithResponseBodyLogging(true)func WithIgnorePaths(patterns ...string) OptionSets path patterns to ignore from request logging.
Parameters:
patterns ...string: Path patterns to ignore
Example:
govisual.WithIgnorePaths("/health", "/metrics", "/static/*")func WithMemoryStorage() OptionConfigures GoVisual to use in-memory storage (default).
Example:
govisual.WithMemoryStorage()func WithPostgresStorage(connStr string, tableName string) OptionConfigures GoVisual to use PostgreSQL storage.
Parameters:
connStr string: PostgreSQL connection stringtableName string: Name of the table to use
Example:
govisual.WithPostgresStorage(
"postgres://user:password@localhost:5432/dbname?sslmode=disable",
"govisual_requests"
)func WithRedisStorage(connStr string, ttlSeconds int) OptionConfigures GoVisual to use Redis storage.
Parameters:
connStr string: Redis connection stringttlSeconds int: Time-to-live in seconds
Example:
govisual.WithRedisStorage("redis://localhost:6379/0", 86400)func WithMongoDBStorage(uri, databaseName, collectionName string)Configures GoVisual to use MongoDB storage.
Parameters:
uri string: MongoDB connection URIdatabaseName string: Name of the database to usecollectionName string: Name of the collection to use
Example:
govisual.WithMongoDBStorage("mongodb://user:password@localhost:27017", "your_database", "your_collection")func WithOpenTelemetry(enabled bool) OptionEnables or disables OpenTelemetry instrumentation.
Parameters:
enabled bool: Whether to enable OpenTelemetry
Example:
govisual.WithOpenTelemetry(true)func WithServiceName(name string) OptionSets the service name for OpenTelemetry.
Parameters:
name string: Service name
Example:
govisual.WithServiceName("my-service")func WithServiceVersion(version string) OptionSets the service version for OpenTelemetry.
Parameters:
version string: Service version
Example:
govisual.WithServiceVersion("1.0.0")func WithOTelEndpoint(endpoint string) OptionSets the OTLP endpoint for exporting telemetry data.
Parameters:
endpoint string: OTLP endpoint
Example:
govisual.WithOTelEndpoint("otel-collector:4317")- Configuration Options - Detailed configuration guide
- Storage Backends - Storage backend documentation
- OpenTelemetry Integration - OpenTelemetry integration guide