Skip to content

Commit

Permalink
more reflection clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaspimentel committed Jan 9, 2025
1 parent c0d16d7 commit be587d9
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions utils/build/docker/dotnet/parametric/Endpoints/ApmTestApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void MapApmTraceEndpoints(WebApplication app, ILogger logger)
// reflected members
private static readonly PropertyInfo GetGlobalSettingsInstance = GlobalSettingsType.GetProperty("Instance", CommonBindingFlags)!;
private static readonly PropertyInfo GetTracerManager = TracerType.GetProperty("TracerManager", CommonBindingFlags)!;
private static readonly MethodInfo GetAgentWriter = TracerManagerType.GetProperty("AgentWriter", CommonBindingFlags)!.GetGetMethod()!;
private static readonly PropertyInfo GetAgentWriter = TracerManagerType.GetProperty("AgentWriter", CommonBindingFlags)!;
private static readonly FieldInfo GetStatsAggregator = AgentWriterType.GetField("_statsAggregator", CommonBindingFlags)!;
private static readonly PropertyInfo PropagationStyleInject = TracerSettingsType.GetProperty("PropagationStyleInject", CommonBindingFlags)!;
private static readonly PropertyInfo RuntimeMetricsEnabled = TracerSettingsType.GetProperty("RuntimeMetricsEnabled", CommonBindingFlags)!;
Expand Down Expand Up @@ -295,18 +295,14 @@ protected static async Task FlushSpans()

protected static async Task FlushTraceStats()
{
if (GetTracerManager is null)
{
throw new NullReferenceException("GetTracerManager is null");
}

if (Tracer.Instance is null)
{
throw new NullReferenceException("Tracer.Instance is null");
}

var tracerManager = GetTracerManager.GetValue(GetTracerInstance.GetValue(null));
var agentWriter = GetAgentWriter.Invoke(tracerManager, null);
var tracer = GetTracerInstance.GetValue(null);
var tracerManager = GetTracerManager.GetValue(tracer);
var agentWriter = GetAgentWriter.GetValue(tracerManager);
var statsAggregator = GetStatsAggregator.GetValue(agentWriter);

if (statsAggregator?.GetType() == StatsAggregatorType)
Expand Down

0 comments on commit be587d9

Please sign in to comment.