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

Adjust number of histogram buckets #1248

Merged
merged 2 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2241,7 +2241,7 @@ var MetricDefs = map[ServiceIdx]map[int]metricDefinition{
ActivityInfoSize: {metricName: "activity_info_size", metricType: Timer},
TimerInfoSize: {metricName: "timer_info_size", metricType: Timer},
ChildInfoSize: {metricName: "child_info_size", metricType: Timer},
SignalInfoSize: {metricName: "signal_info", metricType: Timer},
SignalInfoSize: {metricName: "signal_info_size", metricType: Timer},
BufferedEventsSize: {metricName: "buffered_events_size", metricType: Timer},
ActivityInfoCount: {metricName: "activity_info_count", metricType: Timer},
TimerInfoCount: {metricName: "timer_info_count", metricType: Timer},
Expand Down
41 changes: 37 additions & 4 deletions common/service/config/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import (
statsdreporter "go.temporal.io/server/common/metrics/tally/statsd"
)

const (
ms = float64(time.Millisecond / time.Second)
)

// tally sanitizer options that satisfy both Prometheus and M3 restrictions.
// This will rename metrics at the tally emission level, so metrics name we
// use maybe different from what gets emitted. In the current implementation
Expand All @@ -64,6 +68,28 @@ var (
},
ReplacementCharacter: tally.DefaultReplacementCharacter,
}

defaultHistogramBuckets = tally.ValueBuckets([]float64{
1 * ms,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for * ms. Golang guys will bow for this 🙇‍♂️.

2 * ms,
5 * ms,
10 * ms,
20 * ms,
50 * ms,
100 * ms,
200 * ms,
500 * ms,
1000 * ms,
2000 * ms,
5000 * ms,
10000 * ms,
20000 * ms,
50000 * ms,
100000 * ms,
200000 * ms,
500000 * ms,
1000000 * ms,
})
)

// NewScope builds a new tally scope
Expand Down Expand Up @@ -96,7 +122,11 @@ func (c *Metrics) NewScope(logger log.Logger, customReporter tally.BaseStatsRepo
}

func (c *Metrics) newCustomReporterScope(logger log.Logger, customReporter tally.BaseStatsReporter) tally.Scope {
options := tally.ScopeOptions{Tags: c.Tags, Prefix: c.Prefix}
options := tally.ScopeOptions{
Tags: c.Tags,
Prefix: c.Prefix,
DefaultBuckets: defaultHistogramBuckets,
}
switch reporter := customReporter.(type) {
case tally.StatsReporter:
{
Expand Down Expand Up @@ -129,6 +159,7 @@ func (c *Metrics) newM3Scope(logger log.Logger) tally.Scope {
Tags: c.Tags,
CachedReporter: reporter,
Prefix: c.Prefix,
DefaultBuckets: defaultHistogramBuckets,
}
scope, _ := tally.NewRootScope(scopeOpts, time.Second)
return scope
Expand All @@ -149,9 +180,10 @@ func (c *Metrics) newStatsdScope(logger log.Logger) tally.Scope {
// Therefore, we implement Tally interface to have a statsd reporter that can support tagging
reporter := statsdreporter.NewReporter(statter, tallystatsdreporter.Options{})
scopeOpts := tally.ScopeOptions{
Tags: c.Tags,
Reporter: reporter,
Prefix: c.Prefix,
Tags: c.Tags,
Reporter: reporter,
Prefix: c.Prefix,
DefaultBuckets: defaultHistogramBuckets,
}
scope, _ := tally.NewRootScope(scopeOpts, time.Second)
return scope
Expand All @@ -177,6 +209,7 @@ func (c *Metrics) newPrometheusScope(logger log.Logger) tally.Scope {
Separator: prometheus.DefaultSeparator,
SanitizeOptions: &sanitizeOptions,
Prefix: c.Prefix,
DefaultBuckets: defaultHistogramBuckets,
}
scope, _ := tally.NewRootScope(scopeOpts, time.Second)
return scope
Expand Down