Skip to content

Commit

Permalink
Fine Kevin, you win
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlock committed Nov 22, 2024
1 parent 636c962 commit ad3394e
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed class ImmutableTracerSettings
/// <summary>
/// Initializes a new instance of the <see cref="ImmutableTracerSettings"/> class.
/// </summary>
internal ImmutableTracerSettings(Dictionary<string, object?> initialValues)
internal ImmutableTracerSettings(IDictionary<string, object?> initialValues)
{
AgentUri = GetValue<Uri?>(initialValues, TracerSettingKeyConstants.AgentUriKey, null) ?? new Uri("http://127.0.0.1:8126");
CustomSamplingRules = GetValue<string?>(initialValues, TracerSettingKeyConstants.CustomSamplingRules, null);
Expand All @@ -45,7 +45,7 @@ internal ImmutableTracerSettings(Dictionary<string, object?> initialValues)

Integrations = IntegrationSettingsHelper.ParseImmutableFromAutomatic(initialValues);

static T GetValue<T>(Dictionary<string, object?> results, string key, T defaultValue)
static T GetValue<T>(IDictionary<string, object?> results, string key, T defaultValue)
{
if (results.TryGetValue(key, out var value)
&& value is T t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static IntegrationSettings CreateSettingFunc(string name, bool? enabled, bool? a
=> new(name, enabled, analyticsEnabled, analyticsSampleRate);
}

public static ImmutableIntegrationSettingsCollection ParseImmutableFromAutomatic(Dictionary<string, object?> initialValues)
public static ImmutableIntegrationSettingsCollection ParseImmutableFromAutomatic(IDictionary<string, object?> initialValues)
{
var settings = Populate(initialValues, CreateSettingFunc);
return new ImmutableIntegrationSettingsCollection(settings);
Expand All @@ -30,7 +30,7 @@ static ImmutableIntegrationSettings CreateSettingFunc(string name, bool? enabled
}

private static Dictionary<string, T> Populate<T>(
Dictionary<string, object?> initialValues,
IDictionary<string, object?> initialValues,
Func<string, bool?, bool?, double, T> createSettingFunc)
{
if (!initialValues.TryGetValue(TracerSettingKeyConstants.IntegrationSettingsKey, out var raw)
Expand Down
4 changes: 2 additions & 2 deletions tracer/src/Datadog.Trace.Manual/Tracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public ImmutableTracerSettings Settings
else if (_settings is null)
{
// in manual only mode
_settings = new ImmutableTracerSettings(new());
_settings = new ImmutableTracerSettings(new Dictionary<string, object?>());
}

return _settings;
Expand Down Expand Up @@ -155,7 +155,7 @@ private static void Configure(Dictionary<string, object?> settings)
/// settings, only if the ImmutableTracerSettings (automatic) provided is different to the current one.
/// </summary>
[Instrumented]
private Dictionary<string, object?>? GetUpdatedImmutableTracerSettings(object? automaticTracer, ref object? automaticSettings)
private IDictionary<string, object?>? GetUpdatedImmutableTracerSettings(object? automaticTracer, ref object? automaticSettings)
{
_ = automaticTracer;
_ = automaticSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tr
AssemblyName = "Datadog.Trace.Manual",
TypeName = "Datadog.Trace.Tracer",
MethodName = "GetUpdatedImmutableTracerSettings",
ReturnTypeName = "System.Collections.Generic.Dictionary`2[System.String,System.Object]",
ReturnTypeName = "System.Collections.Generic.IDictionary`2[System.String,System.Object]",
ParameterTypeNames = [ClrNames.Object, "System.Object&"],
MinimumVersion = "3.7.0", // added in 3.7.0
MaximumVersion = ManualInstrumentationConstants.MaxVersion,
Expand All @@ -41,8 +41,8 @@ internal static CallTargetState OnMethodBegin<TTarget>(TTarget instance, ref obj
return CallTargetState.GetDefault();
}

internal static CallTargetReturn<Dictionary<string, object?>?> OnMethodEnd<TTarget>(TTarget instance, Dictionary<string, object?>? returnValue, Exception? exception, in CallTargetState state)
internal static CallTargetReturn<IDictionary<string, object?>?> OnMethodEnd<TTarget>(TTarget instance, IDictionary<string, object?>? returnValue, Exception? exception, in CallTargetState state)
{
return new CallTargetReturn<Dictionary<string, object?>?>(state.State as Dictionary<string, object?>);
return new CallTargetReturn<IDictionary<string, object?>?>(state.State as Dictionary<string, object?>);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static InstrumentationDefinitions()
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("get_ActiveScope"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("Datadog.Trace.IScope"), 1, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.GetActiveScopeIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("get_DefaultServiceName"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("System.String"), 1, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.GetDefaultServiceNameIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("GetAutomaticTracerInstance"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("System.Object"), 1, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.GetAutomaticTracerInstanceIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("GetUpdatedImmutableTracerSettings"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("System.Collections.Generic.Dictionary`2[System.String,System.Object]", "System.Object", "System.Object&"), 3, 3, 7, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.GetUpdatedImmutableTracerSettingsIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("GetUpdatedImmutableTracerSettings"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("System.Collections.Generic.IDictionary`2[System.String,System.Object]", "System.Object", "System.Object&"), 3, 3, 7, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.GetUpdatedImmutableTracerSettingsIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("StartActive"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("Datadog.Trace.IScope", "System.String", "Datadog.Trace.ISpanContext", "System.String", "System.Nullable`1[System.DateTimeOffset]", "System.Nullable`1[System.Boolean]"), 6, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.StartActiveImplementationIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("StartActive"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("Datadog.Trace.IScope", "System.String"), 2, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.StartActiveOperationNameIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("StartActive"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("Datadog.Trace.IScope", "System.String", "Datadog.Trace.SpanCreationSettings"), 3, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.StartActiveSpanCreationSettingsIntegration"), 0, 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static InstrumentationDefinitions()
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("get_ActiveScope"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("Datadog.Trace.IScope"), 1, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.GetActiveScopeIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("get_DefaultServiceName"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("System.String"), 1, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.GetDefaultServiceNameIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("GetAutomaticTracerInstance"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("System.Object"), 1, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.GetAutomaticTracerInstanceIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("GetUpdatedImmutableTracerSettings"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("System.Collections.Generic.Dictionary`2[System.String,System.Object]", "System.Object", "System.Object&"), 3, 3, 7, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.GetUpdatedImmutableTracerSettingsIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("GetUpdatedImmutableTracerSettings"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("System.Collections.Generic.IDictionary`2[System.String,System.Object]", "System.Object", "System.Object&"), 3, 3, 7, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.GetUpdatedImmutableTracerSettingsIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("StartActive"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("Datadog.Trace.IScope", "System.String", "Datadog.Trace.ISpanContext", "System.String", "System.Nullable`1[System.DateTimeOffset]", "System.Nullable`1[System.Boolean]"), 6, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.StartActiveImplementationIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("StartActive"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("Datadog.Trace.IScope", "System.String"), 2, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.StartActiveOperationNameIntegration"), 0, 1),
new (NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Manual"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.Tracer"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("StartActive"), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16StringArray("Datadog.Trace.IScope", "System.String", "Datadog.Trace.SpanCreationSettings"), 3, 3, 0, 0, 3, 65535, 65535, NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String(assemblyFullName), NativeCallTargetUnmanagedMemoryHelper.AllocateAndWriteUtf16String("Datadog.Trace.ClrProfiler.AutoInstrumentation.ManualInstrumentation.Tracer.StartActiveSpanCreationSettingsIntegration"), 0, 1),
Expand Down
Loading

0 comments on commit ad3394e

Please sign in to comment.