pulp / pulp-openapi-generator

GNU General Public License v2.0
4 stars 24 forks source link

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

Open pmoravec opened 1 year ago

pmoravec commented 1 year ago

Is your feature request related to a problem? Please describe. When katello enables pulp_rest debugs (once https://github.com/Katello/katello/pull/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.

pulpbot commented 7 months ago

https://bugzilla.redhat.com/show_bug.cgi?id=2258850

mdellweg commented 7 months ago

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.