public void FormatTraceId_should_correctly_format_trace_context_with_full_trace_id() { var context = new TraceContext(Guid.NewGuid(), Guid.NewGuid()); var expectedValue = $"{context.TraceId:N}"; TracingLogPropertiesFormatter.FormatTraceId(context).Should().Be(expectedValue); }
public void FormatSpanIdPrefix_should_produce_same_result_as_a_substring_of_guids_tostring() { var context = new TraceContext(Guid.NewGuid(), Guid.NewGuid()); var expectedValue = context.SpanId.ToString().Substring(0, 8); TracingLogPropertiesFormatter.FormatSpanIdPrefix(context).Should().Be(expectedValue); }
public async Task InvokeAsync(HttpContext context) { var requestInfo = FlowingContext.Globals.Get <IRequestInfo>(); using (var spanBuilder = tracer.BeginHttpServerSpan()) using (new OperationContextToken( TracingLogPropertiesFormatter.FormatPrefix( spanBuilder.CurrentSpan.ParentSpanId ?? spanBuilder.CurrentSpan.SpanId) ?? string.Empty)) { spanBuilder.SetClientDetails(requestInfo?.ClientApplicationIdentity, requestInfo?.ClientIpAddress); spanBuilder.SetRequestDetails(context.Request.Path, context.Request.Method, context.Request.ContentLength); SetResponseHeaderIfRequired(context, spanBuilder); await next(context); SetResponseHeaderIfRequired(context, spanBuilder); spanBuilder.SetResponseDetails(context.Response.StatusCode, context.Response.ContentLength); } }
public void FormatTraceId_should_return_null_for_null_context() => TracingLogPropertiesFormatter.FormatTraceId(null).Should().BeNull();
public void FormatSpanIdPrefix_should_return_null_for_null_context() => TracingLogPropertiesFormatter.FormatSpanIdPrefix(null).Should().BeNull();