Giter VIP home page Giter VIP logo

Comments (7)

Aaronontheweb avatar Aaronontheweb commented on June 8, 2024

Found the issue here - the problem was that SpanEnvelopes were accidentally being logged, rather than their underlying message contents

from phobos-issues.

Aaronontheweb avatar Aaronontheweb commented on June 8, 2024

Figured out this issue, finally:

public sealed class AwaitActor : ReceiveActor
        {
            private readonly IActorRef _testActor;
            private readonly IActorRef _echoActor;

            public AwaitActor(IActorRef testActor, IActorRef echoActor)
            {
                _testActor = testActor;
                _echoActor = echoActor;

                ReceiveAsync<int>(async i =>
                {
                    using var scope = Context.GetInstrumentation().Tracer
                        .BuildSpan("FireAsync")
                        .IgnoreActiveSpan()
                        .StartActive(true);

                    var result = await _echoActor.Ask<int>(i, TimeSpan.FromSeconds(3));

                    _testActor.Tell(result);
                });
            }
        }

        [Fact(DisplayName = "ScopeLeak: awaited operations that don't use ActiveSpan should not leak")]
        public async Task Bugfix19()
        {
            // arrange
            var echoActor = Sys.ActorOf(EchoActor.Props(this), "echo");
            var awaitActor = Sys.ActorOf(Props.Create(() => new AwaitActor(TestActor, echoActor)), "await");

            // act
            awaitActor.Tell(1);
            ExpectMsg(1);

            // assert
            await WaitForTracesToStabilize();
            var finishedSpans = FinishedSpans;
            var allSpans = LeakTracking.AllScopes;
            allSpans.Count.Should().Be(finishedSpans.Count);
        }

Not sure if the issue is the await or the IgnoreActiveSpan() but I should be able to find out quickly.

from phobos-issues.

Aaronontheweb avatar Aaronontheweb commented on June 8, 2024

The above unit test fails with the following:

Expected allSpans.Count to be 2, but found 3.

from phobos-issues.

Aaronontheweb avatar Aaronontheweb commented on June 8, 2024

It's definitely the await - or more accurately, it's the async state machine. This also causes the test to fail:

ReceiveAsync<int>(async i =>
{
    using var scope = Context.GetInstrumentation().Tracer
        .BuildSpan("FireAsync")
        .IgnoreActiveSpan()
        .StartActive(true);

    var result = _echoActor.Ask<int>(i, TimeSpan.FromSeconds(3)).Result;

    _testActor.Tell(result);
});

from phobos-issues.

Aaronontheweb avatar Aaronontheweb commented on June 8, 2024

Looks like we might have a fix for this....

Before

image

After

image

from phobos-issues.

Aaronontheweb avatar Aaronontheweb commented on June 8, 2024

Simplified this:

public sealed class AwaitActor : ReceiveActor
{
    private readonly IActorRef _testActor;
    private readonly IActorRef _echoActor;

    public AwaitActor(IActorRef testActor, IActorRef echoActor)
    {
        _testActor = testActor;
        _echoActor = echoActor;

        ReceiveAsync<int>(async i =>
        {
            using var scope = Context.GetInstrumentation().Tracer
                .BuildSpan("FireAsync")
                .IgnoreActiveSpan()
                .StartActive(true);

            var result = await _echoActor.Ask<int>(i, TimeSpan.FromSeconds(3)).ConfigureAwait(false);

            _testActor.Tell(result);
        });
    }
}

[Fact(DisplayName = "ScopeLeak: awaited operations that don't use ActiveSpan should not leak")]
public async Task Bugfix19()
{
    // arrange
    var echoActor = Sys.ActorOf(EchoActor.Props(this), "echo");
    var awaitActor = Sys.ActorOf(Props.Create(() => new AwaitActor(TestActor, echoActor)), "await");

    // act
    awaitActor.Tell(1);
    ExpectMsg(1);

    // assert
    await WaitForTracesToStabilize();
    

    LeakTracking.AllScopes.All(x => x.WasDisposed).Should().BeTrue();
}

from phobos-issues.

Aaronontheweb avatar Aaronontheweb commented on June 8, 2024

Final version of this graph:

image

from phobos-issues.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.