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

pkg/debuginfo: Set debuginfod user-agent #2924

Merged
merged 1 commit into from
Apr 4, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/debuginfo/debuginfod.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type DebuginfodClientObjectStorageCache struct {
}

// NewHTTPDebuginfodClient returns a new HTTP debug info client.
func NewHTTPDebuginfodClient(logger log.Logger, serverURLs []string, timeoutDuration time.Duration) (*HTTPDebuginfodClient, error) {
func NewHTTPDebuginfodClient(logger log.Logger, serverURLs []string, client *http.Client) (*HTTPDebuginfodClient, error) {
logger = log.With(logger, "component", "debuginfod")
parsedURLs := make([]*url.URL, 0, len(serverURLs))
for _, serverURL := range serverURLs {
Expand All @@ -79,7 +79,7 @@ func NewHTTPDebuginfodClient(logger log.Logger, serverURLs []string, timeoutDura
return &HTTPDebuginfodClient{
logger: logger,
upstreamServers: parsedURLs,
client: &http.Client{Timeout: timeoutDuration},
client: client,
}, nil
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/debuginfo/debuginfod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ func TestHTTPDebugInfodClientRedirect(t *testing.T) {
}))
defer rs.Close()

c, err := NewHTTPDebuginfodClient(log.NewNopLogger(), []string{rs.URL}, 30*time.Second)
c, err := NewHTTPDebuginfodClient(log.NewNopLogger(), []string{rs.URL}, &http.Client{
Timeout: 30 * time.Second,
})
require.NoError(t, err)

ctx := context.Background()
Expand Down
7 changes: 6 additions & 1 deletion pkg/parca/parca.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"crypto/tls"
"errors"
"fmt"
"net/http"
"os"
"path/filepath"
goruntime "runtime"
Expand All @@ -36,6 +37,7 @@ import (
"github.com/polarsignals/frostdb/dynparquet"
"github.com/polarsignals/frostdb/query"
"github.com/prometheus/client_golang/prometheus"
promconfig "github.com/prometheus/common/config"
"github.com/prometheus/prometheus/discovery"
"github.com/prometheus/prometheus/model/labels"
"github.com/thanos-io/objstore"
Expand Down Expand Up @@ -341,7 +343,10 @@ func Run(ctx context.Context, logger log.Logger, reg *prometheus.Registry, flags

var debuginfodClient debuginfo.DebuginfodClient = debuginfo.NopDebuginfodClient{}
if len(flags.Debuginfod.UpstreamServers) > 0 {
httpDebugInfoClient, err := debuginfo.NewHTTPDebuginfodClient(logger, flags.Debuginfod.UpstreamServers, flags.Debuginfod.HTTPRequestTimeout)
httpDebugInfoClient, err := debuginfo.NewHTTPDebuginfodClient(logger, flags.Debuginfod.UpstreamServers, &http.Client{
Transport: promconfig.NewUserAgentRoundTripper(fmt.Sprintf("parca.dev/debuginfod-client/%s", version), http.DefaultTransport),
Timeout: flags.Debuginfod.HTTPRequestTimeout,
})
if err != nil {
level.Error(logger).Log("msg", "failed to initialize debuginfod http client", "err", err)
return err
Expand Down