public Fixture()
 {
     _           = Hub.IsEnabled.Returns(true);
     HubAccessor = () => Hub;
     Scope       = new Scope(new SentryOptions());
     Hub.ConfigureScope(Arg.Invoke(Scope));
 }
Beispiel #2
0
        public void PushAndLockScope_DoesNotAffectOuterScope()
        {
            // Arrange
            var hub = new Hub(new SentryOptions
            {
                Dsn = DsnSamples.ValidDsnWithSecret,
                BackgroundWorker = new FakeBackgroundWorker()
            });

            // Act & assert
            hub.ConfigureScope(s => Assert.False(s.Locked));
            using (hub.PushAndLockScope())
            {
                hub.ConfigureScope(s => Assert.True(s.Locked));
            }

            hub.ConfigureScope(s => Assert.False(s.Locked));
        }
Beispiel #3
0
    public async Task RecordsSql()
    {
        Skip.If(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows));

        var transport = new RecordingTransport();
        var options   = new SentryOptions
        {
            TracesSampleRate = 1,
            Transport        = transport,
            Dsn             = DsnSamples.ValidDsnWithoutSecret,
            DiagnosticLevel = SentryLevel.Debug
        };

        options.AddIntegration(new SentryDiagnosticListenerIntegration());

        using var database = await sqlInstance.Build();

        using (var hub = new Hub(options))
        {
            var transaction = hub.StartTransaction("my transaction", "my operation");
            hub.ConfigureScope(scope => scope.Transaction = transaction);
            hub.CaptureException(new Exception("my exception"));
            await TestDbBuilder.AddData(database);

            await TestDbBuilder.GetData(database);

            transaction.Finish();
        }

        var payloads = transport.Envelopes
                       .SelectMany(x => x.Items)
                       .Select(x => x.Payload)
                       .ToList();

        await Verify(payloads)
        .ModifySerialization(
            p =>
        {
            p.IgnoreMembersWithType <Contexts>();
            p.IgnoreMembersWithType <SdkVersion>();
            p.IgnoreMembersWithType <DateTimeOffset>();
            p.IgnoreMembersWithType <SpanId>();
            p.IgnoreMembersWithType <SentryId>();
            p.IgnoreMembers <SentryEvent>(e => e.Modules, e => e.Release);
            p.IgnoreMembers <Transaction>(t => t.Release);
            p.IgnoreMembers <SentryException>(e => e.Module, e => e.ThreadId);
        });
    }
Beispiel #4
0
        public void PushScope_BreadcrumbWithinScope_NotVisibleOutside()
        {
            // Arrange
            var hub = new Hub(new SentryOptions
            {
                Dsn = DsnSamples.ValidDsnWithSecret,
                BackgroundWorker = new FakeBackgroundWorker()
            });

            // Act & assert
            using (hub.PushScope())
            {
                hub.ConfigureScope(s => s.AddBreadcrumb("test"));
                Assert.Single(hub.ScopeManager.GetCurrent().Key.Breadcrumbs);
            }

            Assert.Empty(hub.ScopeManager.GetCurrent().Key.Breadcrumbs);
        }
 public Fixture()
 {
     Hub.IsEnabled.Returns(true);
     Clock.GetUtcNow().Returns(DateTimeOffset.MaxValue);
     Hub.ConfigureScope(Arg.Invoke(Scope));
 }
Beispiel #6
0
 public Fixture()
 {
     _           = Hub.IsEnabled.Returns(true);
     HubAccessor = () => Hub;
     Hub.ConfigureScope(Arg.Invoke(Scope));
 }
 public Fixture()
 {
     Hub.IsEnabled.Returns(true);
     Hub.ConfigureScope(Arg.Invoke(Scope));
 }