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.

ArgumentException in DiagnosticsHandler with external retry mechanism

See original GitHub issue

Describe the bug I use Polly as a retry mechanism and use the CircuitBreaker to wrap call to CosmosDb. When a request is retried, I got an ArgumentException in the DiagnosticsHandler. It try to add again a “System Info” key in the request’s trace.

Expected behavior Do not throw exception, replace the item in the dictionary.

Actual behavior Code throw an ArgumentException.

Environment summary SDK Version: 3.29.0 OS Version: Linux

Additional context

System.ArgumentException:
   at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Collections.Generic.Dictionary`2.TryInsert (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.Cosmos.Tracing.Trace.AddDatum (Microsoft.Azure.Cosmos.Client, Version=3.28.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at Microsoft.Azure.Cosmos.Handlers.DiagnosticsHandler+<SendAsync>d__0.MoveNext (Microsoft.Azure.Cosmos.Client, Version=3.28.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jcoqueretcommented, Jul 22, 2022

Oh, I missed that sample. Thank you to answer so fast !

0reactions
ealsurcommented, Jul 22, 2022

Did using base.SendAsync fix the error you were seeing?

Read more comments on GitHub >

github_iconTop Results From Across the Web

HttpClient retry logic not working as expected (.Net Core 3.1)
This corresponds to a class I have which makes calls to an external service however it is not retrying upon failure. I have...
Read more >
Polly is a .NET resilience and transient-fault-handling ...
NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, ...
Read more >
Retry guidance for Azure services
Learn about the retry mechanism features for many Azure services. Retry mechanisms differ because services have different characteristics ...
Read more >
Working with Polly – Using the Context to Obtain the Retry ...
In this post, we'll explore a use for the Polly Context object to share data between our code and the execution of a...
Read more >
c# - 'Retry' mechanism with callback
We've had a situation whereby we have to cater for certain exceptions and retry a particular method whenever these exceptions occur. This is ......
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