question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatic SQL Instrumentation Unable to Find Spans

See original GitHub issue

Package

Sentry

.NET Flavor

.NET

.NET Version

6.0.0

OS

Windows

SDK Version

6.0.203

Self-Hosted Sentry Version

No response

Steps to Reproduce

I’m facing the issue originally reported in #1210 and was asked to spin up a new ticket. Upon upgrading to the latest version of Sentry, we started seeing a large number of warning log messages from sentry in the form below. Since we had jumped a few versions, I bisected until I found that these warnings started appearing in 3.22.0. I did not see these warning logs in 3.21.0. I can also confirm that disabling automatic SQL instrumentation with DisableDiagnosticSourceIntegration does remove the warning logs.

Trying to get a span of type {type} with operation id {guid}, but it was not found.

Here is an excerpt from our logs that show the sentry warnings. I’m not sure if there is some race condition, because when I set the log level to Trace (Serilog calls this Verbose), I don’t see the sentry warnings, but when the log level is set to Debug, I do.

{"Timestamp":"2022-11-18T10:09:24.3750643-05:00","Level":"Information","MessageTemplate":"Entity Framework Core {version} initialized '{contextType}' using provider '{provider}:{providerVersion}' with options: {options}","Properties":{"version":"6.0.9","contextType":"[REDACTED]","provider":"Microsoft.EntityFrameworkCore.SqlServer","providerVersion":"6.0.9","options":"None","EventId":{"Id":10403,"Name":"Microsoft.EntityFrameworkCore.Infrastructure.ContextInitialized"},"SourceContext":"Microsoft.EntityFrameworkCore.Infrastructure","ActionId":"1e01ba7b-0cc1-4926-82a9-3f9b9b60bec9","ActionName":"[REDACTED]","RequestId":"0HMM9ER7LRNIR:0000000F","RequestPath":"[REDACTED]","ConnectionId":"0HMM9ER7LRNIR","MachineName":"[REDACTED]","ClientIp":"127.0.0.1","ClientAgent":"[REDACTED]"}}
{"Timestamp":"2022-11-18T10:09:24.6612204-05:00","Level":"Warning","MessageTemplate":"Trying to get a span of type {0} with operation id {1}, but it was not found.","Properties":{"0":"Execution","1":"07546a94-0989-4d99-b5f7-c1782184eb80","SourceContext":"Sentry.ISentryClient","ActionId":"1e01ba7b-0cc1-4926-82a9-3f9b9b60bec9","ActionName":"[REDACTED]","RequestId":"0HMM9ER7LRNIR:0000000F","RequestPath":"[REDACTED]","ConnectionId":"0HMM9ER7LRNIR","MachineName":"[REDACTED]","ClientIp":"127.0.0.1","ClientAgent":"[REDACTED]"}}
{"Timestamp":"2022-11-18T10:09:24.6699988-05:00","Level":"Information","MessageTemplate":"Executed DbCommand ({elapsed}ms) [Parameters=[{parameters}], CommandType='{commandType}', CommandTimeout='{commandTimeout}']{newLine}{commandText}","Properties":{"elapsed":"56","parameters":"","commandType":"Text","commandTimeout":30,"newLine":"\r\n","commandText":"SELECT [REDACTED]\r\nFROM [REDACTED]\r\nWHERE [REDACTED]","EventId":{"Id":20101,"Name":"Microsoft.EntityFrameworkCore.Database.Command.CommandExecuted"},"SourceContext":"Microsoft.EntityFrameworkCore.Database.Command","ActionId":"1e01ba7b-0cc1-4926-82a9-3f9b9b60bec9","ActionName":"REDACTED"","RequestId":"0HMM9ER7LRNIR:0000000F","RequestPath":"[REDACTED]","ConnectionId":"0HMM9ER7LRNIR","MachineName":"[REDACTED]","ClientIp":"127.0.0.1","ClientAgent":"[REDACTED]"}}
{"Timestamp":"2022-11-18T10:09:24.7338833-05:00","Level":"Warning","MessageTemplate":"Trying to get a span of type {0} with operation id {1}, but it was not found.","Properties":{"0":"Connection","1":"bcfa705d-1d03-4c85-8ecf-16810e17ea6e","SourceContext":"Sentry.ISentryClient","ActionId":"1e01ba7b-0cc1-4926-82a9-3f9b9b60bec9","ActionName":"REDACTED"","RequestId":"0HMM9ER7LRNIR:0000000F","RequestPath":"[REDACTED]","ConnectionId":"0HMM9ER7LRNIR","MachineName":"[REDACTED]","ClientIp":"127.0.0.1","ClientAgent":"[REDACTED]"}}

Expected Result

I would not expect to see the warning log messages when using entity framework and automatic sql instrumentation enabled with Sentry.

Actual Result

An excessive number of warning log messages.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
vermicelicommented, Dec 23, 2022

I can confirm that with the 3.25.0 release I am no longer seeing these warning messages. Thank you for you help.

1reaction
mattjohnsonpintcommented, Dec 21, 2022

BTW - The .NET SDK guidance about TraceSampleRate needs to be updated. In general, the best results now come from setting 1.0 and relying on Sentry’s Dynamic Sampling feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manual Instrumentation
To create Spans, you only need to specify the name of the span. The start and end time of the span is automatically...
Read more >
Query with TraceQL | Grafana Tempo documentation
Construct a TraceQL query ... In this example, the search reduces traces to those spans where: ... Queries select sets of spans and...
Read more >
Introducing Sqlcommenter: An open source ORM auto- ...
Introducing Sqlcommenter: An open source ORM auto-instrumentation library · Getting started with Sqlcommenter · Augment slow query logs with ORM ...
Read more >
How to suppress opentelemetry java auto instrumentation ...
I tried -Dotel.javaagent.exclude-classes= , but it's definitely hard to identify which class of quartz I need to put here to suppress the jdbc ......
Read more >
Custom Instrumentation with Datadog Libraries
Customize your instrumentation and observability within your Datadog traces. ... captured by automatic instrumentation, removing unwanted spans from traces, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found