-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
demo: Add telemetry about usage of new demo features.
This PR adds telemetry for some of the new features added to cockroach demo (nodes, with-load, localities, geo-partitioned-replicas). It isn't straight forward how to test this, as there seems to be a race between the background thread that flushes telemetry and actually querying for the counter's values on startup. Work towards #228. Release justification: Low risk monitoring improvement. Release note: None
- Loading branch information
Rohan Yadav
committed
Sep 18, 2019
1 parent
8e15411
commit c4465cd
Showing
3 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2019 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/server/telemetry" | ||
) | ||
|
||
type demoTelemetry int | ||
|
||
const ( | ||
_ demoTelemetry = iota | ||
nodes | ||
demoLocality | ||
withLoad | ||
geoPartitionedReplicas | ||
) | ||
|
||
var demoTelemetryMap = map[demoTelemetry]string{ | ||
nodes: "nodes", | ||
demoLocality: "demo-locality", | ||
withLoad: "withload", | ||
geoPartitionedReplicas: "geo-partitioned-replicas", | ||
} | ||
|
||
var demoTelemetryCounters map[demoTelemetry]telemetry.Counter | ||
|
||
func init() { | ||
demoTelemetryCounters = make(map[demoTelemetry]telemetry.Counter) | ||
for ty, s := range demoTelemetryMap { | ||
demoTelemetryCounters[ty] = telemetry.GetCounterOnce(fmt.Sprintf("cli.demo.%s", s)) | ||
} | ||
} | ||
|
||
func incrementDemoCounter(d demoTelemetry) { | ||
telemetry.Inc(demoTelemetryCounters[d]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters