summaryrefslogtreecommitdiff
path: root/vendor/go.opentelemetry.io/otel/semconv/internal/http.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/go.opentelemetry.io/otel/semconv/internal/http.go')
-rw-r--r--vendor/go.opentelemetry.io/otel/semconv/internal/http.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/vendor/go.opentelemetry.io/otel/semconv/internal/http.go b/vendor/go.opentelemetry.io/otel/semconv/internal/http.go
index d5197e16c..e9eb57734 100644
--- a/vendor/go.opentelemetry.io/otel/semconv/internal/http.go
+++ b/vendor/go.opentelemetry.io/otel/semconv/internal/http.go
@@ -1,6 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
+// Package internal provides common semconv functionality.
package internal // import "go.opentelemetry.io/otel/semconv/internal"
import (
@@ -49,7 +50,10 @@ type SemanticConventions struct {
// namespace as specified by the OpenTelemetry specification for a
// span. The network parameter is a string that net.Dial function
// from standard library can understand.
-func (sc *SemanticConventions) NetAttributesFromHTTPRequest(network string, request *http.Request) []attribute.KeyValue {
+func (sc *SemanticConventions) NetAttributesFromHTTPRequest(
+ network string,
+ request *http.Request,
+) []attribute.KeyValue {
attrs := []attribute.KeyValue{}
switch network {
@@ -178,9 +182,10 @@ func (sc *SemanticConventions) httpBasicAttributesFromHTTPRequest(request *http.
}
flavor := ""
- if request.ProtoMajor == 1 {
+ switch request.ProtoMajor {
+ case 1:
flavor = fmt.Sprintf("1.%d", request.ProtoMinor)
- } else if request.ProtoMajor == 2 {
+ case 2:
flavor = "2"
}
if flavor != "" {
@@ -198,7 +203,10 @@ func (sc *SemanticConventions) httpBasicAttributesFromHTTPRequest(request *http.
// HTTPServerMetricAttributesFromHTTPRequest generates low-cardinality attributes
// to be used with server-side HTTP metrics.
-func (sc *SemanticConventions) HTTPServerMetricAttributesFromHTTPRequest(serverName string, request *http.Request) []attribute.KeyValue {
+func (sc *SemanticConventions) HTTPServerMetricAttributesFromHTTPRequest(
+ serverName string,
+ request *http.Request,
+) []attribute.KeyValue {
attrs := []attribute.KeyValue{}
if serverName != "" {
attrs = append(attrs, sc.HTTPServerNameKey.String(serverName))
@@ -210,7 +218,10 @@ func (sc *SemanticConventions) HTTPServerMetricAttributesFromHTTPRequest(serverN
// http namespace as specified by the OpenTelemetry specification for
// a span on the server side. Currently, only basic authentication is
// supported.
-func (sc *SemanticConventions) HTTPServerAttributesFromHTTPRequest(serverName, route string, request *http.Request) []attribute.KeyValue {
+func (sc *SemanticConventions) HTTPServerAttributesFromHTTPRequest(
+ serverName, route string,
+ request *http.Request,
+) []attribute.KeyValue {
attrs := []attribute.KeyValue{
sc.HTTPTargetKey.String(request.RequestURI),
}