public void DbDependencyTargetIsSetToNullByDefault() { var PartBTags = AzMonList.Initialize(); string target = PartBTags.GetDbDependencyTarget(); Assert.Null(target); }
public void HttpDependencyTargetIsSetUsingHttpUrl(string port) { var PartBTags = AzMonList.Initialize(); if (port == "80") { AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpUrl, $"http://www.wiki.com:{port}/")); } else { AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpUrl, $"https://www.wiki.com:{port}/")); } string expectedTarget; if (port == "80" || port == "443") { expectedTarget = "www.wiki.com"; } else { expectedTarget = $"www.wiki.com:{port}"; } string target = PartBTags.GetDependencyTarget(PartBType.Http); Assert.Equal(expectedTarget, target); }
public void HttpUrlIsNullByDefault() { var PartBTags = AzMonList.Initialize(); Assert.Null(PartBTags.GetRequestUrl()); Assert.Null(PartBTags.GetDependencyUrl()); }
public void HttpDependencyUrlIsSetUsing_Scheme_PeerIp_Port_Target(string port) { var PartBTags = AzMonList.Initialize(); string httpScheme; if (port == "80") { httpScheme = "http"; } else { httpScheme = "https"; } AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, httpScheme)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerIp, "127.0.0.1")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerPort, port)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpTarget, "/path")); string expectedUrl; if (port == "80" || port == "443") { expectedUrl = $"{httpScheme}://127.0.0.1/path"; } else { expectedUrl = $"{httpScheme}://127.0.0.1:{port}/path"; } string url = PartBTags.GetDependencyUrl(); Assert.Equal(expectedUrl, url); }
public void HttpRequestUrlIsSetUsing_Scheme_NetHostName_Port_Target(string port) { var PartBTags = AzMonList.Initialize(); string httpScheme; if (port == "80") { httpScheme = "http"; } else { httpScheme = "https"; } AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, httpScheme)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetHostName, "localhost")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetHostPort, port)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpTarget, "/path")); string expectedUrl; if (port == "80" || port == "443") { expectedUrl = $"{httpScheme}://localhost/path"; } else { expectedUrl = $"{httpScheme}://localhost:{port}/path"; } string url = PartBTags.GetRequestUrl(); Assert.Equal(expectedUrl, url); }
public void DbNameIsAppendedToTargetDerivedFromNetAttributesforDBDependencyTarget(string peerService, string netPeerName, string netPeerIp, string netPeerPort) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributePeerService, peerService)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerName, netPeerName)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerIp, netPeerIp)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerPort, netPeerPort)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeDbName, "DbName")); string hostName = null; if (peerService != null) { hostName = peerService; } if (netPeerName != null) { hostName = $"{netPeerName}:{netPeerPort}"; } if (netPeerIp != null) { hostName = $"{netPeerIp}:{netPeerPort}"; } string expectedTarget = $"{hostName}/DbName"; string target = PartBTags.GetDbDependencyTarget(); Assert.Equal(expectedTarget, target); }
internal void DependencyTargetIsNullByDefault(PartBType type) { var PartBTags = AzMonList.Initialize(); string target = PartBTags.GetDependencyTarget(type); Assert.Null(target); }
public void GetUrl_Null() { var PartBTags = AzMonList.Initialize(); PartBTags.GenerateUrlAndAuthority(out var url, out var urlAuthority); Assert.Null(url); Assert.Null(urlAuthority); }
public void DbDependencyTargetIsSetToDbSystemWhenNetAndDbNameAttributesAreNotPresent() { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeDbSystem, "DbSystem")); string target = PartBTags.GetDbDependencyTarget(); Assert.Equal("DbSystem", target); }
internal void DependencyTargetIsSetUsingPeerService(PartBType type) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributePeerService, "servicename")); string expectedTarget = "servicename"; string target = PartBTags.GetDependencyTarget(type); Assert.Equal(expectedTarget, target); }
public void GetUrl_HttpUrl_Success() { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpUrl, "https://www.wiki.com")); PartBTags.GenerateUrlAndAuthority(out var url, out var urlAuthority); Assert.Equal("https://www.wiki.com/", url); Assert.Equal("www.wiki.com", urlAuthority); }
public void HttpDependencyUrlIsSetUsingHttpUrl() { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpUrl, "https://www.wiki.com")); string url = PartBTags.GetDependencyUrl(); Assert.Equal("https://www.wiki.com", url); }
private static TagEnumerationState EnumerateActivityTags(Activity activity) { var monitorTags = new TagEnumerationState { PartBTags = AzMonList.Initialize(), PartCTags = AzMonList.Initialize() }; activity.EnumerateTags(ref monitorTags); return(monitorTags); }
public void GetUrl_With_HttpScheme_And_Null_HttpHost() { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, null)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpHost, null)); PartBTags.GenerateUrlAndAuthority(out var url, out var urlAuthority); Assert.Null(url); Assert.Null(urlAuthority); }
internal static TagEnumerationState EnumerateActivityTags(Activity activity) { var monitorTags = new TagEnumerationState { PartBTags = AzMonList.Initialize(), PartCTags = AzMonList.Initialize() }; monitorTags.ForEach(activity.TagObjects); return(monitorTags); }
public void NetPeerIpAttributeTakesPrecedenceSettingHttpDependencyUrl() { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, "http")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerIp, "127.0.0.1")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerPort, "8888")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpTarget, "/path")); string expectedUrl = "http://127.0.0.1:8888/path"; string url = PartBTags.GetDependencyUrl(); Assert.Equal(expectedUrl, url); }
public void GetUrl_NetPeerName_Success(string scheme, string peerName, string peerPort, string target) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, scheme)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerName, peerName)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerPort, peerPort)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpTarget, target)); PartBTags.GenerateUrlAndAuthority(out var url, out var urlAuthority); Assert.Equal($"https://localhost:443{target}", url); Assert.Equal($"localhost:443", urlAuthority); }
public void NetHostNameAttributeTakesPrecedenceSettingHttpRequestUrl() { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, "http")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetHostName, "localhost")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetHostPort, "8888")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpTarget, "/path")); string expectedUrl = "http://localhost:8888/path"; string url = PartBTags.GetRequestUrl(); Assert.Equal(expectedUrl, url); }
public void GetUrl_HttpPort_NullEmptyOrDefault(string scheme, string httpHost, string hostPort) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, scheme)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpHost, httpHost)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpHostPort, hostPort)); PartBTags.GenerateUrlAndAuthority(out var url, out var urlAuthority); Assert.Equal("https://localhost", url); Assert.Equal("localhost", urlAuthority); }
internal void PeerIpTakesPrecedenceSettingDependencyTarget(PartBType type) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, "http")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeDbSystem, "mssql")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerIp, $"127.0.0.1")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerPort, "8888")); string expectedTarget = "127.0.0.1:8888"; string target = PartBTags.GetDependencyTarget(type); Assert.Equal(expectedTarget, target); }
public void GetUrl_HttpPort_RandomPort_With_HttpTarget(string scheme, string httpHost, string hostPort, string target) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, scheme)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpHost, httpHost)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpHostPort, hostPort)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpTarget, target)); PartBTags.GenerateUrlAndAuthority(out var url, out var urlAuthority); hostPort = hostPort == "8888" ? ":8888" : null; Assert.Equal($"{scheme}://localhost{hostPort}{target}", url); Assert.Equal($"localhost{hostPort}", urlAuthority); }
public void HttpUrlTakesPrecedenceSettingHttpDependencyTarget() { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpUrl, $"http://www.wiki.com:8888/")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, "http")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerName, $"servername.com")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerIp, $"127.0.0.1")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerPort, "8888")); string expectedTarget = "www.wiki.com:8888"; string target = PartBTags.GetDependencyTarget(PartBType.Http); Assert.Equal(expectedTarget, target); }
public void GetUrl_NullOrEmpty(string attribute) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(attribute, null)); PartBTags.GenerateUrlAndAuthority(out var url, out var urlAuthority); Assert.Null(url); Assert.Null(urlAuthority); AzMonList.Clear(ref PartBTags); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(attribute, string.Empty)); PartBTags.GenerateUrlAndAuthority(out url, out urlAuthority); Assert.Null(url); Assert.Null(urlAuthority); }
public void HttpUrlAttributeTakesPrecedenceSettingHttpDependencyUrl() { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpUrl, "https://www.wiki.com")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, "http")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerName, "servername.com")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpHost, "www.httphost.org")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerIp, "127.0.0.1")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerPort, "8888")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpTarget, "/path")); string expectedUrl = "https://www.wiki.com"; string url = PartBTags.GetDependencyUrl(); Assert.Equal(expectedUrl, url); }
internal void PeerServiceTakesPrecedenceSettingDependencyTarget(PartBType type) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributePeerService, "servicename")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpHost, $"www.httphost.org:8888")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpUrl, $"http://www.wiki.com:8888/")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, "http")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeDbSystem, "mssql")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerName, $"servername.com")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerIp, $"127.0.0.1")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerPort, "8888")); string expectedTarget = "servicename"; string target = PartBTags.GetDependencyTarget(type); Assert.Equal(expectedTarget, target); }
public void HttpDependencyTargetIsSetUsingHttpHost(string httpScheme, string port) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, httpScheme)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpHost, $"www.httphost.org:{port}")); string expectedTarget; if (port == "80" || port == "443") { expectedTarget = "www.httphost.org"; } else { expectedTarget = $"www.httphost.org:{port}"; } string target = PartBTags.GetDependencyTarget(PartBType.Http); Assert.Equal(expectedTarget, target); }
public void GetUrl_NetPeerName_NullOrEmpty(string scheme, string peerName, string peerPort) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, scheme)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerName, peerName)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerPort, peerPort)); PartBTags.GenerateUrlAndAuthority(out var url, out var urlAuthority); if (string.IsNullOrEmpty(peerName)) { Assert.Null(url); Assert.Null(urlAuthority); } else { Assert.Equal("https://netpeername", url); Assert.Equal("netpeername", urlAuthority); } }
public void HttpRequestUrlIsSetUsing_Scheme_Host_Target(string httpScheme, string port) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, httpScheme)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpHost, $"www.httphost.org:{port}")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpTarget, "/path")); string expectedUrl; if (port == "80" || port == "443") { expectedUrl = $"{httpScheme}://www.httphost.org/path"; } else { expectedUrl = $"{httpScheme}://www.httphost.org:{port}/path"; } string url = PartBTags.GetRequestUrl(); Assert.Equal(expectedUrl, url); }
public void GetUrl_HttpHost_Success(string httpHost, string hostPort, string target) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpHost, httpHost)); if (hostPort != "") { AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpHostPort, hostPort)); } if (target != "") { AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpTarget, target)); } PartBTags.GenerateUrlAndAuthority(out var url, out var urlAuthority); hostPort = hostPort == "8888" ? ":8888" : null; Assert.Equal($"localhost{hostPort}{target}", url); Assert.Equal($"localhost{hostPort}", urlAuthority); }
internal void DependencyTargetIsSetUsingNetPeerIp(string httpScheme, string port, PartBType type) { var PartBTags = AzMonList.Initialize(); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeHttpScheme, httpScheme)); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeDbSystem, "mssql")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerIp, $"127.0.0.1")); AzMonList.Add(ref PartBTags, new KeyValuePair <string, object>(SemanticConventions.AttributeNetPeerPort, port)); string expectedTarget; if (port == "80" || port == "443" || port == "1433") { expectedTarget = "127.0.0.1"; } else { expectedTarget = $"127.0.0.1:{port}"; } string target = PartBTags.GetDependencyTarget(type); Assert.Equal(expectedTarget, target); }