-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Added API Call Metrics to Docker Source #4552
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
base: main
Are you sure you want to change the base?
Added API Call Metrics to Docker Source #4552
Conversation
…I call metric emissions
pkg/sources/docker/docker.go
Outdated
| instrumentedTransport := common.NewInstrumentedTransport(common.NewCustomTransport(defaultTransport)) | ||
| opts = append(opts, remote.WithTransport(instrumentedTransport)) |
There was a problem hiding this comment.
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))?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😂
Description:
This PR wires the Docker source’s registry HTTP traffic into TruffleHog’s shared HTTP metrics instrumentation.
By wrapping the
remote.WithTransport(...)call withcommon.NewCustomTransportandcommon.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_totaltrufflehog_http_client_request_duration_secondstrufflehog_http_client_non_200_responses_totalOnce 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_bytesChecklist:
make test-community)?make lintthis requires golangci-lint)?