Skip to content

Add request-level logging and metrics via Gadget middleware #50

@xortim

Description

@xortim

Problem

There is no centralized request-level observability in Penny. Any logging or timing must be added inside individual handlers, leading to duplication or inconsistency. Gadget already tracks correlation IDs and request latency internally, but consumers have no way to hook into the pipeline.

What changes

Once Gadget supports middleware, register a logging/metrics middleware in cmd/server.go:

myBot.Use(func(next gadget.HandlerFunc) gadget.HandlerFunc {
    return func(ctx gadget.HandlerContext, ...) {
        start := time.Now()
        log.Info().Str("route", ctx.Route.Name).Msg("handling event")
        next(ctx, ...)
        log.Info().Dur("duration", time.Since(start)).Msg("done")
    }
})

This would provide consistent request logging across all handlers without modifying handler code.

Blocked by

Files affected

  • cmd/server.go — register middleware after SetupWithConfig

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions