Skip to content

Explicit forward proxy support for HTTP with Basic Auth #1201

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

Akshay2191
Copy link
Contributor

Proposed changes

Describe the use case and detail of the change. If this PR addresses an issue on GitHub, make sure to include a link to that issue using one of the supported keywords here in this description (not in the title of the PR).

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13

@Akshay2191 Akshay2191 requested a review from a team as a code owner August 7, 2025 16:26
@github-actions github-actions bot added chore Pull requests for routine tasks documentation Improvements or additions to documentation labels Aug 7, 2025
@dhurley dhurley added the v3.x Issues and Pull Requests related to the major version v3 label Aug 8, 2025
proxyURL := proxy.URL
u, err := url.Parse(proxyURL)
if err != nil {
slog.ErrorContext(ctx, "Malformed proxy URL; skipping Proxy setup", "url", proxyURL, "error", err)
Copy link
Collaborator

@dhurley dhurley Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
slog.ErrorContext(ctx, "Malformed proxy URL; skipping Proxy setup", "url", proxyURL, "error", err)
slog.ErrorContext(ctx, "Malformed proxy URL, unable to configure proxy for OTLP exporter", "url", proxyURL, "error", err)

@@ -409,6 +418,14 @@ func (oc *Collector) restartCollector(ctx context.Context) {
}
}

func (oc *Collector) setProxyIfNeeded(ctx context.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be renamed to just setProxy ?

Suggested change
func (oc *Collector) setProxyIfNeeded(ctx context.Context) {
func (oc *Collector) setProxy(ctx context.Context) {

return http.ReadResponse(bufio.NewReader(conn), nil)
}

func wrapProxyError(ctx context.Context, msg string, err error, proxyURL string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to wrap the proxy error ?

@Akshay2191 Akshay2191 requested review from dhurley and aphralG August 11, 2025 11:13
@Akshay2191 Akshay2191 requested a review from dhurley August 20, 2025 13:46
Comment on lines +793 to +794
slog.ErrorContext(ctx, "Unknown auth type for proxy, unable to configure proxy for OTLP exporter",
"auth", auth, "url", proxyURL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
slog.ErrorContext(ctx, "Unknown auth type for proxy, unable to configure proxy for OTLP exporter",
"auth", auth, "url", proxyURL)
slog.ErrorContext(ctx, "Unknown auth type for proxy, unable to configure proxy for OTLP exporter",
"url", proxyURL)

@@ -459,6 +472,14 @@ func (c *Config) NewContextWithLabels(ctx context.Context) context.Context {
return metadata.NewOutgoingContext(ctx, md)
}

func (c *Config) IsCommandServerProxyConfigured() bool {
if c.Command.Server.Proxy == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add nil check for c.Command and c.Command.Server as well?

@@ -338,6 +339,18 @@ type (
ExcludeFiles []string `yaml:"exclude_files" mapstructure:"exclude_files"`
MonitoringFrequency time.Duration `yaml:"monitoring_frequency" mapstructure:"monitoring_frequency"`
}

//nolint:govet // Tried different sequences but not able to fix the lint issue.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @sean-breen had a tool to help fix these I cant remember it though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Pull requests for routine tasks documentation Improvements or additions to documentation v3.x Issues and Pull Requests related to the major version v3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants