Skip to content

Commit

Permalink
pr-fix: cloud result for lesser changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnmoreels committed Aug 1, 2024
1 parent d0e94e4 commit b7304e2
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
Assert.Equal(dependencyType, result.Dependency.Type);
Assert.Equal(accountName, result.Dependency.Target);
Assert.Equal(containerName, result.Dependency.Data);
Assert.Equal(componentName, result.RoleName);
Assert.Equal(componentName, result.Cloud.RoleName);
Assert.Equal(dependencyName, result.Dependency.Name);
Assert.Equal(dependencyId, result.Dependency.Id);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
Assert.Equal(dependencyType, result.Dependency.Type);
Assert.Equal(accountName, result.Dependency.Target);
Assert.Equal(dependencyName, result.Dependency.Data);
Assert.Equal(componentName, result.RoleName);
Assert.Equal(componentName, result.Cloud.RoleName);
Assert.Equal(dependencyName, result.Dependency.Name);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
Assert.True(string.IsNullOrWhiteSpace(result.Request.Url), "request URL should be blank");
Assert.Equal(operationName, result.Operation.Name);
Assert.Equal(isSuccessful, result.Success);
Assert.Equal(componentName, result.RoleName);
Assert.Equal(componentName, result.Cloud.RoleName);
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
Assert.Equal(dependencyType, result.Dependency.Type);
Assert.Equal(eventHubName, result.Dependency.Target);
Assert.Equal(namespaceName, result.Dependency.Data);
Assert.Equal(componentName, result.RoleName);
Assert.Equal(componentName, result.Cloud.RoleName);
Assert.Equal(dependencyName, result.Dependency.Name);
Assert.Equal(dependencyId, result.Dependency.Id);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
Assert.True(string.IsNullOrWhiteSpace(result.Request.Url), "request URL should be blank");
Assert.Equal(operationName, result.Operation.Name);
Assert.Equal(isSuccessful, result.Success);
Assert.Equal(componentName, result.RoleName);
Assert.Equal(componentName, result.Cloud.RoleName);

AssertContainsCustomDimension(result.CustomDimensions, EventHubs.Namespace, eventHubsNamespace);
AssertContainsCustomDimension(result.CustomDimensions, EventHubs.ConsumerGroup, eventHubsConsumerGroup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
AssertX.Any(results, trace =>
{
Assert.Equal(message, trace.Trace.Message);
Assert.Equal(componentName, trace.RoleName);
Assert.Equal(componentName, trace.Cloud.RoleName);
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
AssertX.Any(results, result =>
{
Assert.Equal(exception.Message, result.Exception.OuterMessage);
Assert.Equal(componentName, result.RoleName);
Assert.Equal(componentName, result.Cloud.RoleName);
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
using System.Threading.Tasks;

// ReSharper disable once CheckNamespace
namespace Microsoft.Azure.ApplicationInsights.Query.Models
{
/// <summary>
Expand Down Expand Up @@ -40,38 +41,18 @@ public interface ITelemetryQueryClient
Task<EventsExceptionResult[]> GetExceptionsAsync();
}

public class OperationResult
{
public OperationResult(string id, string parentId)
{
Id = id;
ParentId = parentId;
}

public OperationResult(string id, string parentId, string name)
{
Id = id;
ParentId = parentId;
Name = name;
}

public string Id { get; }
public string Name { get; }
public string ParentId { get; }
}

public class EventsTraceResult
{
public EventsTraceResult(string message, string roleName, OperationResult operation, IDictionary<string, string> customDimensions)
{
Trace = new TraceResult(message);
RoleName = roleName;
Cloud = new CloudResult(roleName);
Operation = operation;
CustomDimensions = customDimensions;
}

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

Expand All @@ -97,12 +78,12 @@ public class EventsCustomEventResult
public EventsCustomEventResult(string name, string roleName, IDictionary<string, string> customDimensions)
{
Name = name;
RoleName = roleName;
Cloud = new CloudResult(roleName);
CustomDimensions = new ReadOnlyDictionary<string, string>(customDimensions);
}

public string Name { get; }
public string RoleName { get; }
public CloudResult Cloud { get; }
public IReadOnlyDictionary<string, string> CustomDimensions { get; }
}

Expand Down Expand Up @@ -134,17 +115,17 @@ public EventsRequestResult(
IDictionary<string, string> customDimensions)
{
Request = new RequestResult(id, name, source, url);
Cloud = new CloudResult(roleName);
Success = success;
ResultCode = resultCode;
RoleName = roleName;
Operation = operation;
CustomDimensions = customDimensions;
}

public RequestResult Request { get; }
public CloudResult Cloud { get; }
public bool Success { get; }
public string ResultCode { get; }
public string RoleName { get; }
public OperationResult Operation { get; }
public IDictionary<string, string> CustomDimensions { get; }

Expand Down Expand Up @@ -183,17 +164,17 @@ public EventsDependencyResult(
IDictionary<string, string> customDimensions)
{
Dependency = new DependencyResult(id, name, type, target, data);
Cloud = new CloudResult(roleName);
Success = success;
ResultCode = resultCode;
RoleName = roleName;
Operation = operation;
CustomDimensions = customDimensions;
}

public DependencyResult Dependency { get; }
public CloudResult Cloud { get; }
public bool Success { get; }
public int ResultCode { get; }
public string RoleName { get; }
public OperationResult Operation { get; }
public IDictionary<string, string> CustomDimensions { get; }

Expand Down Expand Up @@ -227,14 +208,14 @@ public class EventsExceptionResult
public EventsExceptionResult(string message, OperationResult operation, string roleName, IDictionary<string, string> customDimensions)
{
Exception = new ExceptionResult(message);
Cloud = new CloudResult(roleName);
Operation = operation;
RoleName = roleName;
CustomDimensions = customDimensions;
}

public ExceptionResult Exception { get; }
public OperationResult Operation { get; }
public string RoleName { get; }
public CloudResult Cloud { get; }
public IDictionary<string, string> CustomDimensions { get; }

public class ExceptionResult
Expand All @@ -250,4 +231,34 @@ public ExceptionResult(string message)
public string OuterMessage { get; }
}
}

public class CloudResult
{
public CloudResult(string roleName)
{
RoleName = roleName;
}

public string RoleName { get; }
}

public class OperationResult
{
public OperationResult(string id, string parentId)
{
Id = id;
ParentId = parentId;
}

public OperationResult(string id, string parentId, string name)
{
Id = id;
ParentId = parentId;
Name = name;
}

public string Id { get; }
public string Name { get; }
public string ParentId { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
Assert.Equal(requestUri.Host, result.Dependency.Target);
Assert.Equal($"{httpMethod} {requestUri.AbsolutePath}", result.Dependency.Name);
Assert.Equal(dependencyId, result.Dependency.Id);
Assert.Equal(componentName, result.RoleName);
Assert.Equal(componentName, result.Cloud.RoleName);

Assert.Equal(correlation.OperationId, result.Operation.ParentId);
Assert.Equal(correlation.TransactionId, result.Operation.Id);
Expand Down Expand Up @@ -96,7 +96,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
Assert.Equal(requestUri.Host, result.Dependency.Target);
Assert.Equal($"{httpMethod} {requestUri.AbsolutePath}", result.Dependency.Name);
Assert.Equal(dependencyId, result.Dependency.Id);
Assert.Equal(componentName, result.RoleName);
Assert.Equal(componentName, result.Cloud.RoleName);
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
{
Assert.Equal("Azure IoT Hub", result.Dependency.Type);
Assert.Equal(iotHubName, result.Dependency.Target);
Assert.Equal(componentName, result.RoleName);
Assert.Equal(componentName, result.Cloud.RoleName);
Assert.Equal(dependencyName, result.Dependency.Name);
Assert.Equal(dependencyId, result.Dependency.Id);
});
Expand Down Expand Up @@ -77,7 +77,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
{
Assert.Equal("Azure IoT Hub", result.Dependency.Type);
Assert.Equal(hostName, result.Dependency.Target);
Assert.Equal(componentName, result.RoleName);
Assert.Equal(componentName, result.Cloud.RoleName);
Assert.Equal(dependencyName, result.Dependency.Name);
Assert.Equal(dependencyId, result.Dependency.Id);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
Assert.Equal(dependencyType, result.Dependency.Type);
Assert.Equal(accountName, result.Dependency.Target);
Assert.Equal(tableName, result.Dependency.Data);
Assert.Equal(componentName, result.RoleName);
Assert.Equal(componentName, result.Cloud.RoleName);
Assert.Equal(dependencyName, result.Dependency.Name);
Assert.Equal(dependencyId, result.Dependency.Id);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Microsoft.Azure.ApplicationInsights.Query.Models;
using Microsoft.Extensions.Logging;
using Serilog.Events;
using Xunit;
using Xunit.Abstractions;

Expand Down

0 comments on commit b7304e2

Please sign in to comment.