Skip to content

Commit

Permalink
pr-fix: minimize trace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnmoreels committed Aug 1, 2024
1 parent 5e2b926 commit ab45203
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] traces = await client.GetTracesAsync();
AssertX.Any(traces, trace =>
{
Assert.Equal(message, trace.Message);
Assert.Equal(message, trace.Trace.Message);
});
});
}
Expand Down Expand Up @@ -74,7 +74,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] traces = await client.GetTracesAsync();
AssertX.Any(traces, trace =>
{
Assert.Equal(message, trace.Message);
Assert.Equal(message, trace.Trace.Message);
});
});
}
Expand All @@ -98,7 +98,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] traces = await client.GetTracesAsync();
AssertX.Any(traces, trace =>
{
Assert.Equal(message, trace.Message);
Assert.Equal(message, trace.Trace.Message);
});
});
}
Expand All @@ -125,7 +125,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] traces = await client.GetTracesAsync();
AssertX.Any(traces, trace =>
{
Assert.Equal(message, trace.Message);
Assert.Equal(message, trace.Trace.Message);
});
});
}
Expand Down Expand Up @@ -153,7 +153,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] result = await client.GetTracesAsync();
AssertX.Any(result, trace =>
{
Assert.Equal(message, trace.Message);
Assert.Equal(message, trace.Trace.Message);
Assert.Equal(correlation.TransactionId, trace.Operation.Id);
Assert.Equal(correlation.OperationId, trace.Operation.ParentId);
});
Expand Down Expand Up @@ -183,7 +183,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] result = await client.GetTracesAsync();
AssertX.Any(result, trace =>
{
Assert.Equal(message, trace.Message);
Assert.Equal(message, trace.Trace.Message);
Assert.Equal(correlation.TransactionId, trace.Operation.Id);
Assert.Equal(correlation.OperationId, trace.Operation.ParentId);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] results = await client.GetTracesAsync();
AssertX.Any(results, trace =>
{
Assert.Equal(message, trace.Message);
Assert.Equal(message, trace.Trace.Message);
Assert.Equal(componentName, trace.RoleName);
});
});
Expand Down Expand Up @@ -109,7 +109,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] traceEvents = await client.GetTracesAsync();
AssertX.Any(traceEvents, trace =>
{
Assert.Equal(message, trace.Message);
Assert.Equal(message, trace.Trace.Message);
Assert.Equal(operationId, Assert.Contains(ContextProperties.Correlation.OperationId, trace.CustomDimensions));
Assert.Equal(transactionId, Assert.Contains(ContextProperties.Correlation.TransactionId, trace.CustomDimensions));
Assert.Equal(operationParentId, Assert.Contains(ContextProperties.Correlation.OperationParentId, trace.CustomDimensions));
Expand Down Expand Up @@ -145,7 +145,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] traceEvents = await client.GetTracesAsync();
AssertX.Any(traceEvents, trace =>
{
Assert.Equal(message, trace.Message);
Assert.Equal(message, trace.Trace.Message);
Assert.Equal(nodeName, Assert.Contains(ContextProperties.Kubernetes.NodeName, trace.CustomDimensions));
Assert.Equal(podName, Assert.Contains(ContextProperties.Kubernetes.PodName, trace.CustomDimensions));
Assert.Equal(@namespace, Assert.Contains(ContextProperties.Kubernetes.Namespace, trace.CustomDimensions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,29 @@ public class EventsTraceResult
{
public EventsTraceResult(string message, string roleName, OperationResult operation, IDictionary<string, string> customDimensions)
{
Message = message;
Trace = new TraceResult(message);
RoleName = roleName;
Operation = operation;
CustomDimensions = customDimensions;
}

public string Message { get; }
public TraceResult Trace { get; }
public string RoleName { get; }
public OperationResult Operation { get; }
public IDictionary<string, string> CustomDimensions { get; }

public class TraceResult
{
/// <summary>
/// Initializes a new instance of the <see cref="TraceResult" /> class.
/// </summary>
public TraceResult(string message)
{
Message = message;
}

public string Message { get; }
}
}

public class EventsCustomEventResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] results = await client.GetTracesAsync();
AssertX.Any(results, result =>
{
Assert.Contains(message, result.Message);
Assert.Contains(message, result.Trace.Message);
});
});
}
Expand All @@ -52,7 +52,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] results = await client.GetTracesAsync();
AssertX.Any(results, result =>
{
Assert.Contains(message, result.Message);
Assert.Contains(message, result.Trace.Message);
Assert.True(result.CustomDimensions.TryGetValue(key, out string actual), "Should contain custom dimension property");
Assert.Equal(expected, actual);
});
Expand All @@ -78,7 +78,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] results = await client.GetTracesAsync();
AssertX.Any(results, result =>
{
Assert.Contains(message, result.Message);
Assert.Contains(message, result.Trace.Message);
Assert.True(result.CustomDimensions.TryGetValue(key, out string actual), "Should contain custom dimension property");
Assert.Equal(expected, actual);
});
Expand All @@ -104,7 +104,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsTraceResult[] results = await client.GetTracesAsync();
AssertX.Any(results, result =>
{
Assert.Contains(message, result.Message);
Assert.Contains(message, result.Trace.Message);
Assert.True(result.CustomDimensions.TryGetValue(key, out string actual), "Should contain custom dimension property");
Assert.Equal(expected, actual);
});
Expand Down

0 comments on commit ab45203

Please sign in to comment.