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

Allow client_bindings to log method+URL of a pulp request #82

Open
pmoravec opened this issue Jan 7, 2023 · 2 comments
Open

Allow client_bindings to log method+URL of a pulp request #82

pmoravec opened this issue Jan 7, 2023 · 2 comments

Comments

@pmoravec
Copy link

pmoravec commented Jan 7, 2023

Is your feature request related to a problem? Please describe.
When katello enables pulp_rest debugs (once Katello/katello#10402 is merged), it starts logging debugs like:

2023-01-02T22:40:59 [D|kat|6ce9a60c] Calling API: DistributionsRpmApi.partial_update ...
2023-01-02T22:40:59 [D|kat|6ce9a60c] HTTP request body param BEGIN
6ce9a60c | {"content_guard":null,"base_path":"RedHat/Library/custom/zoo_product/ZOO_repo","publication":"/pulp/api/v3/publications/rpm/rpm/2e85692d-4690-4ea1-9092-7927187bf874/"}
6ce9a60c | END
6ce9a60c |
2023-01-02T22:40:59 [D|kat|6ce9a60c] HTTP response body BEGIN
6ce9a60c | {"task":"/pulp/api/v3/tasks/2656ab82-e498-4bdb-9424-08ff56776861/"}
6ce9a60c | END
6ce9a60c |

from rubygem-pulp_rpm_client. The debugs contain request and response body and endpoint, but not the request URL and method used.

It would be beneficial for understanding katello<->pulp communication to log there also these pieces of information.

Describe the solution you'd like

In generated pulp_rpm_client code, e.g. in lib/pulp_rpm_client/api_client.rb:

    def build_request(http_method, path, request, opts = {})
..
      if [:post, :patch, :put, :delete].include?(http_method)
        req_body = build_request_body(header_params, form_params, opts[:body])
        req_opts.update :body => req_body
        if @config.debugging
          @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
        end
      end

add something like:

      if @config.debugging
              @config.logger.debug "HTTP #{http_method.to_sym.upcase} request to #{url}"
      end

prior the if include? code.

Describe alternatives you've considered
Enhance katello (or any other client communicating with pulp) in a similar way - where the changes would have to be maintained per each such project separately.

@dkliban dkliban transferred this issue from pulp/pulp_rpm Jan 12, 2023
@pulpbot
Copy link
Member

pulpbot commented Jan 17, 2024

@mdellweg
Copy link
Member

Actually, the information is there:
DistributionsRpmApi.partial_update translates to PATCH /pulp/api/v3/distributions/rpm/rpm/.
Also you should find the correlationID "6ce9a60c" in the pulp access logs, i think.
Having said this, it may still be valid to add more verbose logging here.

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

No branches or pull requests

3 participants