Fixed tutorial. (#1256)

Signed-off-by: bwplotka <bwplotka@gmail.com>
This commit is contained in:
Bartlomiej Plotka 2023-04-21 15:23:45 +02:00 committed by GitHub
parent 90eb83b690
commit 671a2f0568
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 5 deletions

View File

@ -1,4 +1,3 @@
.PHONY: help
help: ## Displays help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-z0-9A-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)

View File

@ -27,7 +27,7 @@ import (
)
func TestAcceptance(t *testing.T) {
resp, err := http.Get(fmt.Sprintf("http://localhost:%v/metrics", WhatsupPort))
resp, err := http.Get(whatsupAddr(fmt.Sprintf("http://localhost:%v", WhatsupPort)) + "/metrics")
testutil.Ok(t, err)
defer resp.Body.Close()

View File

@ -37,6 +37,13 @@ type Config struct {
TraceSamplingRatio float64 `yaml:"TraceSamplingRatio,omitempty"`
}
func whatsupAddr(defAddress string) string {
if a := os.Getenv("HOSTADDR"); a != "" {
return a + ":" + WhatsupPort
}
return defAddress
}
func ParseOptions(args []string) (Config, error) {
c := Config{}

View File

@ -19,6 +19,7 @@ package internal
import (
"fmt"
"os"
"strings"
"testing"
"time"
@ -71,18 +72,27 @@ func TestPlayground(t *testing.T) {
testutil.Ok(t, prom.SetConfig(prometheusConfig(map[string]string{
"prometheus": prom.InternalEndpoint("http"),
"jaeger": jaeger.InternalEndpoint("http.metrics"),
"whatsup": fmt.Sprintf("host.docker.internal:%v", WhatsupPort),
"whatsup": whatsupAddr(fmt.Sprintf("host.docker.internal:%v", WhatsupPort)),
})))
// Due to VM based docker setups (e.g. MacOS), file sharing can be slower - do more sighups just in case (noops if all good)
prom.Exec(e2e.NewCommand("kill", "-SIGHUP", "1"))
prom.Exec(e2e.NewCommand("kill", "-SIGHUP", "1"))
// Best effort.
fmt.Println(e2einteractive.OpenInBrowser("http://" + jaeger.Endpoint("http.front")))
fmt.Println(e2einteractive.OpenInBrowser("http://" + prom.Endpoint("http")))
fmt.Println(e2einteractive.OpenInBrowser(convertToExternal("http://" + jaeger.Endpoint("http.front"))))
fmt.Println(e2einteractive.OpenInBrowser(convertToExternal("http://" + prom.Endpoint("http"))))
testutil.Ok(t, e2einteractive.RunUntilEndpointHitWithPort(19920))
}
func convertToExternal(endpoint string) string {
a := os.Getenv("HOSTADDR")
if a == "" {
return endpoint
}
// YOLO, fix and test.
return fmt.Sprintf("%v:%v", a, strings.Split(endpoint, ":")[2])
}
func prometheusConfig(jobToScrapeTargetAddress map[string]string) promconfig.Config {
h, _ := os.Hostname()
cfg := promconfig.Config{