Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update example test #1770

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions api/prometheus/v1/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ import (
v1 "github.com/prometheus/client_golang/api/prometheus/v1"
)

const DemoPrometheusURL = "https://demo.prometheus.io:443"

func ExampleAPI_query() {
client, err := api.NewClient(api.Config{
Address: "http://demo.robustperception.io:9090",
Address: DemoPrometheusURL,
})
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
Expand All @@ -53,7 +55,7 @@ func ExampleAPI_query() {

func ExampleAPI_queryRange() {
client, err := api.NewClient(api.Config{
Address: "http://demo.robustperception.io:9090",
Address: DemoPrometheusURL,
})
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
Expand Down Expand Up @@ -104,7 +106,7 @@ func (u userAgentRoundTripper) RoundTrip(r *http.Request) (*http.Response, error

func ExampleAPI_queryRangeWithUserAgent() {
client, err := api.NewClient(api.Config{
Address: "http://demo.robustperception.io:9090",
Address: DemoPrometheusURL,
RoundTripper: userAgentRoundTripper{name: "Client-Golang", rt: api.DefaultRoundTripper},
})
if err != nil {
Expand Down Expand Up @@ -133,7 +135,7 @@ func ExampleAPI_queryRangeWithUserAgent() {

func ExampleAPI_queryRangeWithBasicAuth() {
client, err := api.NewClient(api.Config{
Address: "http://demo.robustperception.io:9090",
Address: DemoPrometheusURL,
// We can use amazing github.com/prometheus/common/config helper!
RoundTripper: config.NewBasicAuthRoundTripper(
config.NewInlineSecret("me"),
Expand Down Expand Up @@ -167,7 +169,7 @@ func ExampleAPI_queryRangeWithBasicAuth() {

func ExampleAPI_queryRangeWithAuthBearerToken() {
client, err := api.NewClient(api.Config{
Address: "http://demo.robustperception.io:9090",
Address: DemoPrometheusURL,
// We can use amazing github.com/prometheus/common/config helper!
RoundTripper: config.NewAuthorizationCredentialsRoundTripper(
"Bearer",
Expand Down Expand Up @@ -201,7 +203,7 @@ func ExampleAPI_queryRangeWithAuthBearerToken() {

func ExampleAPI_queryRangeWithAuthBearerTokenHeadersRoundTripper() {
client, err := api.NewClient(api.Config{
Address: "http://demo.robustperception.io:9090",
Address: DemoPrometheusURL,
// We can use amazing github.com/prometheus/common/config helper!
RoundTripper: config.NewHeadersRoundTripper(
&config.Headers{
Expand Down Expand Up @@ -240,7 +242,7 @@ func ExampleAPI_queryRangeWithAuthBearerTokenHeadersRoundTripper() {

func ExampleAPI_series() {
client, err := api.NewClient(api.Config{
Address: "http://demo.robustperception.io:9090",
Address: DemoPrometheusURL,
})
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
Expand Down
Loading