Commit Graph

2 Commits

Author SHA1 Message Date
Matt Holloway 9d3e8b707d Draft: tool invocation logging middleware
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Build and Test Go Project / build (macos-latest) (push) Has been cancelled
Build and Test Go Project / build (ubuntu-latest) (push) Has been cancelled
Build and Test Go Project / build (windows-latest) (push) Has been cancelled
Adds a sensible logging integration on top of the (currently unused)
observability.Exporters scaffolding:

  * pkg/github/logging_middleware.go
    ToolLoggingMiddleware times every tools/call and logs at Debug on
    success / Error on failure (Go error or IsError result). It enriches
    a *slog.Logger with mcp.method and mcp.tool, then stores it on the
    context via observability.ContextWithLogger so tool handlers pick up
    the request-scoped logger automatically from deps.Logger(ctx).

  * pkg/observability/logger_context.go
    ContextWithLogger / LoggerFromContext helpers.

  * pkg/observability/log_level.go
    ParseLogLevel for 'debug|info|warn|error'.

  * --log-level flag / GITHUB_LOG_LEVEL env var
    Fills an obvious gap: previously levels were hard-coded (stderr=Info,
    file=Debug). The default behaviour is preserved when the flag is empty.

  * Fix fmt.Fprintf(os.Stderr, ...) feature-flag check reporting in
    BaseDeps.IsFeatureEnabled / RequestDeps.IsFeatureEnabled — these
    previously bypassed the structured logger entirely.

Tool handler code is intentionally untouched. The middleware gives every
tool a duration/outcome log line uniformly; tools that want richer
structured logs can opt in via deps.Logger(ctx).

Tests cover the middleware (success / error / IsError / non-tool
pass-through / missing deps), the context helpers, level parsing, and
the BaseDeps.Logger(ctx) context fallback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 17:18:21 +01:00
Matt Holloway dd239d8443 Initial OSS logging adapter for http (#2008)
* initial logging stack for http

* add metrics adapter

* fix linter issues

* make log fields generic

* Update pkg/github/server_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove unused SlogMetrics adapter

The slog-based metrics adapter was never used — OSS always uses
NoopMetrics and the remote server has its own DataDog-backed adapter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Update pkg/github/dependencies.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fmt

* change to use slog

* address feedback

* rename noop adapter to noop sink

* Update pkg/http/server.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* [WIP] [WIP] Address feedback on OSS logging adapter for http implementation (#2264)

* Initial plan

* Fix BaseDeps.Logger and BaseDeps.Metrics to return safe defaults when Obsv is nil

Agent-Logs-Url: https://github.com/github/github-mcp-server/sessions/53221b0b-abb4-4138-a147-3ce9e13b379a

Co-authored-by: mattdholloway <918573+mattdholloway@users.noreply.github.com>

* Fix nil metrics in server.go by passing metrics.NewNoopMetrics() to NewExporters

Agent-Logs-Url: https://github.com/github/github-mcp-server/sessions/53221b0b-abb4-4138-a147-3ce9e13b379a

Co-authored-by: mattdholloway <918573+mattdholloway@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mattdholloway <918573+mattdholloway@users.noreply.github.com>
Co-authored-by: Matt Holloway <mattdholloway@github.com>

* replace nil with stubs

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
2026-03-31 13:10:22 +01:00