Skip to content

fix: Remove noisy context tag from http_request_duration metric log#3645

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

fix: Remove noisy context tag from http_request_duration metric log#3645
edgarrmondragon merged 1 commit into
mainfrom
refactor/http-metric-no-context

Conversation

@edgarrmondragon
Copy link
Copy Markdown
Collaborator

@edgarrmondragon edgarrmondragon commented May 27, 2026

Summary by Sourcery

Remove the noisy context tag from HTTP request duration metrics and update related logging behavior and tests.

Bug Fixes:

  • Stop including the context tag in http_request_duration metric logs to reduce noise in emitted metrics.

Enhancements:

  • Improve REST stream request and metric logging docstrings and make unused context parameters optional with explicit TODO notes for future cleanup.

Tests:

  • Update request metrics tests to assert that the context tag is no longer present on http_request_duration points.

Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
@edgarrmondragon edgarrmondragon self-assigned this May 27, 2026
@edgarrmondragon edgarrmondragon added this to the v0.55 milestone 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 adding the context tag to the http_request_duration metric, cleans up the API around the request duration logger, and updates tests to reflect the new tagging behavior.

Sequence diagram for updated HTTP request duration metric logging

sequenceDiagram
    participant RESTStream
    participant RequestsSession as requests_Session
    participant Metrics as metrics

    RESTStream->>RequestsSession: send(prepared_request)
    RequestsSession-->>RESTStream: Response
    RESTStream->>RESTStream: _write_request_duration_log(endpoint, response, extra_tags)
    RESTStream->>Metrics: Point("timer", tags=extra_tags)
    Metrics-->>RESTStream: point_recorded()
Loading

File-Level Changes

Change Details Files
Stop including the context tag in http_request_duration metric logs and make the duration logger’s extra tags optional.
  • Set a default value for the context parameter in the _request helper and mark it as intentionally unused
  • Adjust _write_request_duration_log signature so context and extra_tags are optional and mark context as intentionally unused
  • Remove logic that injected the context value into extra_tags for the metric point
  • Keep duration logging behavior the same for endpoint and optional URL tags
singer_sdk/streams/rest.py
Align tests with the new metric tagging behavior.
  • Update the metric test to assert that the context tag is absent instead of matching the original context value
  • Retain tests verifying presence or absence of the url tag based on configuration
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 kind/Tech Debt HTTP HTTP based taps and targets such (REST, XML, etc.) Logging Logging & Monitoring with Meltano 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 left some high level feedback:

  • If context and extra_tags are intended to be unused going forward, consider adding a deprecation path (e.g., warnings when non-None values are passed and a note in the docstring) rather than just a TODO and # noqa: ARG002, so callers have a clear migration signal before the parameters are actually removed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- If `context` and `extra_tags` are intended to be unused going forward, consider adding a deprecation path (e.g., warnings when non-None values are passed and a note in the docstring) rather than just a TODO and `# noqa: ARG002`, so callers have a clear migration signal before the parameters are actually removed.

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.

@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 (ae425c6) to head (81732e4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3645      +/-   ##
==========================================
- Coverage   93.81%   93.81%   -0.01%     
==========================================
  Files          73       73              
  Lines        5948     5946       -2     
  Branches      729      728       -1     
==========================================
- Hits         5580     5578       -2     
  Misses        273      273              
  Partials       95       95              
Flag Coverage Δ
core 82.32% <ø> (-0.01%) ⬇️
end-to-end 75.24% <ø> (+0.02%) ⬆️
optional-components 42.76% <ø> (+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-context (81732e4) with main (11fc5b5)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (ae425c6) during the generation of this report, so 11fc5b5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@edgarrmondragon edgarrmondragon added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit ec443c8 May 27, 2026
41 checks passed
@edgarrmondragon edgarrmondragon deleted the refactor/http-metric-no-context branch May 27, 2026 01:51
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.) kind/Tech Debt Logging Logging & Monitoring with Meltano

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant