diff --git a/tracing/metrics.go b/tracing/metrics.go index 58565b0..7020d86 100644 --- a/tracing/metrics.go +++ b/tracing/metrics.go @@ -13,85 +13,3 @@ // limitations under the License. package tracing - -/*// Server HTTP metrics -const ( - ServerRequestCount = "http.server.request_count" // measures the incoming request count total - ServerLatency = "http.server.duration" // measures th incoming end to end duration -) - -// Client HTTP metrics. -const ( - ClientRequestCount = "http.client.request_count" // measures the client request count total - ClientLatency = "http.client.duration" // measures the duration outbound HTTP requests -) - -var ( - HTTPMetricsAttributes = []attribute.Key{ - semconv.HTTPHostKey, - semconv.HTTPRouteKey, - semconv.HTTPMethodKey, - semconv.HTTPStatusCodeKey, - } - - PeerMetricsAttributes = []attribute.Key{ - semconv.PeerServiceKey, - PeerServiceNamespaceKey, - PeerDeploymentEnvironmentKey, - RequestProtocolKey, - } - - // MetricResourceAttributes resource attributes - MetricResourceAttributes = []attribute.Key{ - semconv.ServiceNameKey, - semconv.ServiceNamespaceKey, - semconv.DeploymentEnvironmentKey, - semconv.ServiceInstanceIDKey, - semconv.ServiceVersionKey, - semconv.TelemetrySDKLanguageKey, - semconv.TelemetrySDKVersionKey, - semconv.ProcessPIDKey, - semconv.HostNameKey, - semconv.HostIDKey, - } -) - -func extractMetricsAttributesFromSpan(span oteltrace.Span) []attribute.KeyValue { - var attrs []attribute.KeyValue - readOnlySpan, ok := span.(trace.ReadOnlySpan) - if !ok { - return attrs - } - - // span attributes - for _, attr := range readOnlySpan.Attributes() { - if matchAttributeKey(attr.Key, HTTPMetricsAttributes) { - attrs = append(attrs, attr) - } - if matchAttributeKey(attr.Key, PeerMetricsAttributes) { - attrs = append(attrs, attr) - } - } - - // span resource attributes - for _, attr := range readOnlySpan.Resource().Attributes() { - if matchAttributeKey(attr.Key, MetricResourceAttributes) { - attrs = append(attrs, attr) - } - } - - // status code - attrs = append(attrs, StatusKey.String(readOnlySpan.Status().Code.String())) - - return attrs -} - -func matchAttributeKey(key attribute.Key, toMatchKeys []attribute.Key) bool { - for _, attrKey := range toMatchKeys { - if attrKey == key { - return true - } - } - return false -} -*/ diff --git a/tracing/peer.go b/tracing/peer.go index 516f683..7020d86 100644 --- a/tracing/peer.go +++ b/tracing/peer.go @@ -13,50 +13,3 @@ // limitations under the License. package tracing - -/*func injectPeerServiceToMetadata(_ context.Context, attrs []attribute.KeyValue) map[string]string { - serviceName, serviceNamespace, deploymentEnv := getServiceFromResourceAttributes(attrs) - - md := make(map[string]string, 3) - - if serviceName != "" { - md[semconvAttributeKeyToHTTPHeader(string(semconv.ServiceNameKey))] = serviceName - } - - if serviceNamespace != "" { - md[semconvAttributeKeyToHTTPHeader(string(semconv.ServiceNamespaceKey))] = serviceNamespace - } - - if deploymentEnv != "" { - md[semconvAttributeKeyToHTTPHeader(string(semconv.DeploymentEnvironmentKey))] = deploymentEnv - } - - return md -} - -func extractPeerServiceAttributesFromMetadata(headers *protocol.RequestHeader) []attribute.KeyValue { - var attrs []attribute.KeyValue - - serviceName, serviceNamespace, deploymentEnv := headers.Get(semconvAttributeKeyToHTTPHeader(string(semconv.ServiceNameKey))), - headers.Get(semconvAttributeKeyToHTTPHeader(string(semconv.ServiceNamespaceKey))), - headers.Get(semconvAttributeKeyToHTTPHeader(string(semconv.DeploymentEnvironmentKey))) - - if serviceName != "" { - attrs = append(attrs, semconv.PeerServiceKey.String(serviceName)) - } - - if serviceNamespace != "" { - attrs = append(attrs, PeerServiceNamespaceKey.String(serviceNamespace)) - } - - if deploymentEnv != "" { - attrs = append(attrs, PeerDeploymentEnvironmentKey.String(deploymentEnv)) - } - - return attrs -}*/ -/* -func semconvAttributeKeyToHTTPHeader(key string) string { - return strings.ReplaceAll(key, ".", "-") -} -*/