Support Remote Configuration Management#3077
Conversation
d07b658 to
b2d2ed3
Compare
b2d2ed3 to
d7d74b6
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| var isRcmDisabled = apiResponse.StatusCode == 404; | ||
| if (isRcmDisabled) | ||
| { | ||
| return null; |
There was a problem hiding this comment.
- Please document this in an XML comment and ensure all consumers are checking for null.
- What happens if we received a different error status code? Won't we fail with an exception when we later call
JsonConvert.DeserializeObject?
There was a problem hiding this comment.
It would also be good to add #nullable enable, which further documents and checks (separate PR now!)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
I have quite a few comments, most aren't blocking 😅
The main point is
- This won't handle manual configuration changes, we should refactor to move initialization into the
TracerManager/TracerManagerFactory(those are not longer good names 😅)
And my main nit 😄
- There's a lot of new code that doesn't have
#nullable enableset, we should really try to use it where possible
| } | ||
|
|
||
| public static string[] AllSupportedEndpoints => SupportedDebuggerEndpoints.Concat(SupportedProbeConfigurationEndpoints).ToArray(); | ||
| public static DiscoveryService Instance { get; private set; } |
There was a problem hiding this comment.
I don't think a static instance here is the right way to go. As discussed previously, the creation of the DiscoveryService should be handled in the TracerManager, as the exporter settings (and hence the IApiRequestFactory) can change after the initial Instrumentation execution.
Exposing the DiscoveryService on TracerManager removes the need for a static instance and the GlobalLock (that's handled in TracerManager).
I'm happy for this refactoring to be in a follow-up PR if preferrable
There was a problem hiding this comment.
Yes, we definitely should do it in the following PR
| using var response = await api.GetAsync().ConfigureAwait(false); | ||
| if (response.StatusCode == 200) | ||
| { | ||
| var content = await response.ReadAsStringAsync().ConfigureAwait(false); |
There was a problem hiding this comment.
nit: seeing as we're deserializing this straight to JSON, we could skip the string allocation and use JSON.NET's Stream support instead to deserialize it directly.
Again, could be a follow up, I just think we need to be careful about allocations in this code as it will now run by default, on app startup
There was a problem hiding this comment.
I agree with you, we should do it, but in a follow up PR.
I will be happy to do this.
| #endif | ||
|
|
||
| internal static void InitializeLiveDebugger() | ||
| private static void InitRemoteConfigurationManagement(Tracer tracer) |
There was a problem hiding this comment.
This code should all be wrapped up in TracerManager, as settings could change.
There was a problem hiding this comment.
Agree, will do in a follow up PR.
| } | ||
|
|
||
| public static LiveDebugger Instance => LazyInstance.Value; | ||
| public static LiveDebugger Instance { get; private set; } |
There was a problem hiding this comment.
This may be another case where this needs to be handled and exposed on the TracerManager, as settings could change. TracerManager looking less and less like the right name...🙈
There was a problem hiding this comment.
Same as above.
We can start to think about new name 😄
| AppDomain.CurrentDomain.AssemblyLoad += (sender, args) => CheckUnboundProbes(); | ||
| AppDomain.CurrentDomain.DomainUnload += (sender, args) => _lineProbeResolver.OnDomainUnloaded(); |
There was a problem hiding this comment.
Can we not hook into the LifetimeManager here?
There was a problem hiding this comment.
Great suggestion, makes total sense.
Just to point out that this should only apply to line 105 - line 104 isn't really relevant for LifetimeManager AFAICT.
There was a problem hiding this comment.
BTW @GreenMatan note that we still don't have any tests whatsoever for the debugger working properly in a multi AppDomain scenario, so things like "method probe exists on the same method in both AppDomains A & B, AppDomain B is then unloaded" is a completely untested code path currently. I'll raise the priority of that JIRA ticket.
There was a problem hiding this comment.
Either way, this is existing implementation, so I think we can safely push to a follow up PR 🙂
| var isRcmDisabled = apiResponse.StatusCode == 404; | ||
| if (isRcmDisabled) | ||
| { | ||
| return null; |
There was a problem hiding this comment.
It would also be good to add #nullable enable, which further documents and checks (separate PR now!)
| return null; | ||
| } | ||
|
|
||
| var content = await apiResponse.ReadAsStringAsync().ConfigureAwait(false); |
There was a problem hiding this comment.
nit: if we're deserializing straight from the stream, then we shouldn't convert to a string first. We should probably add a GetStream() method to IApiResponse to avoid the extra unnecessary allocations. For a separate PR though
There was a problem hiding this comment.
Good idea, however I think we should add it in separate PR.
This one is already too big 😄
dromanol
left a comment
There was a problem hiding this comment.
Great job, IMHO. But I think on-the-fly registration / unregistration of products should be addressed.
Co-authored-by: Andrew Lock <[email protected]>
31e7be5 to
ad8bb16
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Benchmarks Report 🐌Benchmarks for #3077 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 - Unknown 🤷 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 #3077 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 #3077:
6 classes were removed from Datadog.Trace in #3077 View the full reports for further details: |
Summary of changes
Add support for Support Remote Configuration management