Repository: incubator-htrace Updated Branches: refs/heads/master 112e6684a -> c2defc7a0
HTRACE-295. htraced: setting span.expiry.ms to 0 should disable span expiry (cmccabe) Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/c2defc7a Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/c2defc7a Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/c2defc7a Branch: refs/heads/master Commit: c2defc7a0cf3781b95f992b5ada2a76515ab35d6 Parents: 112e668 Author: Colin P. Mccabe <[email protected]> Authored: Thu Nov 12 12:37:59 2015 -0800 Committer: Colin P. Mccabe <[email protected]> Committed: Thu Nov 12 12:37:59 2015 -0800 ---------------------------------------------------------------------- .../go/src/org/apache/htrace/conf/config_keys.go | 3 ++- .../go/src/org/apache/htrace/htraced/datastore.go | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/c2defc7a/htrace-htraced/go/src/org/apache/htrace/conf/config_keys.go ---------------------------------------------------------------------- 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 @@ var DEFAULTS = map[string]string{ 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 @@ func TEST_VALUES() map[string]string { 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) } } http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/c2defc7a/htrace-htraced/go/src/org/apache/htrace/htraced/datastore.go ---------------------------------------------------------------------- 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 DURATION_INDEX_PREFIX = 'd' 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 @@ func NewReaper(cnf *conf.Config) *Reaper { 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 @@ func NewReaper(cnf *conf.Config) *Reaper { 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 }
