Change UserDetails to a struct#2682
Conversation
andrewlock
left a comment
There was a problem hiding this comment.
I didn't notice the requirement that Id is non null before. Given this, I wonder if we should add a constructor like UserDetails(string id), as it's a more idiomatic way to indicate a required value. Obviously, with the switch to a struct, this is not quite as nice, as you can still do new UserDetails(), but I think it's still preferable.
Related: is string.Empty a valid Id? I guess it's a valid tag value, but does it make any sense in this API, given you presumably require an ID value if they're setting other values?
Also, given UserDetails is a new public API, I think we should enable nullable in UserDetails, and mark all the non-Id parameters as string? instead of string. That further hammers home the requirement
This comment has been minimized.
This comment has been minimized.
I added the
To be honest, not checking for the empty string was an oversight, but I've added a check for it. I do wonder if we might come across some clients who are using the empty string for a special user id, but I think adding the check is okay, since it's easier to relax restrictions than increase them.
Yes, I have added this now. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
andrewlock
left a comment
There was a problem hiding this comment.
LGTM 👍 Thanks for the update
| Email = null; | ||
| Name = null; | ||
| SessionId = null; | ||
| Role = null; |
There was a problem hiding this comment.
Roll-on C#11 where this is implicit 😄
Code Coverage Report 📊✔️ Merging #2682 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 #2682:
View the full reports for further details: |
Benchmarks Report 🐌Benchmarks for #2682 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 - Faster 🎉 Same allocations ✔️
|
| Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net472 | 1.162 | 1,479.91 | 1,273.22 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | RunOnMethodBegin |
net472 | 1.48μs | 7.56ns | 33.8ns | 0.0838 | 0 | 0 | 538 B |
| master | RunOnMethodBegin |
netcoreapp3.1 | 1.22μs | 4.71ns | 17ns | 0.00821 | 0 | 0 | 576 B |
| #2682 | RunOnMethodBegin |
net472 | 1.29μs | 7.41ns | 56.9ns | 0.0845 | 0 | 0 | 538 B |
| #2682 | RunOnMethodBegin |
netcoreapp3.1 | 1.16μs | 6.02ns | 30.7ns | 0.00794 | 0 | 0 | 576 B |
As requested by @lucaspimentel .