public void GetRootIdWithNull() { string id = null; var traceContext = new HttpCorrelationProtocolTraceContext(); Assert.IsNull(traceContext.GetRootId(id)); }
public void SetParentAndStartWithNullObject() { var traceContext = new HttpCorrelationProtocolTraceContext(); var parentTraceContext = new NullObjectTraceContext(); traceContext.SetParentAndStart(parentTraceContext); Assert.AreEqual(traceContext.StartTime, traceContext.CurrentActivity.StartTimeUtc); }
public void GetRootIdWithMalformed() { // Currently it doesn't fail and doesn't throw exception. string id = "ea55fd0a-45699198bc3873c3"; var traceContext = new HttpCorrelationProtocolTraceContext(); Assert.AreEqual("ea55fd0a-45699198bc3873c3", traceContext.GetRootId(id)); }
public void GetRootIdNormalCase() { var id = "|ea55fd0a-45699198bc3873c3.ea55fd0b_"; var childId = "|ea55fd0a-45699198bc3873c3.ea55fd0b_ea55fd0c_"; var expected = "ea55fd0a-45699198bc3873c3"; var traceContext = new HttpCorrelationProtocolTraceContext(); Assert.AreEqual(expected, traceContext.GetRootId(id)); Assert.AreEqual(expected, traceContext.GetRootId(childId)); }
internal static void UpdateTelemetryHttpCorrelationProtocol(ITelemetry telemetry, HttpCorrelationProtocolTraceContext context) { OperationTelemetry opTelemetry = telemetry as OperationTelemetry; bool initializeFromCurrent = opTelemetry != null; if (initializeFromCurrent) { initializeFromCurrent &= !(opTelemetry is DependencyTelemetry dependency && dependency.Type == SqlRemoteDependencyType && dependency.Context.GetInternalContext().SdkVersion .StartsWith(RddDiagnosticSourcePrefix, StringComparison.Ordinal)); } if (initializeFromCurrent) { opTelemetry.Id = !string.IsNullOrEmpty(opTelemetry.Id) ? opTelemetry.Id : context.TelemetryId; telemetry.Context.Operation.ParentId = !string.IsNullOrEmpty(telemetry.Context.Operation.ParentId) ? telemetry.Context.Operation.ParentId : context.TelemetryContextOperationParentId; } else { telemetry.Context.Operation.Id = !string.IsNullOrEmpty(telemetry.Context.Operation.Id) ? telemetry.Context.Operation.Id : context.TelemetryContextOperationId; if (telemetry is ExceptionTelemetry) { telemetry.Context.Operation.ParentId = context.TelemetryId; } else { telemetry.Context.Operation.ParentId = !string.IsNullOrEmpty(telemetry.Context.Operation.ParentId) ? telemetry.Context.Operation.ParentId : context.TelemetryContextOperationParentId; } } }