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

The segment is infinitely appended to the same trace #545

Open
1 of 4 tasks
inversionhourglass opened this issue Feb 28, 2023 · 3 comments
Open
1 of 4 tasks

The segment is infinitely appended to the same trace #545

inversionhourglass opened this issue Feb 28, 2023 · 3 comments
Assignees

Comments

@inversionhourglass
Copy link
Contributor

Please answer these questions before submitting your issue.

  • Why do you submit this issue?
  • Question or discussion
  • Bug
  • Requirement
  • Feature or performance improvement

Question

  • What do you want to know?

Bug

[HttpGet]
public async Task Test()
{
    Task.Factory.StartNew(async () =>
    {
        while (true)
        {
            // The trace data generated by this request will use the `traceId` generated by the external thread
            await new HttpClient().GetAsync("http://localhost:5002/api/delay/1000");
            await Task.Delay(2000);
        }
    }, TaskCreationOptions.LongRunning);

    await new HttpClient().GetAsync("http://localhost:5002/api/delay/1000");
}

Similar to the above code, create a new thread with an infinite loop in the thread of the existing tracing context, and the trace data in the new thread will be infinitely appended to the trace of the external thread.
Is there any way to generate a independent trace for the new thread?

In my company, there are nearly 700,000 segments with the same trace id in the three-day segments data.
image


Requirement or improvement

  • Please describe about your requirements or improvement suggestions.
@wu-sheng
Copy link
Member

We suspend the previous PR about manually cleaning current context.
I want to discuss this officially about how we treat this case?
Manually close seems misleading.
Does .net want newTracing API(or similar)? Or any suggestion?
Notice, we don't have this in any other agents AFAIK.

@inversionhourglass
Copy link
Contributor Author

I see java has CallableWrapper that also is a hardcode way. If you mean just don't hardcode directly use the tracing context, then I can implement it in a way similar to CallableWrapper. But the two methods in the PR are still needed, just not used in user code.

我看java也有 CallableWrapper 这种硬编码的方式, 如果你的意思是在用户代码中硬编码使用tracing context不合适,那我或许能以类似CallableWrapper的方式来实现。不过之前PR中的两个方法还是需要的,只是它们不直接在用户代码中使用。

@wu-sheng
Copy link
Member

wu-sheng commented Mar 2, 2023

@liuhaoyang Is the manually stopping trace context causing segment leak?
I don't know .net agent enough to make sure it is safe or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants