Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1927)

Side by Side Diff: appengine/tsmon/standardmetrics.go

Issue 2123853002: Added unit annotation supports onto tsmon in go. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Specify the unit of logdog/collector/subscription/processing_time_ms with types.Milliseconds Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/tsmon/middleware_test.go ('k') | client/cmd/luci_machine_tokend/status.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package tsmon 5 package tsmon
6 6
7 import ( 7 import (
8 "golang.org/x/net/context" 8 "golang.org/x/net/context"
9 9
10 "github.com/luci/gae/service/module" 10 "github.com/luci/gae/service/module"
11 "github.com/luci/luci-go/common/logging" 11 "github.com/luci/luci-go/common/logging"
12 "github.com/luci/luci-go/common/tsmon" 12 "github.com/luci/luci-go/common/tsmon"
13 "github.com/luci/luci-go/common/tsmon/metric" 13 "github.com/luci/luci-go/common/tsmon/metric"
14 "github.com/luci/luci-go/common/tsmon/runtimestats" 14 "github.com/luci/luci-go/common/tsmon/runtimestats"
15 "github.com/luci/luci-go/common/tsmon/types"
15 ) 16 )
16 17
17 var ( 18 var (
18 defaultVersion = metric.NewCallbackString( 19 defaultVersion = metric.NewCallbackString(
19 "appengine/default_version", 20 "appengine/default_version",
20 » » "Name of the version currently marked as default.") 21 » » "Name of the version currently marked as default.",
22 » » types.MetricMetadata{})
21 ) 23 )
22 24
23 // collectGlobalMetrics populates service-global metrics. 25 // collectGlobalMetrics populates service-global metrics.
24 // 26 //
25 // Called by tsmon from inside /housekeeping cron handler. Metrics reported must 27 // Called by tsmon from inside /housekeeping cron handler. Metrics reported must
26 // not depend on the state of the particular process that happens to report 28 // not depend on the state of the particular process that happens to report
27 // them. 29 // them.
28 func collectGlobalMetrics(c context.Context) { 30 func collectGlobalMetrics(c context.Context) {
29 version, err := module.Get(c).DefaultVersion("") 31 version, err := module.Get(c).DefaultVersion("")
30 if err != nil { 32 if err != nil {
31 logging.Errorf(c, "Error getting default appengine version: %s", err) 33 logging.Errorf(c, "Error getting default appengine version: %s", err)
32 defaultVersion.Set(c, "(unknown)") 34 defaultVersion.Set(c, "(unknown)")
33 } else { 35 } else {
34 defaultVersion.Set(c, version) 36 defaultVersion.Set(c, version)
35 } 37 }
36 } 38 }
37 39
38 // collectProcessMetrics populates per-process metrics. 40 // collectProcessMetrics populates per-process metrics.
39 // 41 //
40 // It is called by each individual process right before flushing the metrics. 42 // It is called by each individual process right before flushing the metrics.
41 func collectProcessMetrics(c context.Context, s *tsmonSettings) { 43 func collectProcessMetrics(c context.Context, s *tsmonSettings) {
42 if s.ReportRuntimeStats { 44 if s.ReportRuntimeStats {
43 runtimestats.Report(c) 45 runtimestats.Report(c)
44 } 46 }
45 } 47 }
46 48
47 func init() { 49 func init() {
48 tsmon.RegisterGlobalCallback(collectGlobalMetrics, defaultVersion) 50 tsmon.RegisterGlobalCallback(collectGlobalMetrics, defaultVersion)
49 } 51 }
OLDNEW
« no previous file with comments | « appengine/tsmon/middleware_test.go ('k') | client/cmd/luci_machine_tokend/status.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698