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 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); }
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); }
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 bool ForEach(KeyValuePair <string, object> activityTag) { if (activityTag.Value == null) { return(true); } if (activityTag.Value is Array array) { StringBuilder sw = new StringBuilder(); foreach (var item in array) { // TODO: Consider changing it to JSon array. if (item != null) { sw.Append(item); sw.Append(','); } } if (sw.Length > 0) { sw.Length--; } AzMonList.Add(ref PartCTags, new KeyValuePair <string, object>(activityTag.Key, sw.ToString())); return(true); } if (!Part_B_Mapping.TryGetValue(activityTag.Key, out tempActivityType)) { AzMonList.Add(ref PartCTags, activityTag); return(true); } if (activityType == PartBType.Unknown || activityType == PartBType.Common) { activityType = tempActivityType; } if (tempActivityType == activityType || tempActivityType == PartBType.Common) { AzMonList.Add(ref PartBTags, activityTag); } else { AzMonList.Add(ref PartCTags, activityTag); } return(true); }
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 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 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 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); }