Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 2cd8b33

Browse files
committed
shield "meta information" via verbose flag
1 parent ce20ca5 commit 2cd8b33

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

cmd/mt-store-cat/main.go

+22-8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var (
3737
printTs = flag.Bool("print-ts", false, "print time stamps instead of formatted dates. only for points and point-summary format")
3838
groupTTL = flag.String("groupTTL", "d", "group chunks in TTL buckets: s (second. means unbucketed), m (minute), h (hour) or d (day). only for chunk-summary format")
3939
timeZoneStr = flag.String("time-zone", "local", "time-zone to use for interpreting from/to when needed. (check your config)")
40+
verbose bool
4041

4142
printTime func(ts uint32) string
4243
)
@@ -46,6 +47,7 @@ func init() {
4647
formatter.TimestampFormat = "2006-01-02 15:04:05.000"
4748
log.SetFormatter(formatter)
4849
log.SetLevel(log.InfoLevel)
50+
flag.BoolVar(&verbose, "verbose", false, "verbose (print stuff about the request)")
4951
}
5052

5153
func main() {
@@ -235,7 +237,9 @@ func main() {
235237
}
236238
var metrics []Metric
237239
if metricSelector == "*" {
238-
fmt.Println("# Looking for ALL metrics")
240+
if verbose {
241+
fmt.Println("# Looking for ALL metrics")
242+
}
239243
// chunk-summary doesn't need an explicit listing. it knows if metrics is empty, to query all
240244
// but the other two do need an explicit listing.
241245
if format == "points" || format == "point-summary" {
@@ -256,14 +260,18 @@ func main() {
256260
if strings.HasPrefix(metricSelector, "glob:") {
257261
glob = strings.Replace(metricSelector, "glob:", "", 1)
258262
}
259-
fmt.Println("# Looking for these metrics:")
263+
if verbose {
264+
fmt.Println("# Looking for these metrics:")
265+
}
260266
metrics, err = getMetrics(store, prefix, substr, glob)
261267
if err != nil {
262268
log.Errorf("cassandra query error. %s", err.Error())
263269
return
264270
}
265-
for _, m := range metrics {
266-
fmt.Println(m)
271+
if verbose {
272+
for _, m := range metrics {
273+
fmt.Println(m)
274+
}
267275
}
268276
} else {
269277
amkey, err := schema.AMKeyFromString(metricSelector)
@@ -272,7 +280,9 @@ func main() {
272280
return
273281
}
274282

275-
fmt.Println("# Looking for this metric:")
283+
if verbose {
284+
fmt.Println("# Looking for this metric:")
285+
}
276286

277287
metrics, err = getMetric(store, amkey)
278288
if err != nil {
@@ -283,12 +293,16 @@ func main() {
283293
fmt.Printf("metric id %v not found", amkey.MKey)
284294
return
285295
}
286-
for _, m := range metrics {
287-
fmt.Println(m)
296+
if verbose {
297+
for _, m := range metrics {
298+
fmt.Println(m)
299+
}
288300
}
289301
}
290302

291-
fmt.Printf("# Keyspace %q:\n", storeConfig.Keyspace)
303+
if verbose {
304+
fmt.Printf("# Keyspace %q:\n", storeConfig.Keyspace)
305+
}
292306

293307
span := tracer.StartSpan("mt-store-cat " + format)
294308
ctx := opentracing.ContextWithSpan(context.Background(), span)

0 commit comments

Comments
 (0)