Skip to content

Commit 82c95d6

Browse files
authored
Removing Forgiven Nulls (#7745)
## Summary of changes Fixing some nulls I added when rushing in my previous OTLP Logs PR. ## Reason for change Is a most do. ## Implementation details ## Test coverage ## Other details <!-- Fixes #{issue} --> <!-- ⚠️ Note: Where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. MergeQueue is NOT enabled in this repository. If you have write access to the repo, the PR has 1-2 approvals (see above), and all of the required checks have passed, you can use the Squash and Merge button to merge the PR. If you don't have write access, or you need help, reach out in the #apm-dotnet channel in Slack. -->
1 parent 3dd9e0b commit 82c95d6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Logging/ILogger/DirectSubmission/Formatting/OtlpLogEventBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ private static (TraceId TraceId, ulong SpanId, int Flags) ExtractTraceContext()
8383
var ddSpan = Tracer.Instance.ActiveScope?.Span as Span;
8484
if (ddSpan != null)
8585
{
86-
return (ddSpan.TraceId128, ddSpan.SpanId, SamplingPriorityValues.IsKeep(ddSpan.Context.SamplingPriority!.Value) ? 1 : 0);
86+
var flags = ddSpan.Context.SamplingPriority is { } samplingPriority && SamplingPriorityValues.IsKeep(samplingPriority) ? 1 : 0;
87+
return (ddSpan.TraceId128, ddSpan.SpanId, flags);
8788
}
8889

8990
var activity = System.Diagnostics.Activity.Current;

tracer/src/Datadog.Trace/OpenTelemetry/Logs/OtlpExporter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ private Task<bool> SendHttpProtobufRequest(byte[] otlpPayload)
187187
try
188188
{
189189
var deadline = DateTime.UtcNow.AddMilliseconds(_timeoutMs);
190-
var resp = _httpExportClient!.SendExportRequest(
190+
var resp = _httpExportClient?.SendExportRequest(
191191
otlpPayload,
192192
otlpPayload.Length,
193193
deadline);
194194

195-
return Task.FromResult(resp.Success);
195+
return Task.FromResult(resp is { Success: true });
196196
}
197197
catch (Exception ex)
198198
{
@@ -218,11 +218,11 @@ private Task<bool> SendGrpcRequest(byte[] otlpPayload)
218218
(uint)dataLength);
219219

220220
var deadline = DateTime.UtcNow.AddMilliseconds(_timeoutMs);
221-
var resp = _grpcClient!.SendExportRequest(
221+
var resp = _grpcClient?.SendExportRequest(
222222
otlpPayload,
223223
otlpPayload.Length,
224224
deadline);
225-
return Task.FromResult(resp.Success);
225+
return Task.FromResult(resp is { Success: true });
226226
}
227227
catch (Exception ex)
228228
{

0 commit comments

Comments
 (0)