Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: outlineMetrics implements prometheus.Collector #201

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cmd/outline-ss-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type SSServer struct {
stopConfig func() error
lnManager service.ListenerManager
natTimeout time.Duration
m *outlineMetrics
m *outlineMetricsCollector
replayCache service.ReplayCache
}

Expand Down Expand Up @@ -243,7 +243,7 @@ func (s *SSServer) Stop() error {
}

// RunSSServer starts a shadowsocks server running, and returns the server or an error.
func RunSSServer(filename string, natTimeout time.Duration, sm *outlineMetrics, replayHistory int) (*SSServer, error) {
func RunSSServer(filename string, natTimeout time.Duration, sm *outlineMetricsCollector, replayHistory int) (*SSServer, error) {
server := &SSServer{
lnManager: service.NewListenerManager(),
natTimeout: natTimeout,
Expand Down Expand Up @@ -348,9 +348,11 @@ func main() {
}
defer ip2info.Close()

m := newPrometheusOutlineMetrics(ip2info, prometheus.DefaultRegisterer)
m.SetBuildInfo(version)
_, err = RunSSServer(flags.ConfigFile, flags.natTimeout, m, flags.replayHistory)
metrics := newPrometheusOutlineMetrics(ip2info)
metrics.SetBuildInfo(version)
r := prometheus.WrapRegistererWithPrefix("shadowsocks_", prometheus.DefaultRegisterer)
r.MustRegister(metrics)
_, err = RunSSServer(flags.ConfigFile, flags.natTimeout, metrics, flags.replayHistory)
if err != nil {
slog.Error("Server failed to start. Aborting.", "err", err)
}
Expand Down
Loading
Loading