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

Allow goroutines not launched by the tracer to stop on tracer.Stop() #3025

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mtoffl01
Copy link
Contributor

What does this PR do?

Introduces a new package, contribroutines, which contains a stop channel and an API for getting the channel and closing the channel.
The contribs should get the channel to use as a stop condition for any goroutines they launch, and the tracer should be the only one to stop the channel.

Motivation

We needed a way for the tracer to stop any goroutines that it does not directly manage on tracer.Stop(); without this mechanism, we were dealing with runaway goroutines.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.
  • For internal contributors, a matching PR should be created to the v2-dev branch and reviewed by @DataDog/apm-go.

Unsure? Have a question? Request a review!

@github-actions github-actions bot added the apm:ecosystem contrib/* related feature requests or bugs label Dec 10, 2024
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Dec 10, 2024

Datadog Report

Branch report: mtoff/contrib-routines
Commit report: 1209807
Test service: dd-trace-go

❌ 3 Failed (0 Known Flaky), 5102 Passed, 67 Skipped, 2m 26.16s Total Time

❌ Failed Tests (3)

  • TestOpenOptions - gopkg.in/DataDog/dd-trace-go.v1/contrib/database/sql - Details

    Expand for error
     Failed
     
     === RUN   TestOpenOptions
         testing.go:1398: race detected during execution of test
     --- FAIL: TestOpenOptions (1.22s)
    
  • TestOpenOptions/WithDBStats - gopkg.in/DataDog/dd-trace-go.v1/contrib/database/sql - Details

    Expand for error
     Failed
     
     === RUN   TestOpenOptions/WithDBStats
         sql_test.go:292: Stats not collected in expected interval of 500ms
     ==================
     Write at 0x0000022247a8 by goroutine 493:
       gopkg.in/DataDog/dd-trace-go.v1/contrib/database/sql.TestOpenOptions.func1()
           /home/runner/work/dd-trace-go/dd-trace-go/contrib/database/sql/sql_test.go:137 +0x24
       testing.(*common).Cleanup.func1()
           /opt/hostedtoolcache/go/1.22.10/x64/src/testing/testing.go:1175 +0x179
     ...
    
  • TestCollectCoverageAfterTestExecution - gopkg.in/DataDog/dd-trace-go.v1/internal/civisibility/integrations/gotesting/coverage - Details

    Expand for error
     Failed
     
     === RUN   TestCollectCoverageAfterTestExecution
         test_coverage_test.go:315: Expected postCoverageFilename /tmp/TestCollectCoverageAfterTestExecution296606244/001/1-2-3-post.out to exist
     --- FAIL: TestCollectCoverageAfterTestExecution (0.00s)
    

@pr-commenter
Copy link

pr-commenter bot commented Dec 10, 2024

Benchmarks

Benchmark execution time: 2024-12-10 22:50:01

Comparing candidate commit f0f73af in PR branch mtoff/contrib-routines with baseline commit 9980c24 in branch main.

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

scenario:BenchmarkSetTagMetric-24

  • 🟥 execution_time [+4.382ns; +6.278ns] or [+3.626%; +5.194%]

scenario:BenchmarkSetTagString-24

  • 🟥 execution_time [+7.831ns; +11.189ns] or [+6.703%; +9.577%]

scenario:BenchmarkSetTagStringPtr-24

  • 🟥 execution_time [+6.300ns; +8.840ns] or [+3.641%; +5.109%]

scenario:BenchmarkSetTagStringer-24

  • 🟥 execution_time [+5.692ns; +7.728ns] or [+3.999%; +5.430%]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant