Skip to content

Commit 4aa1e01

Browse files
committed
Add debug assertions in TraceCommandStop and TraceCommandException
Debug.Assert checks that TraceCommandStart was called before the stop or exception path, helping catch lifecycle bugs during development.
1 parent 98f6f6d commit 4aa1e01

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • src/FirebirdSql.Data.FirebirdClient/FirebirdClient

src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbCommand.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,8 @@ private void TraceCommandStart()
13251325

13261326
private void TraceCommandStop()
13271327
{
1328+
Debug.Assert(_startedAtTicks > 0 || _currentActivity == null, "TraceCommandStop called without TraceCommandStart");
1329+
13281330
if (_currentActivity != null)
13291331
{
13301332
// Do not set status to Ok: https://opentelemetry.io/docs/concepts/signals/traces/#span-status
@@ -1338,6 +1340,8 @@ private void TraceCommandStop()
13381340

13391341
private void TraceCommandException(Exception e)
13401342
{
1343+
Debug.Assert(_startedAtTicks > 0 || _currentActivity == null, "TraceCommandException called without TraceCommandStart");
1344+
13411345
if (_currentActivity != null)
13421346
{
13431347
FbActivitySource.CommandException(_currentActivity, e);

0 commit comments

Comments
 (0)