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 18 commits into
base: main
Choose a base branch
from

Conversation

mtoffl01
Copy link
Contributor

@mtoffl01 mtoffl01 commented Dec 10, 2024

What does this PR do?

  1. 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.
  2. Introduces additional "stop" condition to pollDBStats goroutine that triggers when db.Close() is invoked

Motivation

We needed a way for the tracer to stop any goroutines that it does not directly manage on tracer.Stop(); without such a 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: 29d925e
Test service: dd-trace-go

❌ 1 Failed (0 Known Flaky), 5014 Passed, 71 Skipped, 2m 44.91s Total Time

❌ Failed Tests (1)

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

    Expand for error
     Failed
     
     FAIL	gopkg.in/DataDog/dd-trace-go.v1/contrib/database/sql [build failed]
    

@pr-commenter
Copy link

pr-commenter bot commented Dec 10, 2024

Benchmarks

Benchmark execution time: 2025-01-17 18:05:53

Comparing candidate commit 5bb8a4c in PR branch mtoff/contrib-routines with baseline commit 471d723 in branch main.

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

@mtoffl01 mtoffl01 force-pushed the mtoff/contrib-routines branch from 0692055 to 37b52f9 Compare December 17, 2024 01:12
Copy link
Member

@darccio darccio left a comment

Choose a reason for hiding this comment

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

LGTM. I left some small nits.

})
}

func GetStopChan() chan struct{} {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func GetStopChan() chan struct{} {
func StopChan() chan struct{} {

This would be a better name.

mu sync.Mutex
)

func InitStopChan() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func InitStopChan() {
func Init() {

Just in case this package evolves and needs to initialize more things beyond the stop chan.

@kakkoyun kakkoyun self-requested a review January 17, 2025 16:18
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.

2 participants