Skip to content

Commit

Permalink
feat: add test config option to disable metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Jun 25, 2024
1 parent 316f53c commit 16d71e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,15 @@ func setupGatewayHandler(cfg Config, nd *Node, tracingAuth string) (http.Handler
NoDNSLink: noDNSLink,
}
gwHandler := gateway.NewHandler(gwConf, backend)
ipfsHandler := withHTTPMetrics(gwHandler, "ipfs")
ipnsHandler := withHTTPMetrics(gwHandler, "ipns")

var ipfsHandler, ipnsHandler http.Handler
if cfg.disableMetrics {
ipfsHandler = gwHandler
ipnsHandler = gwHandler
} else {
ipfsHandler = withHTTPMetrics(gwHandler, "ipfs")
ipnsHandler = withHTTPMetrics(gwHandler, "ipns")
}

topMux := http.NewServeMux()
topMux.Handle("/ipfs/", ipfsHandler)
Expand Down
2 changes: 2 additions & 0 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ type Config struct {

GCInterval time.Duration
GCThreshold float64

disableMetrics bool // only meant to be used during testing
}

func SetupNoLibp2p(ctx context.Context, cfg Config, dnsCache *cachedDNS) (*Node, error) {
Expand Down

0 comments on commit 16d71e2

Please sign in to comment.