Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix urllib3 list index error #11866

Closed
wants to merge 2 commits into from

Conversation

emmettbutler
Copy link
Collaborator

@emmettbutler emmettbutler commented Jan 6, 2025

This change removes an apparent programming error that caused this test failure:

    def test_distributed_tracing_apm_opt_out_true(self):                                                                                                                                                               
        """Tests distributed tracing headers are passed by default"""                                                                                                                                                  
        # Check that distributed tracing headers are passed down; raise an error rather than make the                                                                                                                  
        # request since we don't care about the response at all                                                                                                                                                        
        config.urllib3["distributed_tracing"] = True                                                                                                                                                                   
        self.tracer.enabled = False                                                                                                                                                                                    
        with mock.patch(                                                                                                                                                                                               
            "urllib3.connectionpool.HTTPConnectionPool._make_request", side_effect=ValueError                                                                                                                          
        ) as m_make_request:                                                                                                                                                                                           
            with pytest.raises(ValueError):                                                                                                                                                                            
                self.http.request("GET", URL_200)                                                                                                                                                                      
                                                                                                                                                                                                                       
            spans = self.pop_spans()                                                                                                                                                                                   
>           s = spans[0]                                                                                                                                                                                               
E           IndexError: list index out of range                                                                                                                                                                        
                                                                                                                                                                                                                       
tests/contrib/urllib3/test_urllib3.py:543: IndexError                   

Since the test looks at a span, it follows that the tracer should be enabled to generate that span.

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

@emmettbutler emmettbutler requested review from a team as code owners January 6, 2025 21:40
@emmettbutler emmettbutler added the changelog/no-changelog A changelog entry is not required for this PR. label Jan 6, 2025
Copy link
Contributor

github-actions bot commented Jan 6, 2025

CODEOWNERS have been resolved as:

tests/contrib/urllib3/test_urllib3.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python

@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Jan 6, 2025

Datadog Report

Branch report: emmett.butler/urllib-tracer-test
Commit report: dc0b72f
Test service: dd-trace-py

✅ 0 Failed, 87 Passed, 1468 Skipped, 3m 54.05s Total duration (35m 24.44s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Jan 6, 2025

Benchmarks

Benchmark execution time: 2025-01-07 18:37:17

Comparing candidate commit dc0b72f in PR branch emmett.butler/urllib-tracer-test with baseline commit 5f1aefc in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 394 metrics, 2 unstable metrics.

@emmettbutler emmettbutler enabled auto-merge (squash) January 7, 2025 17:55
@mabdinur
Copy link
Contributor

mabdinur commented Jan 8, 2025

This change should address the CI failure: 86a367a.

This PR removes self.tracer.enabled = False from the test which disabled APM optout. This defeats the purpose of the test.

@mabdinur mabdinur closed this Jan 8, 2025
auto-merge was automatically disabled January 8, 2025 19:24

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants