Skip to content

Commit

Permalink
api client examples: avoid shadowing package with variable
Browse files Browse the repository at this point in the history
Signed-off-by: Beni Cherniavsky-Paskin <[email protected]>
  • Loading branch information
cben committed Dec 9, 2019
1 parent 9097a2c commit 38c6752
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api/prometheus/v1/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func ExampleAPI_query() {
os.Exit(1)
}

api := v1.NewAPI(client)
v1api := v1.NewAPI(client)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
result, warnings, err := api.Query(ctx, "up", time.Now())
result, warnings, err := v1api.Query(ctx, "up", time.Now())
if err != nil {
fmt.Printf("Error querying Prometheus: %v\n", err)
os.Exit(1)
Expand All @@ -57,15 +57,15 @@ func ExampleAPI_queryRange() {
os.Exit(1)
}

api := v1.NewAPI(client)
v1api := v1.NewAPI(client)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
r := v1.Range{
Start: time.Now().Add(-time.Hour),
End: time.Now(),
Step: time.Minute,
}
result, warnings, err := api.QueryRange(ctx, "rate(prometheus_tsdb_head_samples_appended_total[5m])", r)
result, warnings, err := v1api.QueryRange(ctx, "rate(prometheus_tsdb_head_samples_appended_total[5m])", r)
if err != nil {
fmt.Printf("Error querying Prometheus: %v\n", err)
os.Exit(1)
Expand All @@ -85,10 +85,10 @@ func ExampleAPI_series() {
os.Exit(1)
}

api := v1.NewAPI(client)
v1api := v1.NewAPI(client)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
lbls, warnings, err := api.Series(ctx, []string{
lbls, warnings, err := v1api.Series(ctx, []string{
"{__name__=~\"scrape_.+\",job=\"node\"}",
"{__name__=~\"scrape_.+\",job=\"prometheus\"}",
}, time.Now().Add(-time.Hour), time.Now())
Expand Down

0 comments on commit 38c6752

Please sign in to comment.