()
| 29 | ) |
| 30 | |
| 31 | func ExampleAPI_query() { |
| 32 | client, err := api.NewClient(api.Config{ |
| 33 | Address: "http://demo.robustperception.io:9090", |
| 34 | }) |
| 35 | if err != nil { |
| 36 | fmt.Printf("Error creating client: %v\n", err) |
| 37 | os.Exit(1) |
| 38 | } |
| 39 | |
| 40 | v1api := v1.NewAPI(client) |
| 41 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) |
| 42 | defer cancel() |
| 43 | result, warnings, err := v1api.Query(ctx, "up", time.Now(), v1.WithTimeout(5*time.Second)) |
| 44 | if err != nil { |
| 45 | fmt.Printf("Error querying Prometheus: %v\n", err) |
| 46 | os.Exit(1) |
| 47 | } |
| 48 | if len(warnings) > 0 { |
| 49 | fmt.Printf("Warnings: %v\n", warnings) |
| 50 | } |
| 51 | fmt.Printf("Result:\n%v\n", result) |
| 52 | } |
| 53 | |
| 54 | func ExampleAPI_queryRange() { |
| 55 | client, err := api.NewClient(api.Config{ |
nothing calls this directly
no test coverage detected