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

Fixed tutorial. #1256

Merged
merged 1 commit into from Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion tutorial/whatsup/Makefile
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tutorial/whatsup/internal/acceptance_test.go
Expand Up @@ -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()

Expand Down
7 changes: 7 additions & 0 deletions tutorial/whatsup/internal/common.go
Expand Up @@ -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{}

Expand Down
16 changes: 13 additions & 3 deletions tutorial/whatsup/internal/playground_test.go
Expand Up @@ -19,6 +19,7 @@ package internal
import (
"fmt"
"os"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -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{
Expand Down