Small refactoring to remove duplicate code around SocketException detection#3123
Conversation
Benchmarks Report 🐌Benchmarks for #3123 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️Raw results
|
Code Coverage Report 📊✔️ Merging #3123 into master will not change line coverage
View the full report for further details: Datadog.Trace Breakdown ✔️
The following classes have significant coverage changes.
The following classes were added in #3123:
View the full reports for further details: |
|
|
||
| namespace Datadog.Trace.Util.Http; | ||
|
|
||
| internal static class HttpExceptionExtensions |
There was a problem hiding this comment.
Should this be called ExceptionExtensions since the only method is an extension on Exception, not HttpException? (level of care low)
There was a problem hiding this comment.
Yeah, probably 🤔 I made it HttpExceptionExtensions because I wanted to put it in the Http sub namespace, to reduce the places it's in scope. I'll leave it there for now, but happy to shift it later
lucaspimentel
left a comment
There was a problem hiding this comment.
Nice deduplication, thanks
Summary of changes
Extracts helper method for determining if an exception is a
SocketExceptionReason for change
We have the exact same logic duplicated in multiple places
Implementation details
Created an extension method called
IsSocketException(),Test coverage
Added some unit tests
Other details