HTRACE-295. htraced: setting span.expiry.ms to 0 should disable span expiry (cmccabe)
diff --git a/htrace-htraced/go/src/org/apache/htrace/conf/config_keys.go b/htrace-htraced/go/src/org/apache/htrace/conf/config_keys.go
index ed809f9..d10f3af 100644
--- a/htrace-htraced/go/src/org/apache/htrace/conf/config_keys.go
+++ b/htrace-htraced/go/src/org/apache/htrace/conf/config_keys.go
@@ -98,7 +98,7 @@
HTRACE_LOG_LEVEL: "INFO",
HTRACE_METRICS_HEARTBEAT_PERIOD_MS: fmt.Sprintf("%d", 45*1000),
HTRACE_METRICS_MAX_ADDR_ENTRIES: "100000",
- HTRACE_SPAN_EXPIRY_MS: fmt.Sprintf("%d", 3*24*60*60*1000),
+ HTRACE_SPAN_EXPIRY_MS: "0",
HTRACE_REAPER_HEARTBEAT_PERIOD_MS: fmt.Sprintf("%d", 90*1000),
}
@@ -108,5 +108,6 @@
HTRACE_HRPC_ADDRESS: ":0", // use a random port for the HRPC server
HTRACE_LOG_LEVEL: "TRACE", // show all log messages in tests
HTRACE_WEB_ADDRESS: ":0", // use a random port for the REST server
+ HTRACE_SPAN_EXPIRY_MS:"0", // never time out spans (unless testing the reaper)
}
}
diff --git a/htrace-htraced/go/src/org/apache/htrace/htraced/datastore.go b/htrace-htraced/go/src/org/apache/htrace/htraced/datastore.go
index 749b5ab..d0296c3 100644
--- a/htrace-htraced/go/src/org/apache/htrace/htraced/datastore.go
+++ b/htrace-htraced/go/src/org/apache/htrace/htraced/datastore.go
@@ -79,6 +79,10 @@
const PARENT_ID_INDEX_PREFIX = 'p'
const INVALID_INDEX_PREFIX = 0
+// The maximum span expiry time, in milliseconds.
+// For all practical purposes this is "never" since it's more than a million years.
+const MAX_SPAN_EXPIRY_MS = 0x7ffffffffffffff
+
type IncomingSpan struct {
// The address that the span was sent from.
Addr string
@@ -360,6 +364,11 @@
heartbeats: make(chan interface{}, 1),
exited: make(chan interface{}),
}
+ if rpr.spanExpiryMs >= MAX_SPAN_EXPIRY_MS {
+ rpr.spanExpiryMs = MAX_SPAN_EXPIRY_MS
+ } else if rpr.spanExpiryMs <= 0 {
+ rpr.spanExpiryMs = MAX_SPAN_EXPIRY_MS
+ }
rpr.hb = NewHeartbeater("ReaperHeartbeater",
cnf.GetInt64(conf.HTRACE_REAPER_HEARTBEAT_PERIOD_MS), rpr.lg)
go rpr.run()
@@ -367,6 +376,13 @@
name: "reaper",
targetChan: rpr.heartbeats,
})
+ var when string
+ if rpr.spanExpiryMs >= MAX_SPAN_EXPIRY_MS {
+ when = "never"
+ } else {
+ when = "after " + time.Duration(rpr.spanExpiryMs).String()
+ }
+ rpr.lg.Infof("Initializing span reaper: span time out = %s.\n", when)
return rpr
}