pulp / pulp/pulp-openapi-generator

Allow client_bindings to log method+URL of a pulp request

Open
#82 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Triage-Needed
Dominant language
Mustache
Stars
4
Forks
29
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/pulp_rpm_client/api_client.rb at build_request, especially the debugging branch before request-body handling. Trace how the generated client constructs the URL and emits debug messages. Done means debugging output identifies the HTTP method and request URL alongside the existing request and response details.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.