Skip to content

Conversation

@nabeelalam
Copy link
Contributor

Description:

This PR wires the Docker source’s registry HTTP traffic into TruffleHog’s shared HTTP metrics instrumentation.

By wrapping the remote.WithTransport(...) call with common.NewCustomTransport and common.NewInstrumentedTransport, Docker API calls should now emit the associated API metrics.

This should add the following metrics to Docker API calls:

  • trufflehog_http_client_requests_total
  • trufflehog_http_client_request_duration_seconds
  • trufflehog_http_client_non_200_responses_total

Once this PR to add new metrics to the Retryable HTTP Client is merged, the following metric will also be recorded:

  • trufflehog_http_client_response_body_size_bytes

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@nabeelalam nabeelalam self-assigned this Nov 14, 2025
@nabeelalam nabeelalam requested a review from a team November 14, 2025 09:24
@nabeelalam nabeelalam requested review from a team as code owners November 14, 2025 09:24
Comment on lines 505 to 506
instrumentedTransport := common.NewInstrumentedTransport(common.NewCustomTransport(defaultTransport))
opts = append(opts, remote.WithTransport(instrumentedTransport))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not simply do remote.WithTransport(common.NewInstrumentedTransport(defaultTransport))?

Copy link
Contributor

Choose a reason for hiding this comment

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

I too am a fan of not naming things when they're only used once. But, I can also see how that'd be pretty nested, so, maybe author's choice on this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mustansir14 hmm. Based off of looking at CustomTransport in common/http.go I assumed it was responsible for adding the a User-Agent header and it would serve some sort of meaningful purpose.

Copy link
Contributor

Choose a reason for hiding this comment

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

@camgunz I didn't mind the variable. I was just concerned why we added common.NewCustomTransport. But upon checking, @nabeelalam is right that it is responsible for adding the User-Agent, which is cool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked at it and the nesting doesn't seem as bad to me as I had thought it would be, so I'll just remove the extra assignment 😂

@nabeelalam nabeelalam requested a review from a team as a code owner November 21, 2025 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants