Skip to content

fix: Avoid logging full URLs in HTTP metrics (i.e. _LOG_REQUEST_METRIC_URLS has no effect now)#3646

Merged
edgarrmondragon merged 1 commit into
mainfrom
refactor/http-metric-no-url
May 27, 2026
Merged

fix: Avoid logging full URLs in HTTP metrics (i.e. _LOG_REQUEST_METRIC_URLS has no effect now)#3646
edgarrmondragon merged 1 commit into
mainfrom
refactor/http-metric-no-url

Conversation

@edgarrmondragon
Copy link
Copy Markdown
Collaborator

@edgarrmondragon edgarrmondragon commented May 27, 2026

Summary by Sourcery

Stop including request URLs in HTTP duration metrics and update tests accordingly.

Bug Fixes:

  • Ensure HTTP request duration metrics no longer attempt to log full request URLs, making the URL logging flag effectively unused.

Tests:

  • Adjust HTTP metrics logging tests to assert that request URLs are never included in metric tags and simplify parameterization.

…IC_URLS` has no effect now)

Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
@edgarrmondragon edgarrmondragon self-assigned this May 27, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 27, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR stops including request URLs in HTTP request duration metrics regardless of the _LOG_REQUEST_METRIC_URLS flag, simplifies the metric logging implementation, and updates tests accordingly to assert that URLs are never logged.

Sequence diagram for HTTP request metric logging without URL tags

sequenceDiagram
    participant RestStream
    participant Requests as requests
    participant Metrics as metrics

    RestStream->>Requests: request(method, url, headers, data, timeout, allow_redirects)
    Requests-->>RestStream: Response
    RestStream->>RestStream: _write_request_duration_log(endpoint, response)
    RestStream->>Metrics: Point("timer", metric=Metric.HTTP_REQUEST_DURATION, tags={endpoint, status, status_name})
    RestStream->>RestStream: _log_metric(point)
Loading

File-Level Changes

Change Details Files
Stop passing request URL information into HTTP duration metrics and remove its effect from logging.
  • Remove conditional construction of extra_tags containing the request path_url when calling _write_request_duration_log
  • Call _write_request_duration_log only with endpoint and response, ignoring _LOG_REQUEST_METRIC_URLS configuration
  • Eliminate use of extra_tags in metrics tags so that URL is never included in logged metrics
singer_sdk/streams/rest.py
Update request metrics tests to align with the new behavior that URLs are never logged and simplify test parameters.
  • Remove pytest parametrization over context and log_urls since URL logging is no longer configurable
  • Stop setting _LOG_REQUEST_METRIC_URLS on the test stream implementation
  • Always call get_records with None context in the test to match removed context parametrization
  • Change assertion to check that 'url' is not present in metric tags instead of being conditional on log_urls
  • Import pytest in type checking block to satisfy typing and fixtures usage
tests/core/rest/test_request_metrics.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@edgarrmondragon edgarrmondragon added Logging Logging & Monitoring with Meltano HTTP HTTP based taps and targets such (REST, XML, etc.) labels May 27, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Now that _LOG_REQUEST_METRIC_URLS no longer affects behavior, consider removing or clearly deprecating it to avoid confusion for future maintainers.
  • Given that extra_tags is now intentionally unused (with # noqa: ARG002), consider either removing it from _write_request_duration_log if it’s not part of the public API, or adding a brief code comment explaining why it’s retained to make the intent clearer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that `_LOG_REQUEST_METRIC_URLS` no longer affects behavior, consider removing or clearly deprecating it to avoid confusion for future maintainers.
- Given that `extra_tags` is now intentionally unused (with `# noqa: ARG002`), consider either removing it from `_write_request_duration_log` if it’s not part of the public API, or adding a brief code comment explaining why it’s retained to make the intent clearer.

## Individual Comments

### Comment 1
<location path="singer_sdk/streams/rest.py" line_range="679-682" />
<code_context>
         response: requests.Response,
         context: Context | None = None,  # noqa: ARG002
-        extra_tags: dict | None = None,
+        extra_tags: dict | None = None,  # noqa: ARG002
     ) -> None:
         """Log the HTTP duration metric.
</code_context>
<issue_to_address>
**suggestion:** `extra_tags` is now a dead parameter; consider a clearer approach than suppressing the unused-arg lint.

Since `extra_tags` isn’t used in `_write_request_duration_log`, keeping it in the signature with `# noqa: ARG002` may mislead callers into thinking it still has an effect. If you can change the API, consider removing the parameter. If you must keep it for compatibility, either pass it into a dedicated (even if currently no-op) hook or clearly mark it as deprecated in the public API instead of only suppressing the lint warning.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread singer_sdk/streams/rest.py
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.81%. Comparing base (ff18876) to head (e7c9953).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3646      +/-   ##
==========================================
- Coverage   93.81%   93.81%   -0.01%     
==========================================
  Files          73       73              
  Lines        5950     5949       -1     
  Branches      728      728              
==========================================
- Hits         5582     5581       -1     
  Misses        273      273              
  Partials       95       95              
Flag Coverage Δ
core 82.43% <100.00%> (-0.01%) ⬇️
end-to-end 75.25% <100.00%> (-0.01%) ⬇️
optional-components 42.78% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 27, 2026

Merging this PR will not alter performance

✅ 8 untouched benchmarks


Comparing refactor/http-metric-no-url (e7c9953) with main (ff18876)

Open in CodSpeed

@edgarrmondragon edgarrmondragon added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit 51748cc May 27, 2026
41 checks passed
@edgarrmondragon edgarrmondragon deleted the refactor/http-metric-no-url branch May 27, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

HTTP HTTP based taps and targets such (REST, XML, etc.) Logging Logging & Monitoring with Meltano

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant