dd239d8443
* 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>
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package observability
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
"testing"
|
|
|
|
"github.com/github/github-mcp-server/pkg/observability/metrics"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNewExporters(t *testing.T) {
|
|
logger := slog.Default()
|
|
m := metrics.NewNoopMetrics()
|
|
exp, err := NewExporters(logger, m)
|
|
ctx := context.Background()
|
|
|
|
require.NoError(t, err)
|
|
assert.NotNil(t, exp)
|
|
assert.Equal(t, logger, exp.Logger())
|
|
assert.Equal(t, m, exp.Metrics(ctx))
|
|
}
|
|
|
|
func TestNewExporters_WithNilLogger(t *testing.T) {
|
|
_, err := NewExporters(nil, metrics.NewNoopMetrics())
|
|
require.Error(t, err)
|
|
assert.Contains(t, err.Error(), "logger must not be nil")
|
|
}
|
|
|
|
func TestNewExporters_WithNilMetrics(t *testing.T) {
|
|
_, err := NewExporters(slog.New(slog.DiscardHandler), nil)
|
|
require.Error(t, err)
|
|
assert.Contains(t, err.Error(), "metrics must not be nil")
|
|
}
|
|
|
|
func TestNewExporters_WithDiscardLogger(t *testing.T) {
|
|
logger := slog.New(slog.DiscardHandler)
|
|
m := metrics.NewNoopMetrics()
|
|
exp, err := NewExporters(logger, m)
|
|
|
|
require.NoError(t, err)
|
|
assert.NotNil(t, exp)
|
|
assert.Equal(t, logger, exp.Logger())
|
|
assert.Equal(t, m, exp.Metrics(context.Background()))
|
|
}
|