Skip to content

Commit

Permalink
Merge pull request #1875 from influxdb/raft_log_trace
Browse files Browse the repository at this point in the history
Support control of Raft debug logging
  • Loading branch information
otoolep committed Mar 9, 2015
2 parents 71ec2bb + d802829 commit c714f14
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
- [#1862](https://github.com/influxdb/influxdb/pull/1862): Fix memory leak in `httpd.serveWait`. Thanks @mountkin
- [#1868](https://github.com/influxdb/influxdb/pull/1868): Use `BatchPoints` for `client.Write` method. Thanks @vladlopes, @georgmu, @d2g, @evanphx, @akolosov.

### Features
- [#1875](https://github.com/influxdb/influxdb/pull/1875): Support trace logging of Raft.

## v0.9.0-rc9 [2015-03-06]

### Bugfixes
Expand Down
5 changes: 3 additions & 2 deletions cmd/influxd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ type Config struct {
} `toml:"cluster"`

Logging struct {
File string `toml:"file"`
WriteTraceEnabled bool `toml:"write-tracing"`
File string `toml:"file"`
WriteTracing bool `toml:"write-tracing"`
RaftTracing bool `toml:"raft-tracing"`
} `toml:"logging"`

ContinuousQuery struct {
Expand Down
1 change: 1 addition & 0 deletions cmd/influxd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ enabled = true
[logging]
file = "influxdb.log"
write-tracing = true
raft-tracing = true
# Configure the admin server
[admin]
Expand Down
7 changes: 5 additions & 2 deletions cmd/influxd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func Run(config *Config, join, version string, logWriter *os.File) (*messaging.B
// Open broker, initialize or join as necessary.
b := openBroker(config.BrokerDir(), config.BrokerURL(), initBroker, joinURLs, logWriter)

// Configure debug of Raft module.
b.EnableRaftDebug(config.Logging.RaftTracing)

// Start the broker handler.
var h *Handler
if b != nil {
Expand Down Expand Up @@ -90,7 +93,7 @@ func Run(config *Config, join, version string, logWriter *os.File) (*messaging.B
if s != nil {
sh := httpd.NewHandler(s, config.Authentication.Enabled, version)
sh.SetLogOutput(logWriter)
sh.WriteTrace = config.Logging.WriteTraceEnabled
sh.WriteTrace = config.Logging.WriteTracing

if h != nil && config.BrokerAddr() == config.DataAddr() {
h.serverHandler = sh
Expand Down Expand Up @@ -267,7 +270,7 @@ func openServer(config *Config, b *influxdb.Broker, initServer, initBroker, conf
// Create and open the server.
s := influxdb.NewServer()
s.SetLogOutput(w)
s.WriteTrace = config.Logging.WriteTraceEnabled
s.WriteTrace = config.Logging.WriteTracing
s.RecomputePreviousN = config.ContinuousQuery.RecomputePreviousN
s.RecomputeNoOlderThan = time.Duration(config.ContinuousQuery.RecomputeNoOlderThan)
s.ComputeRunsPerInterval = config.ContinuousQuery.ComputeRunsPerInterval
Expand Down
1 change: 1 addition & 0 deletions etc/config.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ dir = "/tmp/influxdb/development/state"
[logging]
file = "/var/log/influxdb/influxd.log" # Leave blank to redirect logs to stderr.
write-tracing = false # If true, enables detailed logging of the write system.
raft-tracing = false # If true, enables detailed logging of Raft consensus.
5 changes: 5 additions & 0 deletions messaging/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ func (b *Broker) SetLogOutput(w io.Writer) {
b.log.SetLogOutput(w)
}

// EnableRaftDebug controls debugging functionality in the Raft concensus module.
func (b *Broker) EnableRaftDebug(enable bool) {
b.log.DebugEnabled = enable
}

// Open initializes the log.
// The broker then must be initialized or join a cluster before it can be used.
func (b *Broker) Open(path string, u *url.URL) error {
Expand Down

0 comments on commit c714f14

Please sign in to comment.