Skip to content

Commit 1ca3271

Browse files
committed
Make TelemetryValue always required when using DefaultResult
1 parent ca11697 commit 1ca3271

File tree

1 file changed

+3
-17
lines changed
  • tracer/src/Datadog.Trace/Configuration/ConfigurationSources/Telemetry

1 file changed

+3
-17
lines changed

tracer/src/Datadog.Trace/Configuration/ConfigurationSources/Telemetry/DefaultResult.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,18 @@
44
// </copyright>
55

66
#nullable enable
7-
using System.Collections.Generic;
87

98
namespace Datadog.Trace.Configuration.ConfigurationSources.Telemetry;
109

11-
internal readonly record struct DefaultResult<T>
10+
internal readonly struct DefaultResult<T>(T result, string telemetryValue)
1211
{
13-
private readonly string? _telemetryValue;
14-
15-
public DefaultResult(T result, string? telemetryValue)
16-
{
17-
Result = result;
18-
_telemetryValue = telemetryValue;
19-
}
20-
2112
/// <summary>
2213
/// Gets the value to use as the default result
2314
/// </summary>
24-
public T Result { get; }
15+
public T Result { get; } = result;
2516

2617
/// <summary>
2718
/// Gets a string representation of the result to use in telemetry.
2819
/// </summary>
29-
public string? TelemetryValue => _telemetryValue ?? Result?.ToString();
30-
31-
public static implicit operator DefaultResult<T>(T result)
32-
=> result is IDictionary<string, string>
33-
? new(result, telemetryValue: string.Empty) // we don't want to call ToString() on these
34-
: new(result, null);
20+
public string TelemetryValue { get; } = telemetryValue;
3521
}

0 commit comments

Comments
 (0)