Skip to content

Commit

Permalink
fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wildum committed Nov 3, 2023
1 parent 8da0b4b commit 7ce98c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
9 changes: 8 additions & 1 deletion integration-tests/configs/prom-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ func main() {
listenAddress := fmt.Sprintf("%s:%s", address, port)
http.Handle("/metrics", promhttp.Handler())
server := &http.Server{Addr: listenAddress, Handler: nil}
defer server.Shutdown(context.Background())
defer func() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

if err := server.Shutdown(ctx); err != nil {
log.Fatalf("Server shutdown error: %v", err)
}
}()
log.Printf("HTTP server on %s", listenAddress)

go func() { log.Fatal(server.ListenAndServe()) }()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

const promURL = "http://localhost:9009/prometheus/api/v1/query?query="

func metricQuery(metricName, testName string) string {
return fmt.Sprintf("%s%s{test_name='%s'}", promURL, metricName, testName)
func metricQuery(metricName string) string {
return fmt.Sprintf("%s%s{test_name='scrape_prom_metrics'}", promURL, metricName)
}

func TestScrapePromMetrics(t *testing.T) {
Expand All @@ -20,10 +20,10 @@ func TestScrapePromMetrics(t *testing.T) {
metric string
}{
// TODO: better differentiate these metric types?
{metricQuery("golang_counter", "scrape_prom_metrics"), "golang_counter"},
{metricQuery("golang_gauge", "scrape_prom_metrics"), "golang_gauge"},
{metricQuery("golang_histogram_bucket", "scrape_prom_metrics"), "golang_histogram_bucket"},
{metricQuery("golang_summary", "scrape_prom_metrics"), "golang_summary"},
{metricQuery("golang_counter"), "golang_counter"},
{metricQuery("golang_gauge"), "golang_gauge"},
{metricQuery("golang_histogram_bucket"), "golang_histogram_bucket"},
{metricQuery("golang_summary"), "golang_summary"},
}

for _, tt := range tests {
Expand All @@ -35,7 +35,7 @@ func TestScrapePromMetrics(t *testing.T) {
}
t.Run("golang_native_histogram", func(t *testing.T) {
t.Parallel()
assertHistogramData(t, metricQuery("golang_native_histogram", "scrape_prom_metrics"), "golang_native_histogram")
assertHistogramData(t, metricQuery("golang_native_histogram"), "golang_native_histogram")
})
}

Expand Down

0 comments on commit 7ce98c5

Please sign in to comment.