Skip to content

feat(go-forwarder): add proxy and custom compression level#1140

Open
ndakkoune wants to merge 5 commits into
nabil.dakkoune/go-forwarderfrom
nabil.dakkoune/AWSINTS-3697
Open

feat(go-forwarder): add proxy and custom compression level#1140
ndakkoune wants to merge 5 commits into
nabil.dakkoune/go-forwarderfrom
nabil.dakkoune/AWSINTS-3697

Conversation

@ndakkoune
Copy link
Copy Markdown
Contributor

@ndakkoune ndakkoune commented May 29, 2026

What does this PR do?

Adds the custom compression level and the proxy support.

Motivation

Testing Guidelines

Additional Notes

  • Deprecating DD_USE_COMPRESSION in favor to DD_COMPRESSION_LEVEL
  • Keep using the same logic for proxies as the Python forwarder (i.e. we let the underlying http library read from HTTP_PROXY and HTTPS_PROXY to configure it ootb; the CloudFormation Template as the responsibility to bind DdHttpProxyURL to the two variables).
  • Renamed the package from client to sdkclients.
  • Moved the WithCompression middleware logic inside Forwarder.Send() since we need a level and the key validation does not use it.

Types of changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)
  • This PR passes the unit tests
  • This PR passes the installation tests (ask a Datadog member to run the tests)

@github-actions github-actions Bot added the aws label May 29, 2026
@datadog-prod-us1-6

This comment has been minimized.

@ndakkoune ndakkoune force-pushed the nabil.dakkoune/AWSINTS-3697 branch from 0a34912 to 009bec7 Compare May 29, 2026 08:33
cfg *config.Config
client *http.Client
storage string
gzipPool *sync.Pool
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did not find any other solution to use a gzip pool with a custom compression level if we use a package-level variable since we have to create the gzipWriter from the configuration. @ViBiOh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it should be fine since we're using it in a single place

@@ -22,6 +23,9 @@ func main() {
if err != nil {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(will change this in the future by joining all the errors in the config, keeping it as is for now)

@ndakkoune ndakkoune marked this pull request as ready for review May 29, 2026 08:47
@ndakkoune ndakkoune requested a review from a team as a code owner May 29, 2026 08:47
@ndakkoune ndakkoune requested review from ViBiOh and ge0Aja May 29, 2026 08:48
@@ -22,6 +23,9 @@ func main() {
if err != nil {
panic(err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: prefer log.fatal instead (recommended to do the same elsewhere)

req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.APIURL+"/api/v1/validate", nil)
if err != nil {
slog.Warn("failed to build API key validation request", slog.Any("error", err))
return nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should return the error here not to silently drop it

c.SkipServerCertificate = envOrDefaultBool(EnvSkipServerCertificate, false)
c.UseHTTP = envOrDefaultBool(EnvUseHTTP, false)

scheme := "https"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: i think protocol is a straight forward name


func (f Forwarder) Start(ctx context.Context, in <-chan model.LogEntry) error {
batches := make(chan []byte, MaxConcurrency)
batches := make(chan []byte, httpclient.MaxConcurrency)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I didn't get why are we limiting the batches slice size to max concurrency ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My assumption was that the batcher (CPU bound) would produce more batches than the forwarding goroutines (network bound).

var Client *http.Client

func newClient() *http.Client {
func Init(skipServerCertificate bool) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: prefer options pattern, easier to extend in the future if we want to pass other options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants