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

add config option to disable bandwidth metrics #3381

Merged
merged 1 commit into from
Nov 16, 2016
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
5 changes: 5 additions & 0 deletions core/commands/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ Example:
return
}

if nd.Reporter == nil {
res.SetError(fmt.Errorf("bandwidth reporter disabled in config"), cmds.ErrNormal)
return
}

pstr, pfound, err := req.Option("peer").String()
if err != nil {
res.SetError(err, cmds.ErrNormal)
Expand Down
8 changes: 5 additions & 3 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
return err
}

// Set reporter
n.Reporter = metrics.NewBandwidthCounter()

// get undialable addrs from config
cfg, err := n.Repo.Config()
if err != nil {
Expand All @@ -160,6 +157,11 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
addrfilter = append(addrfilter, f)
}

if !cfg.Swarm.DisableBandwidthMetrics {
// Set reporter
n.Reporter = metrics.NewBandwidthCounter()
}

peerhost, err := hostOption(ctx, n.Identity, n.Peerstore, n.Reporter, addrfilter)
if err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,10 @@ Options for configuring the swarm.
An array of address filters (multiaddr netmasks) to filter dials to.
See https:/ipfs/go-ipfs/issues/1226#issuecomment-120494604 for more information.

- `DisableBandwidthMetrics`
A boolean value that when set to true, will cause ipfs to not keep track of
bandwidth metrics. Disabling bandwidth metrics can lead to a slight performance
improvement, as well as a reduction in memory usage.

## `Tour`
Unused.
3 changes: 2 additions & 1 deletion repo/config/swarm.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package config

type SwarmConfig struct {
AddrFilters []string
AddrFilters []string
DisableBandwidthMetrics bool
}