private void AzureServiceBusHttpParserConvertsValidDependencies( string operation, string verb, string url) { Uri parsedUrl = new Uri(url); // Parse with verb var d = new DependencyTelemetry( dependencyTypeName: RemoteDependencyConstants.HTTP, target: parsedUrl.Host, dependencyName: verb + " " + parsedUrl.AbsolutePath, data: parsedUrl.OriginalString); bool success = AzureServiceBusHttpParser.TryParse(ref d); Assert.IsTrue(success, operation); Assert.AreEqual(RemoteDependencyConstants.AzureServiceBus, d.Type, operation); Assert.AreEqual(parsedUrl.Host, d.Target, operation); // Parse without verb d = new DependencyTelemetry( dependencyTypeName: RemoteDependencyConstants.HTTP, target: parsedUrl.Host, dependencyName: parsedUrl.AbsolutePath, data: parsedUrl.OriginalString); success = AzureServiceBusHttpParser.TryParse(ref d); Assert.IsTrue(success, operation); Assert.AreEqual(RemoteDependencyConstants.AzureServiceBus, d.Type, operation); Assert.AreEqual(parsedUrl.Host, d.Target, operation); }
/// <summary> /// If telemetry item is http dependency - converts it to the well-known type of the dependency. /// </summary> /// <param name="telemetry">Telemetry item to convert.</param> public void Initialize(ITelemetry telemetry) { var httpDependency = telemetry as DependencyTelemetry; if (httpDependency != null && httpDependency.Type != null && httpDependency.Type.Equals(RemoteDependencyConstants.HTTP, StringComparison.OrdinalIgnoreCase)) { bool parsed = AzureBlobHttpParser.TryParse(ref httpDependency) || AzureTableHttpParser.TryParse(ref httpDependency) || AzureQueueHttpParser.TryParse(ref httpDependency) || DocumentDbHttpParser.TryParse(ref httpDependency) || AzureServiceBusHttpParser.TryParse(ref httpDependency) || GenericServiceHttpParser.TryParse(ref httpDependency) || AzureIotHubHttpParser.TryParse(ref httpDependency); } }