ronantakizawa/codereview-bench huggingface dataset:
Repository: prometheus/alertmanager
File: notify/jira/jira_test.go (Go)

Code before:
			err := dec.Decode(&out)
			if err != nil {
				panic(err)
			}
		}
	}))
	defer srv.Close()
	u, _ := url.Parse(srv.URL)

	for _, tc := range []struct {
		title string
		cfg   *config.JiraConfig

		retry  bool
		errMsg string
	}{
		{
			title: "full-blown message",
			cfg: &config.JiraConfig{
				Summary:     `{{ template "jira.default.summary" . }}`,
				Description: `{{ template "jira.default.description" . }}`,
				Fields: map[string]any{
					"customfield_14400": `{{ template "jira.host" . }}`,
				},
			},
			retry: false,
		},
		{
			title: "template project",
			cfg: &config.JiraConfig{
				Project:     `{{ .CommonLabels.lbl1 }}`,
				Summary:     `{{ template "jira.default.summary" . }}`,
				Description: `{{ template "jira.default.description" . }}`,
			},
			retry: false,
		},
		{
			title: "template issue type",
			cfg: &config.JiraConfig{
				IssueType:   `{{ .CommonLabels.lbl1 }}`,
				Summary:     `{{ template "jira.default.summary" . }}`,
				Description: `{{ template "jira.default.description" . }}`,
			},
			retry: false,
		},
		{
			title: "summary with templating errors",
			cfg: &config.JiraConfig{
				Summary: "{{ ",
			},
			errMsg: "template: :1: unclosed action",

Review comment (suggestion):
I think we should add test cases for each of the possible types that can appear in a field. As it is, I'm not sure that the recursive copy is actually being exercised by the tests.

Code after:
			dec := json.NewDecoder(r.Body)
			out := make(map[string]any)
			if err := dec.Decode(&out); err != nil {
				panic(err)
			}
			capturedBody = out
		}
	}))
	defer srv.Close()
	u, _ := url.Parse(srv.URL)

	for _, tc := range []struct {
		title string
		cfg   *config.JiraConfig

		retry              bool
		errMsg             string
		expectedFieldKey   string
		expectedFieldValue any
	}{
		{
			title: "full-blown message with templated custom field",
			cfg: &config.JiraConfig{
				Summary:     `{{ template "jira.default.summary" . }}`,
				Description: `{{ template "jira.default.description" . }}`,
				Fields: map[string]any{
					"customfield_14400": `{{ template "jira.host" . }}`,
				},
			},
			retry:              false,
			expectedFieldKey:   "customfield_14400",
			expectedFieldValue: "host1.example.com",
		},
		{
			title: "template project",
			cfg: &config.JiraConfig{
				Project:     `{{ .CommonLabels.lbl1 }}`,
				Summary:     `{{ template "jira.default.summary" . }}`,
				Description: `{{ template "jira.default.description" . }}`,
			},
			retry: false,
		},
		{
			title: "template issue type",
			cfg: &config.JiraConfig{
				IssueType:   `{{ .CommonLabels.lbl1 }}`,
				Summary:     `{{ template "jira.default.summary" . }}`,
				Description: `{{ template "jira.default.description" . }}`,
			},
			retry: false,
		},
Repository: prometheus/alertmanager
File: notify/discord/discord.go (Go)

Code before:
	}
	return n, nil
}

type webhook struct {
	Content   string         `json:"content"`
	Embeds    []webhookEmbed `json:"embeds"`
	Username  string         `json:"username,omitempty"`
	AvatarURL string         `json:"avatar_url,omitempty"`
}

type webhookEmbed struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	Color       int    `json:"color"`
}

// Notify implements the Notifier interface.
func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error) {
	key, err := notify.ExtractGroupKey(ctx)
	if err != nil {
		return false, err
	}

	n.logger.Debug("extracted group key", "key", key)

	alerts := types.Alerts(as...)
	data := notify.GetTemplateData(ctx, n.tmpl, as, n.logger)
	tmpl := notify.TmplText(n.tmpl, data, &err)
	if err != nil {
		return false, err
	}

	title, truncated := notify.TruncateInRunes(tmpl(n.conf.Title), maxTitleLenRunes)
	if err != nil {
		return false, err
	}
	if truncated {
		n.logger.Warn("Truncated title", "key", key, "max_runes", maxTitleLenRunes)
	}
	description, truncated := notify.TruncateInRunes(tmpl(n.conf.Message), maxDescriptionLenRunes)
	if err != nil {
		return false, err
	}
	if truncated {
		n.logger.Warn("Truncated message", "key", key, "max_runes", maxDescriptionLenRunes)
	}

	content, truncated := notify.TruncateInRunes(tmpl(n.conf.Content), maxContentLenRunes)
	if err != nil {
		return false, err

Review comment (refactor):
Shall we move this inside `notify.ExtractGroupKey()` instead of repeating the same line of code in all integrations?

Code after:
	}
	return n, nil
}

type webhook struct {
	Content   string         `json:"content"`
	Embeds    []webhookEmbed `json:"embeds"`
	Username  string         `json:"username,omitempty"`
	AvatarURL string         `json:"avatar_url,omitempty"`
}

type webhookEmbed struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	Color       int    `json:"color"`
}

// Notify implements the Notifier interface.
func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error) {
	key, err := notify.ExtractGroupKey(ctx)
	if err != nil {
		return false, err
	}

	logger := n.logger.With("group_key", key)
	logger.Debug("extracted group key")

	alerts := types.Alerts(as...)
	data := notify.GetTemplateData(ctx, n.tmpl, as, logger)
	tmpl := notify.TmplText(n.tmpl, data, &err)
	if err != nil {
		return false, err
	}

	title, truncated := notify.TruncateInRunes(tmpl(n.conf.Title), maxTitleLenRunes)
	if err != nil {
		return false, err
	}
	if truncated {
		logger.Warn("Truncated title", "max_runes", maxTitleLenRunes)
	}
	description, truncated := notify.TruncateInRunes(tmpl(n.conf.Message), maxDescriptionLenRunes)
	if err != nil {
		return false, err
	}
	if truncated {
		logger.Warn("Truncated message", "max_runes", maxDescriptionLenRunes)
	}

	content, truncated := notify.TruncateInRunes(tmpl(n.conf.Content), maxContentLenRunes)
	if err != nil {
Repository: prometheus/alertmanager
File: notify/opsgenie/opsgenie_test.go (Go)

Code before:
	require.Equal(t, "https://test-opsgenie-url/v2/alerts", requests[0].URL.String())
	require.NotEmpty(t, body0)

	require.Equal(t, requests[1].URL.String(), fmt.Sprintf("https://test-opsgenie-url/v2/alerts/%s/message?identifierType=alias", alias))
	require.Equal(t, `{"message":"new message"}
`, body1)
	require.Equal(t, requests[2].URL.String(), fmt.Sprintf("https://test-opsgenie-url/v2/alerts/%s/description?identifierType=alias", alias))
	require.Equal(t, `{"description":"new description"}
`, body2)
}

func TestOpsGenieApiKeyFile(t *testing.T) {
	u, err := url.Parse("https://test-opsgenie-url")
	require.NoError(t, err)
	tmpl := test.CreateTmpl(t)
	ctx := context.Background()
	ctx = notify.WithGroupKey(ctx, "1")
	opsGenieConfigWithUpdate := config.OpsGenieConfig{
		APIKeyFile: `./api_key_file`,
		APIURL:     &config.URL{URL: u},
		HTTPConfig: &commoncfg.HTTPClientConfig{},
	}
	notifierWithUpdate, err := New(&opsGenieConfigWithUpdate, tmpl, promslog.NewNopLogger())

	require.NoError(t, err)
	requests, _, err := notifierWithUpdate.createRequests(ctx)
	require.Equal(t, "GenieKey my_secret_api_key", requests[0].Header.Get("Authorization"))
}

func readBody(t *testing.T, r *http.Request) string {
	t.Helper()
	body, err := io.ReadAll(r.Body)
	require.NoError(t, err)
	return string(body)
}


Review comment (bug):
You have a lint error here, as `err` is not checked:

```
ineffectual assignment to err (ineffassign)
```

Code after:
	require.Equal(t, "https://test-opsgenie-url/v2/alerts", requests[0].URL.String())
	require.NotEmpty(t, body0)

	require.Equal(t, requests[1].URL.String(), fmt.Sprintf("https://test-opsgenie-url/v2/alerts/%s/message?identifierType=alias", alias))
	require.Equal(t, `{"message":"new message"}
`, body1)
	require.Equal(t, requests[2].URL.String(), fmt.Sprintf("https://test-opsgenie-url/v2/alerts/%s/description?identifierType=alias", alias))
	require.Equal(t, `{"description":"new description"}
`, body2)
}

func TestOpsGenieApiKeyFile(t *testing.T) {
	u, err := url.Parse("https://test-opsgenie-url")
	require.NoError(t, err)
	tmpl := test.CreateTmpl(t)
	ctx := context.Background()
	ctx = notify.WithGroupKey(ctx, "1")
	opsGenieConfigWithUpdate := config.OpsGenieConfig{
		APIKeyFile: `./api_key_file`,
		APIURL:     &config.URL{URL: u},
		HTTPConfig: &commoncfg.HTTPClientConfig{},
	}
	notifierWithUpdate, err := New(&opsGenieConfigWithUpdate, tmpl, promslog.NewNopLogger())

	require.NoError(t, err)
	requests, _, err := notifierWithUpdate.createRequests(ctx)
	require.NoError(t, err)
	require.Equal(t, "GenieKey my_secret_api_key", requests[0].Header.Get("Authorization"))
}

func readBody(t *testing.T, r *http.Request) string {
	t.Helper()
	body, err := io.ReadAll(r.Body)
	require.NoError(t, err)
	return string(body)
}
Repository: prometheus/alertmanager
File: dispatch/dispatch.go (Go)

Code before:
	for _, alert := range alerts {
		a := *alert
		// Ensure that alerts don't resolve as time move forwards.
		if a.ResolvedAt(now) {
			resolvedSlice = append(resolvedSlice, &a)
		} else {
			a.EndsAt = time.Time{}
		}
		alertsSlice = append(alertsSlice, &a)
	}
	sort.Stable(alertsSlice)

	ag.logger.Debug("flushing", "alerts", fmt.Sprintf("%v", alertsSlice))

	if notify(alertsSlice...) {
		// Delete all resolved alerts as we just sent a notification for them,
		// and we don't want to send another one. However, we need to make sure
		// that each resolved alert has not fired again during the flush as then
		// we would delete an active alert thinking it was resolved.
		if err := ag.alerts.DeleteIfNotModified(resolvedSlice); err != nil {
			ag.logger.Error("error on delete alerts", "err", err)
		}
	}
}

type nilLimits struct{}

func (n nilLimits) MaxNumberOfAggregationGroups() int { return 0 }


Review comment (bug):
Just heads up this is a race condition for the same reason we had to implement `DeleteIfNotModified`. There is a missing check to make sure the deleted alert is the same alert returned from `ag.alerts.Get(alert.Fingerprint())`.

Without this check what can happen is we delete the alert in between `DeletedIfNotModified` and then before we call `Get` a new alert is received. What happens then is we delete the marker of the new alert by mistake. 

Code after:
		now           = time.Now()
	)
	for _, alert := range alerts {
		a := *alert
		// Ensure that alerts don't resolve as time move forwards.
		if a.ResolvedAt(now) {
			resolvedSlice = append(resolvedSlice, &a)
		} else {
			a.EndsAt = time.Time{}
		}
		alertsSlice = append(alertsSlice, &a)
	}
	sort.Stable(alertsSlice)

	ag.logger.Debug("flushing", "alerts", fmt.Sprintf("%v", alertsSlice))

	if notify(alertsSlice...) {
		// Delete all resolved alerts as we just sent a notification for them,
		// and we don't want to send another one. However, we need to make sure
		// that each resolved alert has not fired again during the flush as then
		// we would delete an active alert thinking it was resolved.
		if err := ag.alerts.DeleteIfNotModified(resolvedSlice); err != nil {
			ag.logger.Error("error on delete alerts", "err", err)
		} else {
			// Delete markers for resolved alerts that are not in the store.
			for _, alert := range resolvedSlice {
				_, err := ag.alerts.Get(alert.Fingerprint())
				if errors.Is(err, store.ErrNotFound) {
					ag.marker.Delete(alert.Fingerprint())
				}
			}
		}
	}
}

type nilLimits struct{}

func (n nilLimits) MaxNumberOfAggregationGroups() int { return 0 }
Repository: prometheus/alertmanager
File: notify/sns/sns.go (Go)

Code before:

import (
	"context"
	"errors"
	"fmt"
	"log/slog"
	"net/http"
	"strings"
	"unicode/utf8"

	"github.com/aws/aws-sdk-go-v2/aws"
	awsconfig "github.com/aws/aws-sdk-go-v2/config"
	"github.com/aws/aws-sdk-go-v2/credentials"
	"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
	"github.com/aws/aws-sdk-go-v2/service/sns"
	"github.com/aws/aws-sdk-go-v2/service/sns/types"
	"github.com/aws/aws-sdk-go-v2/service/sts"
	"github.com/aws/smithy-go"
	smithyhttp "github.com/aws/smithy-go/transport/http"

	commoncfg "github.com/prometheus/common/config"

	"github.com/prometheus/alertmanager/config"
	"github.com/prometheus/alertmanager/notify"
	"github.com/prometheus/alertmanager/template"
	amtypes "github.com/prometheus/alertmanager/types"
)

// Notifier implements a Notifier for SNS notifications.
type Notifier struct {
	conf    *config.SNSConfig
	tmpl    *template.Template
	logger  *slog.Logger
	client  *http.Client
	retrier *notify.Retrier
}

// New returns a new SNS notification handler.
func New(c *config.SNSConfig, t *template.Template, l *slog.Logger, httpOpts ...commoncfg.HTTPClientOption) (*Notifier, error) {
	client, err := commoncfg.NewClientFromConfig(*c.HTTPConfig, "sns", httpOpts...)
	if err != nil {
		return nil, err
	}
	return &Notifier{
		conf:    c,
		tmpl:    t,
		logger:  l,
		client:  client,
		retrier: &notify.Retrier{},
	}, nil
}

Review comment (suggestion):
I think it makes more sense to leave this package as `types` and alias the SNS package to something like `snsTypes`

Code after:

import (
	"context"
	"errors"
	"fmt"
	"log/slog"
	"net/http"
	"strings"
	"unicode/utf8"

	"github.com/aws/aws-sdk-go-v2/aws"
	awsconfig "github.com/aws/aws-sdk-go-v2/config"
	"github.com/aws/aws-sdk-go-v2/credentials"
	"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
	"github.com/aws/aws-sdk-go-v2/service/sns"
	snstypes "github.com/aws/aws-sdk-go-v2/service/sns/types"
	"github.com/aws/aws-sdk-go-v2/service/sts"
	"github.com/aws/smithy-go"
	smithyhttp "github.com/aws/smithy-go/transport/http"

	commoncfg "github.com/prometheus/common/config"

	"github.com/prometheus/alertmanager/config"
	"github.com/prometheus/alertmanager/notify"
	"github.com/prometheus/alertmanager/template"
	"github.com/prometheus/alertmanager/types"
)

// Notifier implements a Notifier for SNS notifications.
type Notifier struct {
	conf    *config.SNSConfig
	tmpl    *template.Template
	logger  *slog.Logger
	client  *http.Client
	retrier *notify.Retrier
}

// New returns a new SNS notification handler.
func New(c *config.SNSConfig, t *template.Template, l *slog.Logger, httpOpts ...commoncfg.HTTPClientOption) (*Notifier, error) {
	client, err := commoncfg.NewClientFromConfig(*c.HTTPConfig, "sns", httpOpts...)
	if err != nil {
		return nil, err
	}
	return &Notifier{
		conf:    c,
		tmpl:    t,
		logger:  l,
		client:  client,
		retrier: &notify.Retrier{},
	}, nil
}
Repository: prometheus/alertmanager
File: cluster/cluster.go (Go)

Code before:
// Copyright Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cluster

import (
	"context"
	"errors"
	"fmt"
	"log/slog"
	"math/rand"
	"net"
	"sort"
	"strconv"
	"strings"
	"sync"

Review comment (security):
```suggestion
// Copyright The Prometheus Authors
```

Code after:
// Copyright The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cluster

import (
	"context"
	"errors"
	"fmt"
	"log/slog"
	"math/rand"
	"net"
	"sort"
	"strconv"
	"strings"
	"sync"
Repository: prometheus/alertmanager
File: ui/web.go (Go)

Code before:
	r.Get("/-/ready", func(w http.ResponseWriter, _ *http.Request) {
		w.WriteHeader(http.StatusOK)
		fmt.Fprintf(w, "OK")
	})
	r.Head("/-/ready", func(w http.ResponseWriter, _ *http.Request) {
		w.WriteHeader(http.StatusOK)
	})

	r.Get("/debug/*subpath", func(w http.ResponseWriter, req *http.Request) {
		subpath := route.Param(req.Context(), "subpath")
		req.URL.Path = path.Join("/debug", subpath)
		// path.Join removes trailing slashes, but some pprof handlers expect them.
		if strings.HasSuffix(subpath, "/") && !strings.HasSuffix(req.URL.Path, "/") {
			req.URL.Path += "/"
		}
		http.DefaultServeMux.ServeHTTP(w, req)
	})
	r.Post("/debug/*subpath", func(w http.ResponseWriter, req *http.Request) {
		subpath := route.Param(req.Context(), "subpath")
		req.URL.Path = path.Join("/debug", subpath)
		// path.Join removes trailing slashes, but some pprof handlers expect them.
		if strings.HasSuffix(subpath, "/") && !strings.HasSuffix(req.URL.Path, "/") {
			req.URL.Path += "/"
		}
		http.DefaultServeMux.ServeHTTP(w, req)
	})
}

func disableCaching(w http.ResponseWriter) {
	w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
	w.Header().Set("Pragma", "no-cache")
	w.Header().Set("Expires", "0") // Prevent proxies from caching.
}


Review comment (refactor):
Let's avoid duplicate code, we can define a function and then use it for both `get` and `post` handlers.

Code after:
	r.Get("/-/ready", func(w http.ResponseWriter, _ *http.Request) {
		w.WriteHeader(http.StatusOK)
		fmt.Fprintf(w, "OK")
	})
	r.Head("/-/ready", func(w http.ResponseWriter, _ *http.Request) {
		w.WriteHeader(http.StatusOK)
	})

	debugHandlerFunc := func(w http.ResponseWriter, req *http.Request) {
		subpath := route.Param(req.Context(), "subpath")
		req.URL.Path = path.Join("/debug", subpath)
		// path.Join removes trailing slashes, but some pprof handlers expect them.
		if strings.HasSuffix(subpath, "/") && !strings.HasSuffix(req.URL.Path, "/") {
			req.URL.Path += "/"
		}
		http.DefaultServeMux.ServeHTTP(w, req)
	}
	r.Get("/debug/*subpath", debugHandlerFunc)
	r.Post("/debug/*subpath", debugHandlerFunc)
}

func disableCaching(w http.ResponseWriter) {
	w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
	w.Header().Set("Pragma", "no-cache")
	w.Header().Set("Expires", "0") // Prevent proxies from caching.
}
Repository: prometheus/alertmanager
File: ui/web_test.go (Go)

Code before:
// Copyright 2015 Prometheus Team
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ui

import (
	"log/slog"
	"net/http"
	"net/http/httptest"
	"os"
	"testing"

	"github.com/prometheus/common/route"
)

func TestDebugHandlersWithRoutePrefix(t *testing.T) {

Review comment (security):
Let's use the new copyright header:
```suggestion
// Copyright The Prometheus Authors
```

Also update `web.go` header please.

Code after:
// Copyright The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ui

import (
	"log/slog"
	"net/http"
	"net/http/httptest"
	"os"
	"testing"

	"github.com/prometheus/common/route"
	"github.com/stretchr/testify/require"
)
Repository: prometheus/alertmanager
File: ui/web_test.go (Go)

Code before:
	"log/slog"
	"net/http"
	"net/http/httptest"
	"os"
	"testing"

	"github.com/prometheus/common/route"
)

func TestDebugHandlersWithRoutePrefix(t *testing.T) {
	logger := slog.New(slog.NewTextHandler(os.Stderr, nil))
	reloadCh := make(chan chan error)

	// Test with route prefix
	routePrefix := "/prometheus/alertmanager"
	router := route.New().WithPrefix(routePrefix)
	Register(router, reloadCh, logger)

	// Test GET request to pprof index (note: pprof index returns text/html)
	req := httptest.NewRequest("GET", routePrefix+"/debug/pprof/", nil)
	w := httptest.NewRecorder()
	router.ServeHTTP(w, req)

	if w.Code != http.StatusOK {
		t.Errorf("Expected status %d for %s, got %d. Body: %s", http.StatusOK, req.URL.Path, w.Code, w.Body.String())
	}
	if w.Body.Len() == 0 {
		t.Error("Expected non-empty response body for pprof index")
	}

	// Test GET request to pprof heap endpoint
	req = httptest.NewRequest("GET", routePrefix+"/debug/pprof/heap", nil)
	w = httptest.NewRecorder()
	router.ServeHTTP(w, req)

	if w.Code != http.StatusOK {
		t.Errorf("Expected status %d for %s, got %d", http.StatusOK, req.URL.Path, w.Code)
	}

	// Test without route prefix (should also work)
	router2 := route.New()
	Register(router2, reloadCh, logger)

	req = httptest.NewRequest("GET", "/debug/pprof/", nil)
	w = httptest.NewRecorder()
	router2.ServeHTTP(w, req)

	if w.Code != http.StatusOK {
		t.Errorf("Expected status %d for %s without prefix, got %d", http.StatusOK, req.URL.Path, w.Code)
	}
}

Review comment (suggestion):
Let's use `github.com/stretchr/testify/require` instead of all the `if` statements in tests.
I expected the linter to catch these but it did not.

Code after:
	"log/slog"
	"net/http"
	"net/http/httptest"
	"os"
	"testing"

	"github.com/prometheus/common/route"
	"github.com/stretchr/testify/require"
)

func TestDebugHandlersWithRoutePrefix(t *testing.T) {
	logger := slog.New(slog.NewTextHandler(os.Stderr, nil))
	reloadCh := make(chan chan error)

	// Test with route prefix
	routePrefix := "/prometheus/alertmanager"
	router := route.New().WithPrefix(routePrefix)
	Register(router, reloadCh, logger)

	// Test GET request to pprof index (note: pprof index returns text/html)
	req := httptest.NewRequest("GET", routePrefix+"/debug/pprof/", nil)
	w := httptest.NewRecorder()
	router.ServeHTTP(w, req)

	require.Equal(t, http.StatusOK, w.Code)
	require.Contains(t, w.Body.String(), "/debug/pprof/", "pprof page did not load with expected content when using a route prefix")

	// Test GET request to pprof heap endpoint
	req = httptest.NewRequest("GET", routePrefix+"/debug/pprof/heap", nil)
	w = httptest.NewRecorder()
	router.ServeHTTP(w, req)

	require.Equal(t, http.StatusOK, w.Code)

	// Test without route prefix (should also work)
	router2 := route.New()
	Register(router2, reloadCh, logger)

	req = httptest.NewRequest("GET", "/debug/pprof/", nil)
	w = httptest.NewRecorder()
	router2.ServeHTTP(w, req)

	require.Equal(t, http.StatusOK, w.Code)
	require.Contains(t, w.Body.String(), "/debug/pprof/", "pprof page did not load with expected content")
}