private void AzureSearchHttpParserConvertsValidDependencies( string operation, string verb, string url, Dictionary <string, string> properties) { var parsedUrl = new Uri(url); // Parse with verb var d = new DependencyTelemetry( dependencyTypeName: RemoteDependencyConstants.HTTP, target: parsedUrl.Host, dependencyName: verb + " " + parsedUrl.AbsolutePath, data: parsedUrl.OriginalString); var success = AzureSearchHttpParser.TryParse(ref d); Assert.IsTrue(success, operation); Assert.AreEqual(RemoteDependencyConstants.AzureSearch, d.Type, operation); Assert.AreEqual(parsedUrl.Host, d.Target, operation); Assert.AreEqual(operation, d.Name, operation); if (properties != null) { foreach (var property in properties) { Assert.IsTrue(d.Properties.TryGetValue(property.Key, out var value), operation); Assert.AreEqual(property.Value, value, operation); } } // Parse without verb d = new DependencyTelemetry( dependencyTypeName: RemoteDependencyConstants.HTTP, target: parsedUrl.Host, dependencyName: parsedUrl.AbsolutePath, data: parsedUrl.OriginalString); success = AzureSearchHttpParser.TryParse(ref d); Assert.IsTrue(success, operation); Assert.AreEqual(RemoteDependencyConstants.AzureSearch, d.Type, operation); Assert.AreEqual(parsedUrl.Host, d.Target, operation); string moniker = AzureSearchHttpParser.BuildOperationMoniker(null, AzureSearchHttpParser.ParseResourcePath(parsedUrl.AbsolutePath)); Assert.AreEqual(moniker, d.Name, operation); if (properties != null) { foreach (var property in properties) { Assert.IsTrue(d.Properties.TryGetValue(property.Key, out var value), operation); Assert.AreEqual(property.Value, value, 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) || AzureSearchHttpParser.TryParse(ref httpDependency); } }