in src/LibraryTest/Library/TelemetryGeneratorTests.cs [730:826]
public void TelemetryGeneratorTests_AvailabilityProbeIsHandledCorrectlyThroughIngressGateway()
{
// ARRANGE
var telemetryGenerator = new TelemetryGenerator(new []{"default"}, new string[]{});
// incoming request, reported by outbound proxy of the gateway
var instance1 = Common.GetStandardInstanceMsg();
instance1.SpanTags["context.reporter.uid"].StringValue = "kubernetes://istio-ingressgateway";
instance1.SpanTags["context.reporter.kind"].StringValue = "outbound";
instance1.SpanTags["source.uid"].StringValue = "kubernetes://istio-ingressgateway.istio-system";
instance1.SpanTags["source.workload.namespace"].StringValue = "istio-system";
instance1.SpanTags["source.workload.name"].StringValue = "istio-ingressgateway";
instance1.SpanTags["source.name"].StringValue = "istio-ingressgateway";
instance1.SpanTags["source.labels.appinsights.monitoring.enabled"].StringValue = "";
instance1.SpanTags["source.labels.istio.isingressgateway"].BoolValue = true;
instance1.SpanTags["source.role.name"].StringValue = "istio-ingressway";
instance1.SpanTags["source.role.instance"].StringValue = "istio-ingressway-1";
instance1.SpanTags["destination.uid"].StringValue = "kubernetes://destination-deployment-1.default";
instance1.SpanTags["destination.workload.namespace"].StringValue = "default";
instance1.SpanTags["destination.workload.name"].StringValue = "destination-deployment";
instance1.SpanTags["destination.name"].StringValue = "destination-deployment-1";
instance1.SpanTags["destination.labels.appinsights.monitoring.enabled"].StringValue = "";
instance1.SpanTags["destination.role.name"].StringValue = "destination-deployment";
instance1.SpanTags["destination.role.instance"].StringValue = "destination-deployment-1";
instance1.SpanTags["request.scheme"].StringValue = "http";
instance1.SpanTags["request.path"].StringValue = "/some/path";
instance1.SpanTags["http.useragent"].StringValue = "GSM";
instance1.SpanTags["host"].StringValue = "destination-deployment-1";
instance1.SpanTags["http.status_code"].StringValue = "200";
instance1.SpanTags["http.path"].StringValue = "/some/path";
instance1.SpanTags["http.method"].StringValue = "GET";
instance1.SpanTags["destination.port"].StringValue = "8888";
instance1.SpanTags["request.headers.request.id"].StringValue = "|29b9f7da25a34eb183dfa589c30ee9e9.0";
instance1.SpanTags["request.headers.synthetictest.runid"].StringValue = "29b9f7da25a34eb183dfa589c30ee9e9";
instance1.SpanTags["request.headers.synthetictest.location"].StringValue = "us-va-ash-azr";
instance1.SpanTags["request.headers.request.context"].StringValue = "appId=cid-v1:b146db49-7bee-425a-9dc5-a302329eb7b2";
instance1.SpanTags["response.headers.request.context"].StringValue = "";
// same incoming request, reported by inbound proxy of the destination-deployment-1 pod
var instance2 = Common.GetStandardInstanceMsg();
instance2.SpanTags["context.reporter.uid"].StringValue = "kubernetes://destination-deployment-1";
instance2.SpanTags["context.reporter.kind"].StringValue = "inbound";
instance2.SpanTags["source.uid"].StringValue = "kubernetes://istio-ingressgateway.istio-system";
instance2.SpanTags["source.workload.namespace"].StringValue = "istio-system";
instance2.SpanTags["source.workload.name"].StringValue = "istio-ingressgateway";
instance2.SpanTags["source.name"].StringValue = "istio-ingressgateway";
instance2.SpanTags["source.labels.appinsights.monitoring.enabled"].StringValue = "";
instance2.SpanTags["source.labels.istio.isingressgateway"].BoolValue = true;
instance2.SpanTags["source.role.name"].StringValue = "istio-ingressway";
instance2.SpanTags["source.role.instance"].StringValue = "istio-ingressway-1";
instance2.SpanTags["destination.uid"].StringValue = "kubernetes://destination-deployment-1.default";
instance2.SpanTags["destination.workload.namespace"].StringValue = "default";
instance2.SpanTags["destination.workload.name"].StringValue = "destination-deployment";
instance2.SpanTags["destination.name"].StringValue = "destination-deployment-1";
instance2.SpanTags["destination.labels.appinsights.monitoring.enabled"].StringValue = "";
instance2.SpanTags["destination.role.name"].StringValue = "destination-deployment";
instance2.SpanTags["destination.role.instance"].StringValue = "destination-deployment-1";
instance2.SpanTags["request.scheme"].StringValue = "http";
instance2.SpanTags["request.path"].StringValue = "/some/path";
instance2.SpanTags["http.useragent"].StringValue = "GSM";
instance2.SpanTags["host"].StringValue = "destination-deployment-1";
instance2.SpanTags["http.status_code"].StringValue = "200";
instance2.SpanTags["http.path"].StringValue = "/some/path";
instance2.SpanTags["http.method"].StringValue = "GET";
instance2.SpanTags["destination.port"].StringValue = "8888";
instance2.SpanTags["request.headers.request.id"].StringValue = "|29b9f7da25a34eb183dfa589c30ee9e9.0";
instance2.SpanTags["request.headers.synthetictest.runid"].StringValue = "29b9f7da25a34eb183dfa589c30ee9e9";
instance2.SpanTags["request.headers.synthetictest.location"].StringValue = "us-va-ash-azr";
instance2.SpanTags["request.headers.request.context"].StringValue = "appId=cid-v1:b146db49-7bee-425a-9dc5-a302329eb7b2";
instance2.SpanTags["response.headers.request.context"].StringValue = "";
// ACT
ITelemetry[] telemetryItems = telemetryGenerator.Generate(instance1, instance2).ToArray();
// ASSERT
// 2 items for gateway, 1 items for destination-deployment
Assert.AreEqual(3, telemetryItems.Length);
var gatewayRequest = telemetryItems[0] as RequestTelemetry;
var gatewayDependency = telemetryItems[1] as DependencyTelemetry;
var destinationRequest = telemetryItems[2] as RequestTelemetry;
Assert.IsNotNull(gatewayRequest);
Assert.IsNotNull(gatewayDependency);
Assert.IsNotNull(destinationRequest);
ValidateTelemetrySource(gatewayRequest, "istio-ingressgateway", "istio-ingressgateway", "istio-system", "destination-deployment-1", "destination-deployment", "default", "kubernetes://destination-deployment-1", "inbound");
ValidateTelemetrySource(gatewayDependency, "istio-ingressgateway", "istio-ingressgateway", "istio-system", "destination-deployment-1", "destination-deployment", "default", "kubernetes://destination-deployment-1", "inbound");
ValidateTelemetrySource(destinationRequest, "istio-ingressgateway", "istio-ingressgateway", "istio-system", "destination-deployment-1", "destination-deployment", "default", "kubernetes://destination-deployment-1", "inbound");
ValidateTelemetryOperationData(gatewayRequest, @"^\|29b9f7da25a34eb183dfa589c30ee9e9.0[A-Za-z0-9]{8}_$", @"^\|29b9f7da25a34eb183dfa589c30ee9e9\.0$", @"^29b9f7da25a34eb183dfa589c30ee9e9$");
ValidateTelemetryOperationData(gatewayDependency, @"^\|29b9f7da25a34eb183dfa589c30ee9e9.0[A-Za-z0-9]{8}_[A-Za-z0-9]{8}\.$", @"^\|29b9f7da25a34eb183dfa589c30ee9e9.0[A-Za-z0-9]{8}_$", @"^29b9f7da25a34eb183dfa589c30ee9e9$");
ValidateTelemetryOperationData(destinationRequest, @"^\|29b9f7da25a34eb183dfa589c30ee9e9.0[A-Za-z0-9]{8}_[A-Za-z0-9]{8}\.[A-Za-z0-9]{8}_$", @"^\|29b9f7da25a34eb183dfa589c30ee9e9.0[A-Za-z0-9]{8}_[A-Za-z0-9]{8}\.$", @"^29b9f7da25a34eb183dfa589c30ee9e9$");
Assert.AreEqual(gatewayRequest.Id, gatewayDependency.Context.Operation.ParentId);
Assert.AreEqual(gatewayDependency.Id, destinationRequest.Context.Operation.ParentId);
}