Replace references to SpanAttributeConstants with constants from SemanticConventions (#828)
* Replace references to SpanAttributeConstants with constants from SemanticConventions * Missed a few references to the "component" attribute in some tests. Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
parent
52955d3f1f
commit
b319c0bed6
|
|
@ -22,36 +22,13 @@ namespace OpenTelemetry.Trace
|
|||
public static class SpanAttributeConstants
|
||||
{
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
public const string ComponentKey = "component";
|
||||
public const string PeerServiceKey = "peer.service";
|
||||
|
||||
public const string StatusCodeKey = "ot.status_code";
|
||||
public const string StatusDescriptionKey = "ot.status_description";
|
||||
|
||||
public const string HttpMethodKey = "http.method";
|
||||
public const string HttpSchemeKey = "http.scheme";
|
||||
public const string HttpTargetKey = "http.target";
|
||||
public const string HttpStatusCodeKey = "http.status_code";
|
||||
public const string HttpStatusTextKey = "http.status_text";
|
||||
public const string HttpUserAgentKey = "http.user_agent";
|
||||
public const string HttpPathKey = "http.path";
|
||||
public const string HttpHostKey = "http.host";
|
||||
public const string HttpUrlKey = "http.url";
|
||||
public const string HttpRouteKey = "http.route";
|
||||
public const string HttpFlavorKey = "http.flavor";
|
||||
|
||||
public const string DatabaseSystemKey = "db.system";
|
||||
public const string DatabaseNameKey = "db.name";
|
||||
public const string DatabaseStatementKey = "db.statement";
|
||||
public const string DatabaseStatementTypeKey = "db.statement_type";
|
||||
|
||||
public const string RpcSystem = "rpc.system";
|
||||
public const string RpcService = "rpc.service";
|
||||
public const string RpcMethod = "rpc.method";
|
||||
|
||||
public const string NetPeerIp = "net.peer.ip";
|
||||
public const string NetPeerName = "net.peer.name";
|
||||
public const string NetPeerPort = "net.peer.port";
|
||||
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,248 +0,0 @@
|
|||
// <copyright file="SpanExtensions.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
namespace OpenTelemetry.Trace
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class to populate well-known span attributes.
|
||||
/// </summary>
|
||||
public static class SpanExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from component
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-http.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="component">Http method.</param>
|
||||
/// <returns>Span with populated http method properties.</returns>
|
||||
public static TelemetrySpan PutComponentAttribute(this TelemetrySpan span, string component)
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.ComponentKey, component);
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from component
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-span-general.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="peerService">Peer service.</param>
|
||||
/// <returns>Span with populated http method properties.</returns>
|
||||
public static TelemetrySpan PutPeerServiceAttribute(this TelemetrySpan span, string peerService)
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.PeerServiceKey, peerService);
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from http method according
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-http.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="method">Http method.</param>
|
||||
/// <returns>Span with populated http method properties.</returns>
|
||||
public static TelemetrySpan PutHttpMethodAttribute(this TelemetrySpan span, string method)
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.HttpMethodKey, method);
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from http status code according
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-http.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="statusCode">Http status code.</param>
|
||||
/// <returns>Span with populated status code properties.</returns>
|
||||
public static TelemetrySpan PutHttpStatusCodeAttribute(this TelemetrySpan span, int statusCode)
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.HttpStatusCodeKey, statusCode);
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from http user agent according
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-http.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="userAgent">Http status code.</param>
|
||||
/// <returns>Span with populated user agent code properties.</returns>
|
||||
public static TelemetrySpan PutHttpUserAgentAttribute(this TelemetrySpan span, string userAgent)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(userAgent))
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.HttpUserAgentKey, userAgent);
|
||||
}
|
||||
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from host and port
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-http.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="hostName">Hostr name.</param>
|
||||
/// <param name="port">Port number.</param>
|
||||
/// <returns>Span with populated host properties.</returns>
|
||||
public static TelemetrySpan PutHttpHostAttribute(this TelemetrySpan span, string hostName, int port)
|
||||
{
|
||||
if (port == 80 || port == 443)
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.HttpHostKey, hostName);
|
||||
}
|
||||
else
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.HttpHostKey, hostName + ":" + port);
|
||||
}
|
||||
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from host and port
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-http.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="hostAndPort">Host and port value.</param>
|
||||
/// <returns>Span with populated host properties.</returns>
|
||||
public static TelemetrySpan PutHttpHostAttribute(this TelemetrySpan span, string hostAndPort)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(hostAndPort))
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.HttpHostKey, hostAndPort);
|
||||
}
|
||||
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from route
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-http.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="route">Route used to resolve url to controller.</param>
|
||||
/// <returns>Span with populated route properties.</returns>
|
||||
public static TelemetrySpan PutHttpRouteAttribute(this TelemetrySpan span, string route)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(route))
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.HttpRouteKey, route);
|
||||
}
|
||||
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from host and port
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-http.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="rawUrl">Raw url.</param>
|
||||
/// <returns>Span with populated url properties.</returns>
|
||||
public static TelemetrySpan PutHttpRawUrlAttribute(this TelemetrySpan span, string rawUrl)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(rawUrl))
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.HttpUrlKey, rawUrl);
|
||||
}
|
||||
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from url path according
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-http.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="path">Url path.</param>
|
||||
/// <returns>Span with populated path properties.</returns>
|
||||
public static TelemetrySpan PutHttpPathAttribute(this TelemetrySpan span, string path)
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.HttpPathKey, path);
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from http status code according
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-http.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="statusCode">Http status code.</param>
|
||||
/// <param name="reasonPhrase">Http reason phrase.</param>
|
||||
/// <returns>Span with populated properties.</returns>
|
||||
public static TelemetrySpan PutHttpStatusCode(this TelemetrySpan span, int statusCode, string reasonPhrase)
|
||||
{
|
||||
span.PutHttpStatusCodeAttribute(statusCode);
|
||||
|
||||
span.Status = SpanHelper.ResolveSpanStatusForHttpStatusCode(statusCode).WithDescription(reasonPhrase);
|
||||
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates span properties from request version according
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/2316771e7e0ca3bfe9b2286d13e3a41ded6b8858/specification/data-http.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="flavor">HTTP version.</param>
|
||||
/// <returns>Span with populated properties.</returns>
|
||||
public static TelemetrySpan PutHttpFlavorAttribute(this TelemetrySpan span, string flavor)
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.HttpFlavorKey, flavor);
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates database system
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/database.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="system">Database system.</param>
|
||||
/// <returns>Span with populated properties.</returns>
|
||||
public static TelemetrySpan PutDatabaseSystemAttribute(this TelemetrySpan span, string system)
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.DatabaseSystemKey, system);
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates database name
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/database.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="name">Database name.</param>
|
||||
/// <returns>Span with populated properties.</returns>
|
||||
public static TelemetrySpan PutDatabaseNameAttribute(this TelemetrySpan span, string name)
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.DatabaseNameKey, name);
|
||||
return span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that populates database statement
|
||||
/// to https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/database.md.
|
||||
/// </summary>
|
||||
/// <param name="span">Span to fill out.</param>
|
||||
/// <param name="statement">Database statement.</param>
|
||||
/// <returns>Span with populated properties.</returns>
|
||||
public static TelemetrySpan PutDatabaseStatementAttribute(this TelemetrySpan span, string statement)
|
||||
{
|
||||
span.SetAttribute(SpanAttributeConstants.DatabaseStatementKey, statement);
|
||||
return span;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,9 +25,9 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
{
|
||||
private static readonly Dictionary<string, int> PeerServiceKeyResolutionDictionary = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
[SpanAttributeConstants.PeerServiceKey] = 0, // priority 0 (highest).
|
||||
[SpanAttributeConstants.NetPeerName] = 1,
|
||||
[SpanAttributeConstants.NetPeerIp] = 2,
|
||||
[SemanticConventions.AttributePeerService] = 0, // priority 0 (highest).
|
||||
[SemanticConventions.AttributeNetPeerName] = 1,
|
||||
[SemanticConventions.AttributeNetPeerIP] = 2,
|
||||
["peer.hostname"] = 2,
|
||||
["peer.address"] = 2,
|
||||
["http.host"] = 3, // peer.service for Http.
|
||||
|
|
@ -60,7 +60,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
// If priority = 0 that means peer.service was already included in tags.
|
||||
if (jaegerTags.PeerServicePriority > 0)
|
||||
{
|
||||
PooledList<JaegerTag>.Add(ref jaegerTags.Tags, new JaegerTag(SpanAttributeConstants.PeerServiceKey, JaegerTagType.STRING, vStr: peerServiceName));
|
||||
PooledList<JaegerTag>.Add(ref jaegerTags.Tags, new JaegerTag(SemanticConventions.AttributePeerService, JaegerTagType.STRING, vStr: peerServiceName));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
|
||||
private static readonly Dictionary<string, int> PeerServiceKeyResolutionDictionary = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
[SpanAttributeConstants.PeerServiceKey] = 0, // priority 0 (highest).
|
||||
[SpanAttributeConstants.NetPeerName] = 1,
|
||||
[SpanAttributeConstants.NetPeerIp] = 2,
|
||||
[SemanticConventions.AttributePeerService] = 0, // priority 0 (highest).
|
||||
[SemanticConventions.AttributeNetPeerName] = 1,
|
||||
[SemanticConventions.AttributeNetPeerIP] = 2,
|
||||
["peer.hostname"] = 2,
|
||||
["peer.address"] = 2,
|
||||
["http.host"] = 3, // peer.service for Http.
|
||||
|
|
@ -81,7 +81,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
// If priority = 0 that means peer.service was already included in tags.
|
||||
if (jaegerTags.PeerServicePriority > 0)
|
||||
{
|
||||
PooledList<JaegerTag>.Add(ref jaegerTags.Tags, new JaegerTag(SpanAttributeConstants.PeerServiceKey, JaegerTagType.STRING, vStr: peerServiceName));
|
||||
PooledList<JaegerTag>.Add(ref jaegerTags.Tags, new JaegerTag(SemanticConventions.AttributePeerService, JaegerTagType.STRING, vStr: peerServiceName));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation
|
|||
|
||||
private static readonly Dictionary<string, int> RemoteEndpointServiceNameKeyResolutionDictionary = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
[SpanAttributeConstants.PeerServiceKey] = 0, // priority 0 (highest).
|
||||
[SpanAttributeConstants.NetPeerName] = 1,
|
||||
[SpanAttributeConstants.NetPeerIp] = 2,
|
||||
[SemanticConventions.AttributePeerService] = 0, // priority 0 (highest).
|
||||
[SemanticConventions.AttributeNetPeerName] = 1,
|
||||
[SemanticConventions.AttributeNetPeerIP] = 2,
|
||||
["peer.hostname"] = 2,
|
||||
["peer.address"] = 2,
|
||||
["http.host"] = 3, // RemoteEndpoint.ServiceName for Http.
|
||||
|
|
|
|||
|
|
@ -96,17 +96,17 @@ namespace OpenTelemetry.Instrumentation.AspNet.Implementation
|
|||
{
|
||||
if (request.Url.Port == 80 || request.Url.Port == 443)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.HttpHostKey, request.Url.Host);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPHost, request.Url.Host);
|
||||
}
|
||||
else
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.HttpHostKey, request.Url.Host + ":" + request.Url.Port);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPHost, request.Url.Host + ":" + request.Url.Port);
|
||||
}
|
||||
|
||||
activity.AddTag(SpanAttributeConstants.HttpMethodKey, request.HttpMethod);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPMethod, request.HttpMethod);
|
||||
activity.AddTag(SpanAttributeConstants.HttpPathKey, path);
|
||||
activity.AddTag(SpanAttributeConstants.HttpUserAgentKey, request.UserAgent);
|
||||
activity.AddTag(SpanAttributeConstants.HttpUrlKey, request.Url.ToString());
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPUserAgent, request.UserAgent);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPURL, request.Url.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ namespace OpenTelemetry.Instrumentation.AspNet.Implementation
|
|||
}
|
||||
|
||||
var response = context.Response;
|
||||
activityToEnrich.AddTag(SpanAttributeConstants.HttpStatusCodeKey, response.StatusCode.ToString());
|
||||
activityToEnrich.AddTag(SemanticConventions.AttributeHTTPStatusCode, response.StatusCode.ToString());
|
||||
Status status = SpanHelper.ResolveSpanStatusForHttpStatusCode((int)response.StatusCode);
|
||||
activityToEnrich.AddTag(SpanAttributeConstants.StatusCodeKey, SpanHelper.GetCachedCanonicalCodeString(status.CanonicalCode));
|
||||
activityToEnrich.AddTag(SpanAttributeConstants.StatusDescriptionKey, response.StatusDescription);
|
||||
|
|
@ -170,7 +170,7 @@ namespace OpenTelemetry.Instrumentation.AspNet.Implementation
|
|||
{
|
||||
// Override the name that was previously set to the path part of URL.
|
||||
activityToEnrich.DisplayName = template;
|
||||
activityToEnrich.AddTag(SpanAttributeConstants.HttpRouteKey, template);
|
||||
activityToEnrich.AddTag(SemanticConventions.AttributeHTTPRoute, template);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,21 +101,21 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
|
|||
|
||||
if (request.Host.Port == 80 || request.Host.Port == 443)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.HttpHostKey, request.Host.Host);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPHost, request.Host.Host);
|
||||
}
|
||||
else
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.HttpHostKey, request.Host.Host + ":" + request.Host.Port);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPHost, request.Host.Host + ":" + request.Host.Port);
|
||||
}
|
||||
|
||||
activity.AddTag(SpanAttributeConstants.HttpMethodKey, request.Method);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPMethod, request.Method);
|
||||
activity.AddTag(SpanAttributeConstants.HttpPathKey, path);
|
||||
activity.AddTag(SpanAttributeConstants.HttpUrlKey, GetUri(request));
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPURL, GetUri(request));
|
||||
|
||||
var userAgent = request.Headers["User-Agent"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(userAgent))
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.HttpUserAgentKey, userAgent);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPUserAgent, userAgent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
|
|||
}
|
||||
|
||||
var response = context.Response;
|
||||
activity.AddTag(SpanAttributeConstants.HttpStatusCodeKey, response.StatusCode.ToString());
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPStatusCode, response.StatusCode.ToString());
|
||||
|
||||
Status status = SpanHelper.ResolveSpanStatusForHttpStatusCode((int)response.StatusCode);
|
||||
activity.AddTag(SpanAttributeConstants.StatusCodeKey, SpanHelper.GetCachedCanonicalCodeString(status.CanonicalCode));
|
||||
|
|
@ -183,7 +183,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
|
|||
{
|
||||
// override the span name that was previously set to the path part of URL.
|
||||
activity.DisplayName = template;
|
||||
activity.AddTag(SpanAttributeConstants.HttpRouteKey, template);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPRoute, template);
|
||||
}
|
||||
|
||||
// TODO: Should we get values from RouteData?
|
||||
|
|
|
|||
|
|
@ -57,25 +57,25 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Implementation
|
|||
|
||||
if (activity.IsAllDataRequested)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.RpcSystem, "grpc");
|
||||
activity.AddTag(SemanticConventions.AttributeRPCSystem, "grpc");
|
||||
|
||||
if (GrpcTagHelper.TryParseRpcServiceAndRpcMethod(grpcMethod, out var rpcService, out var rpcMethod))
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.RpcService, rpcService);
|
||||
activity.AddTag(SpanAttributeConstants.RpcMethod, rpcMethod);
|
||||
activity.AddTag(SemanticConventions.AttributeRPCService, rpcService);
|
||||
activity.AddTag(SemanticConventions.AttributeRPCMethod, rpcMethod);
|
||||
}
|
||||
|
||||
var uriHostNameType = Uri.CheckHostName(request.RequestUri.Host);
|
||||
if (uriHostNameType == UriHostNameType.IPv4 || uriHostNameType == UriHostNameType.IPv6)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.NetPeerIp, request.RequestUri.Host);
|
||||
activity.AddTag(SemanticConventions.AttributeNetPeerIP, request.RequestUri.Host);
|
||||
}
|
||||
else
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.NetPeerName, request.RequestUri.Host);
|
||||
activity.AddTag(SemanticConventions.AttributeNetPeerName, request.RequestUri.Host);
|
||||
}
|
||||
|
||||
activity.AddTag(SpanAttributeConstants.NetPeerPort, request.RequestUri.Port.ToString());
|
||||
activity.AddTag(SemanticConventions.AttributeNetPeerPort, request.RequestUri.Port.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,14 +83,13 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Implementation
|
|||
|
||||
if (activity.IsAllDataRequested)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.ComponentKey, "http");
|
||||
activity.AddTag(SpanAttributeConstants.HttpMethodKey, HttpTagHelper.GetNameForHttpMethod(request.Method));
|
||||
activity.AddTag(SpanAttributeConstants.HttpHostKey, HttpTagHelper.GetHostTagValueFromRequestUri(request.RequestUri));
|
||||
activity.AddTag(SpanAttributeConstants.HttpUrlKey, request.RequestUri.OriginalString);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPMethod, HttpTagHelper.GetNameForHttpMethod(request.Method));
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPHost, HttpTagHelper.GetHostTagValueFromRequestUri(request.RequestUri));
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPURL, request.RequestUri.OriginalString);
|
||||
|
||||
if (this.options.SetHttpFlavor)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.HttpFlavorKey, HttpTagHelper.GetFlavorTagValueFromProtocolVersion(request.Version));
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPFlavor, HttpTagHelper.GetFlavorTagValueFromProtocolVersion(request.Version));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +126,7 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Implementation
|
|||
if (this.stopResponseFetcher.Fetch(payload) is HttpResponseMessage response)
|
||||
{
|
||||
// response could be null for DNS issues, timeouts, etc...
|
||||
activity.AddTag(SpanAttributeConstants.HttpStatusCodeKey, response.StatusCode.ToString());
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPStatusCode, response.StatusCode.ToString());
|
||||
|
||||
Status status = SpanHelper.ResolveSpanStatusForHttpStatusCode((int)response.StatusCode);
|
||||
activity.AddTag(SpanAttributeConstants.StatusCodeKey, SpanHelper.GetCachedCanonicalCodeString(status.CanonicalCode));
|
||||
|
|
|
|||
|
|
@ -101,11 +101,10 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Implementation
|
|||
|
||||
if (activity.IsAllDataRequested)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.ComponentKey, "http");
|
||||
activity.AddTag(SpanAttributeConstants.HttpMethodKey, request.Method);
|
||||
activity.AddTag(SpanAttributeConstants.HttpHostKey, HttpTagHelper.GetHostTagValueFromRequestUri(request.RequestUri));
|
||||
activity.AddTag(SpanAttributeConstants.HttpUrlKey, request.RequestUri.OriginalString);
|
||||
activity.AddTag(SpanAttributeConstants.HttpFlavorKey, HttpTagHelper.GetFlavorTagValueFromProtocolVersion(request.ProtocolVersion));
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPMethod, request.Method);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPHost, HttpTagHelper.GetHostTagValueFromRequestUri(request.RequestUri));
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPURL, request.RequestUri.OriginalString);
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPFlavor, HttpTagHelper.GetFlavorTagValueFromProtocolVersion(request.ProtocolVersion));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +115,7 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Implementation
|
|||
|
||||
if (activity.IsAllDataRequested)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.HttpStatusCodeKey, HttpTagHelper.GetStatusCodeTagValueFromHttpStatusCode(response.StatusCode));
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPStatusCode, HttpTagHelper.GetStatusCodeTagValueFromHttpStatusCode(response.StatusCode));
|
||||
|
||||
Status status = SpanHelper.ResolveSpanStatusForHttpStatusCode((int)response.StatusCode);
|
||||
|
||||
|
|
@ -140,7 +139,7 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Implementation
|
|||
{
|
||||
if (wexc.Response is HttpWebResponse response)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.HttpStatusCodeKey, HttpTagHelper.GetStatusCodeTagValueFromHttpStatusCode(response.StatusCode));
|
||||
activity.AddTag(SemanticConventions.AttributeHTTPStatusCode, HttpTagHelper.GetStatusCodeTagValueFromHttpStatusCode(response.StatusCode));
|
||||
|
||||
status = SpanHelper.ResolveSpanStatusForHttpStatusCode((int)response.StatusCode).WithDescription(response.StatusDescription);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,9 +83,8 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Implementation
|
|||
var dataSource = this.dataSourceFetcher.Fetch(connection);
|
||||
var commandText = this.commandTextFetcher.Fetch(command);
|
||||
|
||||
activity.AddTag(SpanAttributeConstants.ComponentKey, "sql");
|
||||
activity.AddTag(SpanAttributeConstants.DatabaseSystemKey, MicrosoftSqlServerDatabaseSystemName);
|
||||
activity.AddTag(SpanAttributeConstants.DatabaseNameKey, (string)database);
|
||||
activity.AddTag(SemanticConventions.AttributeDBSystem, MicrosoftSqlServerDatabaseSystemName);
|
||||
activity.AddTag(SemanticConventions.AttributeDBName, (string)database);
|
||||
|
||||
this.options.AddConnectionLevelDetailsToActivity((string)dataSource, activity);
|
||||
|
||||
|
|
@ -97,7 +96,7 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Implementation
|
|||
activity.AddTag(SpanAttributeConstants.DatabaseStatementTypeKey, nameof(CommandType.StoredProcedure));
|
||||
if (this.options.CaptureStoredProcedureCommandName)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.DatabaseStatementKey, (string)commandText);
|
||||
activity.AddTag(SemanticConventions.AttributeDBStatement, (string)commandText);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -106,7 +105,7 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Implementation
|
|||
activity.AddTag(SpanAttributeConstants.DatabaseStatementTypeKey, nameof(CommandType.Text));
|
||||
if (this.options.CaptureTextCommandContent)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.DatabaseStatementKey, (string)commandText);
|
||||
activity.AddTag(SemanticConventions.AttributeDBStatement, (string)commandText);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -114,10 +114,8 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Implementation
|
|||
|
||||
if (activity.IsAllDataRequested)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.ComponentKey, "sql");
|
||||
|
||||
activity.AddTag(SpanAttributeConstants.DatabaseSystemKey, SqlClientDiagnosticListener.MicrosoftSqlServerDatabaseSystemName);
|
||||
activity.AddTag(SpanAttributeConstants.DatabaseNameKey, databaseName);
|
||||
activity.AddTag(SemanticConventions.AttributeDBSystem, SqlClientDiagnosticListener.MicrosoftSqlServerDatabaseSystemName);
|
||||
activity.AddTag(SemanticConventions.AttributeDBName, databaseName);
|
||||
|
||||
this.options.AddConnectionLevelDetailsToActivity((string)eventData.Payload[1], activity);
|
||||
|
||||
|
|
@ -131,7 +129,7 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Implementation
|
|||
activity.AddTag(SpanAttributeConstants.DatabaseStatementTypeKey, nameof(CommandType.StoredProcedure));
|
||||
if (this.options.CaptureStoredProcedureCommandName)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.DatabaseStatementKey, commandText);
|
||||
activity.AddTag(SemanticConventions.AttributeDBStatement, commandText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ namespace OpenTelemetry.Instrumentation.Dependencies
|
|||
{
|
||||
if (!this.EnableConnectionLevelAttributes)
|
||||
{
|
||||
sqlActivity.AddTag(SpanAttributeConstants.PeerServiceKey, dataSource);
|
||||
sqlActivity.AddTag(SemanticConventions.AttributePeerService, dataSource);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -125,11 +125,11 @@ namespace OpenTelemetry.Instrumentation.Dependencies
|
|||
|
||||
if (!string.IsNullOrEmpty(connectionDetails.ServerHostName))
|
||||
{
|
||||
sqlActivity.AddTag(SpanAttributeConstants.NetPeerName, connectionDetails.ServerHostName);
|
||||
sqlActivity.AddTag(SemanticConventions.AttributeNetPeerName, connectionDetails.ServerHostName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlActivity.AddTag(SpanAttributeConstants.NetPeerIp, connectionDetails.ServerIpAddress);
|
||||
sqlActivity.AddTag(SemanticConventions.AttributeNetPeerIP, connectionDetails.ServerIpAddress);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(connectionDetails.InstanceName))
|
||||
|
|
@ -139,7 +139,7 @@ namespace OpenTelemetry.Instrumentation.Dependencies
|
|||
|
||||
if (!string.IsNullOrEmpty(connectionDetails.Port))
|
||||
{
|
||||
sqlActivity.AddTag(SpanAttributeConstants.NetPeerPort, connectionDetails.Port);
|
||||
sqlActivity.AddTag(SemanticConventions.AttributeNetPeerPort, connectionDetails.Port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,30 +58,30 @@ namespace OpenTelemetry.Instrumentation.StackExchangeRedis.Implementation
|
|||
// command.ElapsedTime; // 00:00:32.4988020
|
||||
|
||||
activity.AddTag(SpanAttributeConstants.StatusCodeKey, SpanHelper.GetCachedCanonicalCodeString(StatusCanonicalCode.Ok));
|
||||
activity.AddTag(SpanAttributeConstants.DatabaseSystemKey, "redis");
|
||||
activity.AddTag(SemanticConventions.AttributeDBSystem, "redis");
|
||||
activity.AddTag(StackExchangeRedisCallsInstrumentation.RedisFlagsKeyName, command.Flags.ToString());
|
||||
|
||||
if (command.Command != null)
|
||||
{
|
||||
// Example: "db.statement": SET;
|
||||
activity.AddTag(SpanAttributeConstants.DatabaseStatementKey, command.Command);
|
||||
activity.AddTag(SemanticConventions.AttributeDBStatement, command.Command);
|
||||
}
|
||||
|
||||
if (command.EndPoint != null)
|
||||
{
|
||||
if (command.EndPoint is IPEndPoint ipEndPoint)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.NetPeerIp, ipEndPoint.Address.ToString());
|
||||
activity.AddTag(SpanAttributeConstants.NetPeerPort, ipEndPoint.Port.ToString());
|
||||
activity.AddTag(SemanticConventions.AttributeNetPeerIP, ipEndPoint.Address.ToString());
|
||||
activity.AddTag(SemanticConventions.AttributeNetPeerPort, ipEndPoint.Port.ToString());
|
||||
}
|
||||
else if (command.EndPoint is DnsEndPoint dnsEndPoint)
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.NetPeerName, dnsEndPoint.Host);
|
||||
activity.AddTag(SpanAttributeConstants.NetPeerPort, dnsEndPoint.Port.ToString());
|
||||
activity.AddTag(SemanticConventions.AttributeNetPeerName, dnsEndPoint.Host);
|
||||
activity.AddTag(SemanticConventions.AttributeNetPeerPort, dnsEndPoint.Port.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
activity.AddTag(SpanAttributeConstants.PeerServiceKey, command.EndPoint.ToString());
|
||||
activity.AddTag(SemanticConventions.AttributePeerService, command.EndPoint.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ namespace OpenTelemetry.Instrumentation.AspNet.Tests
|
|||
|
||||
Assert.Equal(
|
||||
"200",
|
||||
span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpStatusCodeKey).Value);
|
||||
span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPStatusCode).Value);
|
||||
|
||||
Assert.Equal(
|
||||
"Ok",
|
||||
|
|
@ -216,7 +216,7 @@ namespace OpenTelemetry.Instrumentation.AspNet.Tests
|
|||
span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.StatusDescriptionKey).Value);
|
||||
|
||||
var expectedUri = new Uri(url);
|
||||
var actualUrl = span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpUrlKey).Value;
|
||||
var actualUrl = span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPURL).Value;
|
||||
|
||||
Assert.Equal(expectedUri.ToString(), actualUrl);
|
||||
|
||||
|
|
@ -235,24 +235,24 @@ namespace OpenTelemetry.Instrumentation.AspNet.Tests
|
|||
{
|
||||
Assert.Equal(
|
||||
expectedUri.Host,
|
||||
span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpHostKey).Value as string);
|
||||
span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPHost).Value as string);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal(
|
||||
$"{expectedUri.Host}:{expectedUri.Port}",
|
||||
span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpHostKey).Value as string);
|
||||
span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPHost).Value as string);
|
||||
}
|
||||
|
||||
Assert.Equal(
|
||||
HttpContext.Current.Request.HttpMethod,
|
||||
span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpMethodKey).Value as string);
|
||||
span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPMethod).Value as string);
|
||||
Assert.Equal(
|
||||
HttpContext.Current.Request.Path,
|
||||
span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpPathKey).Value as string);
|
||||
Assert.Equal(
|
||||
HttpContext.Current.Request.UserAgent,
|
||||
span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpUserAgentKey).Value as string);
|
||||
span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPUserAgent).Value as string);
|
||||
|
||||
Assert.Equal(expectedResource, span.GetResource());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,16 +104,16 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
var span = (Activity)spanProcessor.Invocations[1].Arguments[0];
|
||||
|
||||
Assert.Equal(ActivityKind.Server, span.Kind);
|
||||
Assert.Equal("localhost:", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpHostKey).Value);
|
||||
Assert.Equal("GET", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpMethodKey).Value);
|
||||
Assert.Equal("localhost:", span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPHost).Value);
|
||||
Assert.Equal("GET", span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPMethod).Value);
|
||||
Assert.Equal(urlPath, span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpPathKey).Value);
|
||||
Assert.Equal($"http://localhost{urlPath}", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpUrlKey).Value);
|
||||
Assert.Equal(statusCode.ToString(), span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpStatusCodeKey).Value);
|
||||
Assert.Equal($"http://localhost{urlPath}", span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPURL).Value);
|
||||
Assert.Equal(statusCode.ToString(), span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPStatusCode).Value);
|
||||
|
||||
Status status = SpanHelper.ResolveSpanStatusForHttpStatusCode(statusCode);
|
||||
Assert.Equal(SpanHelper.GetCachedCanonicalCodeString(status.CanonicalCode), span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.StatusCodeKey).Value);
|
||||
this.ValidateTagValue(span, SpanAttributeConstants.StatusDescriptionKey, reasonPhrase);
|
||||
this.ValidateTagValue(span, SpanAttributeConstants.HttpUserAgentKey, userAgent);
|
||||
this.ValidateTagValue(span, SemanticConventions.AttributeHTTPUserAgent, userAgent);
|
||||
}
|
||||
|
||||
private void ValidateTagValue(Activity activity, string attribute, string expectedValue)
|
||||
|
|
|
|||
|
|
@ -154,7 +154,6 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Tests
|
|||
""spanStatus"": ""OK"",
|
||||
""spanKind"": ""Client"",
|
||||
""spanAttributes"": {
|
||||
""component"": ""http"",
|
||||
""http.method"": ""GET"",
|
||||
""http.host"": ""{host}:{port}"",
|
||||
""http.status_code"": ""399"",
|
||||
|
|
|
|||
|
|
@ -886,20 +886,19 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Tests
|
|||
private static void VerifyActivityStartTags(string hostNameAndPort, string method, string url, Activity activity)
|
||||
{
|
||||
Assert.NotNull(activity.Tags);
|
||||
Assert.Equal("http", activity.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.ComponentKey).Value);
|
||||
Assert.Equal(method, activity.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpMethodKey).Value);
|
||||
Assert.Equal(method, activity.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPMethod).Value);
|
||||
if (hostNameAndPort != null)
|
||||
{
|
||||
Assert.Equal(hostNameAndPort, activity.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpHostKey).Value);
|
||||
Assert.Equal(hostNameAndPort, activity.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPHost).Value);
|
||||
}
|
||||
|
||||
Assert.Equal(url, activity.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpUrlKey).Value);
|
||||
Assert.Equal("1.1", activity.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpFlavorKey).Value);
|
||||
Assert.Equal(url, activity.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPURL).Value);
|
||||
Assert.Equal("1.1", activity.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPFlavor).Value);
|
||||
}
|
||||
|
||||
private static void VerifyActivityStopTags(string statusCode, string statusText, Activity activity)
|
||||
{
|
||||
Assert.Equal(statusCode, activity.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.HttpStatusCodeKey).Value);
|
||||
Assert.Equal(statusCode, activity.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeHTTPStatusCode).Value);
|
||||
Assert.Equal(statusText, activity.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.StatusDescriptionKey).Value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Tests
|
|||
""spanKind"": ""Client"",
|
||||
""setHttpFlavor"": true,
|
||||
""spanAttributes"": {
|
||||
""component"": ""http"",
|
||||
""http.method"": ""GET"",
|
||||
""http.host"": ""{host}:{port}"",
|
||||
""http.flavor"": ""2.0"",
|
||||
|
|
|
|||
|
|
@ -116,20 +116,19 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Tests
|
|||
// Assert.Equal("Ok", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.StatusCodeKey).Value);
|
||||
Assert.Null(span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.StatusDescriptionKey).Value);
|
||||
|
||||
Assert.Equal("sql", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.ComponentKey).Value);
|
||||
Assert.Equal(SqlClientDiagnosticListener.MicrosoftSqlServerDatabaseSystemName, span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.DatabaseSystemKey).Value);
|
||||
Assert.Equal("master", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.DatabaseNameKey).Value);
|
||||
Assert.Equal(SqlClientDiagnosticListener.MicrosoftSqlServerDatabaseSystemName, span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeDBSystem).Value);
|
||||
Assert.Equal("master", span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeDBName).Value);
|
||||
|
||||
switch (commandType)
|
||||
{
|
||||
case CommandType.StoredProcedure:
|
||||
if (captureStoredProcedureCommandName)
|
||||
{
|
||||
Assert.Equal(commandText, span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.DatabaseStatementKey).Value);
|
||||
Assert.Equal(commandText, span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeDBStatement).Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Null(span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.DatabaseStatementKey).Value);
|
||||
Assert.Null(span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeDBStatement).Value);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -137,17 +136,17 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Tests
|
|||
case CommandType.Text:
|
||||
if (captureTextCommandContent)
|
||||
{
|
||||
Assert.Equal(commandText, span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.DatabaseStatementKey).Value);
|
||||
Assert.Equal(commandText, span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeDBStatement).Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Null(span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.DatabaseStatementKey).Value);
|
||||
Assert.Null(span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeDBStatement).Value);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Assert.Equal("(localdb)\\MSSQLLocalDB", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.PeerServiceKey).Value);
|
||||
Assert.Equal("(localdb)\\MSSQLLocalDB", span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributePeerService).Value);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -204,11 +203,10 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Tests
|
|||
|
||||
Assert.Equal("Unknown", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.StatusCodeKey).Value);
|
||||
Assert.Equal("Boom!", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.StatusDescriptionKey).Value);
|
||||
Assert.Equal("sql", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.ComponentKey).Value);
|
||||
Assert.Equal(SqlClientDiagnosticListener.MicrosoftSqlServerDatabaseSystemName, span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.DatabaseSystemKey).Value);
|
||||
Assert.Equal("master", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.DatabaseNameKey).Value);
|
||||
Assert.Equal("SP_GetOrders", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.DatabaseStatementKey).Value);
|
||||
Assert.Equal("(localdb)\\MSSQLLocalDB", span.Tags.FirstOrDefault(i => i.Key == SpanAttributeConstants.PeerServiceKey).Value);
|
||||
Assert.Equal(SqlClientDiagnosticListener.MicrosoftSqlServerDatabaseSystemName, span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeDBSystem).Value);
|
||||
Assert.Equal("master", span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeDBName).Value);
|
||||
Assert.Equal("SP_GetOrders", span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributeDBStatement).Value);
|
||||
Assert.Equal("(localdb)\\MSSQLLocalDB", span.Tags.FirstOrDefault(i => i.Key == SemanticConventions.AttributePeerService).Value);
|
||||
}
|
||||
|
||||
private class FakeSqlClientDiagnosticSource : IDisposable
|
||||
|
|
|
|||
|
|
@ -187,12 +187,11 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Tests
|
|||
{
|
||||
Assert.Equal("master", activity.DisplayName);
|
||||
Assert.Equal(ActivityKind.Client, activity.Kind);
|
||||
Assert.Equal("sql", activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.ComponentKey).Value);
|
||||
Assert.Equal(SqlClientDiagnosticListener.MicrosoftSqlServerDatabaseSystemName, activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.DatabaseSystemKey).Value);
|
||||
Assert.Equal(SqlClientDiagnosticListener.MicrosoftSqlServerDatabaseSystemName, activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeDBSystem).Value);
|
||||
|
||||
if (!enableConnectionLevelAttributes)
|
||||
{
|
||||
Assert.Equal(dataSource, activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.PeerServiceKey).Value);
|
||||
Assert.Equal(dataSource, activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributePeerService).Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -200,11 +199,11 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Tests
|
|||
|
||||
if (!string.IsNullOrEmpty(connectionDetails.ServerHostName))
|
||||
{
|
||||
Assert.Equal(connectionDetails.ServerHostName, activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.NetPeerName).Value);
|
||||
Assert.Equal(connectionDetails.ServerHostName, activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeNetPeerName).Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal(connectionDetails.ServerIpAddress, activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.NetPeerIp).Value);
|
||||
Assert.Equal(connectionDetails.ServerIpAddress, activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeNetPeerIP).Value);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(connectionDetails.InstanceName))
|
||||
|
|
@ -214,21 +213,21 @@ namespace OpenTelemetry.Instrumentation.Dependencies.Tests
|
|||
|
||||
if (!string.IsNullOrEmpty(connectionDetails.Port))
|
||||
{
|
||||
Assert.Equal(connectionDetails.Port, activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.NetPeerPort).Value);
|
||||
Assert.Equal(connectionDetails.Port, activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeNetPeerPort).Value);
|
||||
}
|
||||
}
|
||||
|
||||
Assert.Equal("master", activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.DatabaseNameKey).Value);
|
||||
Assert.Equal("master", activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeDBName).Value);
|
||||
Assert.Equal(commandType.ToString(), activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.DatabaseStatementTypeKey).Value);
|
||||
if (commandType == CommandType.StoredProcedure)
|
||||
{
|
||||
if (captureText)
|
||||
{
|
||||
Assert.Equal(commandText, activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.DatabaseStatementKey).Value);
|
||||
Assert.Equal(commandText, activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeDBStatement).Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.DoesNotContain(activity.Tags, t => t.Key == SpanAttributeConstants.DatabaseStatementKey);
|
||||
Assert.DoesNotContain(activity.Tags, t => t.Key == SemanticConventions.AttributeDBStatement);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
"spanStatus": "OK",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "example.com",
|
||||
"http.status_code": "200",
|
||||
|
|
@ -22,7 +21,6 @@
|
|||
"spanStatus": "OK",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "POST",
|
||||
"http.host": "example.com",
|
||||
"http.status_code": "200",
|
||||
|
|
@ -38,7 +36,6 @@
|
|||
"spanStatus": "OK",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "200",
|
||||
|
|
@ -54,7 +51,6 @@
|
|||
"spanStatusHasDescription": true,
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com",
|
||||
"http.url": "https://sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com/"
|
||||
|
|
@ -69,7 +65,6 @@
|
|||
"spanStatus": "OK",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "200",
|
||||
|
|
@ -85,7 +80,6 @@
|
|||
"spanStatus": "OK",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "200",
|
||||
|
|
@ -101,7 +95,6 @@
|
|||
"spanStatus": "OK",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "399",
|
||||
|
|
@ -117,7 +110,6 @@
|
|||
"spanStatus": "INVALID_ARGUMENT",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "400",
|
||||
|
|
@ -133,7 +125,6 @@
|
|||
"spanStatus": "UNAUTHENTICATED",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "401",
|
||||
|
|
@ -149,7 +140,6 @@
|
|||
"spanStatus": "PERMISSION_DENIED",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "403",
|
||||
|
|
@ -165,7 +155,6 @@
|
|||
"spanStatus": "NOT_FOUND",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "404",
|
||||
|
|
@ -181,7 +170,6 @@
|
|||
"spanStatus": "RESOURCE_EXHAUSTED",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "429",
|
||||
|
|
@ -197,7 +185,6 @@
|
|||
"spanStatus": "UNIMPLEMENTED",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "501",
|
||||
|
|
@ -213,7 +200,6 @@
|
|||
"spanStatus": "UNAVAILABLE",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "503",
|
||||
|
|
@ -229,7 +215,6 @@
|
|||
"spanStatus": "DEADLINE_EXCEEDED",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "504",
|
||||
|
|
@ -245,7 +230,6 @@
|
|||
"spanStatus": "UNKNOWN",
|
||||
"spanKind": "Client",
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.status_code": "600",
|
||||
|
|
@ -262,7 +246,6 @@
|
|||
"spanKind": "Client",
|
||||
"setHttpFlavor": true,
|
||||
"spanAttributes": {
|
||||
"component": "http",
|
||||
"http.method": "GET",
|
||||
"http.host": "{host}:{port}",
|
||||
"http.flavor": "2.0",
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ namespace OpenTelemetry.Instrumentation.StackExchangeRedis.Implementation
|
|||
|
||||
var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object);
|
||||
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SpanAttributeConstants.DatabaseSystemKey);
|
||||
Assert.Equal("redis", result.Tags.FirstOrDefault(kvp => kvp.Key == SpanAttributeConstants.DatabaseSystemKey).Value);
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributeDBSystem);
|
||||
Assert.Equal("redis", result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributeDBSystem).Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -103,8 +103,8 @@ namespace OpenTelemetry.Instrumentation.StackExchangeRedis.Implementation
|
|||
|
||||
var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object);
|
||||
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SpanAttributeConstants.DatabaseStatementKey);
|
||||
Assert.Equal("SET", result.Tags.FirstOrDefault(kvp => kvp.Key == SpanAttributeConstants.DatabaseStatementKey).Value);
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributeDBStatement);
|
||||
Assert.Equal("SET", result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributeDBStatement).Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -136,10 +136,10 @@ namespace OpenTelemetry.Instrumentation.StackExchangeRedis.Implementation
|
|||
|
||||
var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object);
|
||||
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SpanAttributeConstants.NetPeerIp);
|
||||
Assert.Equal($"{address}.0.0.0", result.Tags.FirstOrDefault(kvp => kvp.Key == SpanAttributeConstants.NetPeerIp).Value);
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SpanAttributeConstants.NetPeerPort);
|
||||
Assert.Equal($"{port}", result.Tags.FirstOrDefault(kvp => kvp.Key == SpanAttributeConstants.NetPeerPort).Value);
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributeNetPeerIP);
|
||||
Assert.Equal($"{address}.0.0.0", result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributeNetPeerIP).Value);
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributeNetPeerPort);
|
||||
Assert.Equal($"{port}", result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributeNetPeerPort).Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -153,10 +153,10 @@ namespace OpenTelemetry.Instrumentation.StackExchangeRedis.Implementation
|
|||
|
||||
var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object);
|
||||
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SpanAttributeConstants.NetPeerName);
|
||||
Assert.Equal(dnsEndPoint.Host, result.Tags.FirstOrDefault(kvp => kvp.Key == SpanAttributeConstants.NetPeerName).Value);
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SpanAttributeConstants.NetPeerPort);
|
||||
Assert.Equal(dnsEndPoint.Port.ToString(), result.Tags.FirstOrDefault(kvp => kvp.Key == SpanAttributeConstants.NetPeerPort).Value);
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributeNetPeerName);
|
||||
Assert.Equal(dnsEndPoint.Host, result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributeNetPeerName).Value);
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributeNetPeerPort);
|
||||
Assert.Equal(dnsEndPoint.Port.ToString(), result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributeNetPeerPort).Value);
|
||||
}
|
||||
|
||||
#if !NET461
|
||||
|
|
@ -170,8 +170,8 @@ namespace OpenTelemetry.Instrumentation.StackExchangeRedis.Implementation
|
|||
|
||||
var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object);
|
||||
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SpanAttributeConstants.PeerServiceKey);
|
||||
Assert.Equal(unixEndPoint.ToString(), result.Tags.FirstOrDefault(kvp => kvp.Key == SpanAttributeConstants.PeerServiceKey).Value);
|
||||
Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributePeerService);
|
||||
Assert.Equal(unixEndPoint.ToString(), result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributePeerService).Value);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,31 +109,31 @@ namespace OpenTelemetry.Instrumentation.StackExchangeRedis.Tests
|
|||
if (isSet)
|
||||
{
|
||||
Assert.Equal("SETEX", activity.DisplayName);
|
||||
Assert.Equal("SETEX", activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.DatabaseStatementKey).Value);
|
||||
Assert.Equal("SETEX", activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeDBStatement).Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal("GET", activity.DisplayName);
|
||||
Assert.Equal("GET", activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.DatabaseStatementKey).Value);
|
||||
Assert.Equal("GET", activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeDBStatement).Value);
|
||||
}
|
||||
|
||||
Assert.Equal(SpanHelper.GetCachedCanonicalCodeString(StatusCanonicalCode.Ok), activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.StatusCodeKey).Value);
|
||||
Assert.Equal("redis", activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.DatabaseSystemKey).Value);
|
||||
Assert.Equal("redis", activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeDBSystem).Value);
|
||||
Assert.Equal("0", activity.Tags.FirstOrDefault(t => t.Key == StackExchangeRedisCallsInstrumentation.RedisDatabaseIndexKeyName).Value);
|
||||
|
||||
if (endPoint is IPEndPoint ipEndPoint)
|
||||
{
|
||||
Assert.Equal(ipEndPoint.Address.ToString(), activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.NetPeerIp).Value);
|
||||
Assert.Equal(ipEndPoint.Port.ToString(), activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.NetPeerPort).Value);
|
||||
Assert.Equal(ipEndPoint.Address.ToString(), activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeNetPeerIP).Value);
|
||||
Assert.Equal(ipEndPoint.Port.ToString(), activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeNetPeerPort).Value);
|
||||
}
|
||||
else if (endPoint is DnsEndPoint dnsEndPoint)
|
||||
{
|
||||
Assert.Equal(dnsEndPoint.Host, activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.NetPeerName).Value);
|
||||
Assert.Equal(dnsEndPoint.Port.ToString(), activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.NetPeerPort).Value);
|
||||
Assert.Equal(dnsEndPoint.Host, activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeNetPeerName).Value);
|
||||
Assert.Equal(dnsEndPoint.Port.ToString(), activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeNetPeerPort).Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal(endPoint.ToString(), activity.Tags.FirstOrDefault(t => t.Key == SpanAttributeConstants.PeerServiceKey).Value);
|
||||
Assert.Equal(endPoint.ToString(), activity.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributePeerService).Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue