Skip to content

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

@pmoravec

Description

@pmoravec

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions