@@ -15,37 +15,40 @@ import TracingInstrumentation
15
15
16
16
extension SpanAttributeName {
17
17
/// - See: HTTPAttributes
18
- public static let httpMethod = " http.method "
19
- /// - See: HTTPAttributes
20
- public static let httpURL = " http.url "
21
- /// - See: HTTPAttributes
22
- public static let httpTarget = " http.target "
23
- /// - See: HTTPAttributes
24
- public static let httpHost = " http.host "
25
- /// - See: HTTPAttributes
26
- public static let httpScheme = " http.scheme "
27
- /// - See: HTTPAttributes
28
- public static let httpStatusCode = " http.status_code "
29
- /// - See: HTTPAttributes
30
- public static let httpStatusText = " http.status_text "
31
- /// - See: HTTPAttributes
32
- public static let httpFlavor = " http.flavor "
33
- /// - See: HTTPAttributes
34
- public static let httpUserAgent = " http.user_agent "
35
- /// - See: HTTPAttributes
36
- public static let httpRequestContentLength = " http.request_content_length "
37
- /// - See: HTTPAttributes
38
- public static let httpRequestContentLengthUncompressed = " http.request_content_length_uncompressed "
39
- /// - See: HTTPAttributes
40
- public static let httpResponseContentLength = " http.response_content_length "
41
- /// - See: HTTPAttributes
42
- public static let httpResponseContentLengthUncompressed = " http.response_content_length_uncompressed "
43
- /// - See: HTTPAttributes
44
- public static let httpServerName = " http.server_name "
45
- /// - See: HTTPAttributes
46
- public static let httpServerRoute = " http.route "
47
- /// - See: HTTPAttributes
48
- public static let httpServerClientIP = " http.client_ip "
18
+ public enum HTTP {
19
+ /// - See: HTTPAttributes
20
+ public static let method = " http.method "
21
+ /// - See: HTTPAttributes
22
+ public static let url = " http.url "
23
+ /// - See: HTTPAttributes
24
+ public static let target = " http.target "
25
+ /// - See: HTTPAttributes
26
+ public static let host = " http.host "
27
+ /// - See: HTTPAttributes
28
+ public static let scheme = " http.scheme "
29
+ /// - See: HTTPAttributes
30
+ public static let statusCode = " http.status_code "
31
+ /// - See: HTTPAttributes
32
+ public static let statusText = " http.status_text "
33
+ /// - See: HTTPAttributes
34
+ public static let flavor = " http.flavor "
35
+ /// - See: HTTPAttributes
36
+ public static let userAgent = " http.user_agent "
37
+ /// - See: HTTPAttributes
38
+ public static let requestContentLength = " http.request_content_length "
39
+ /// - See: HTTPAttributes
40
+ public static let requestContentLengthUncompressed = " http.request_content_length_uncompressed "
41
+ /// - See: HTTPAttributes
42
+ public static let responseContentLength = " http.response_content_length "
43
+ /// - See: HTTPAttributes
44
+ public static let responseContentLengthUncompressed = " http.response_content_length_uncompressed "
45
+ /// - See: HTTPAttributes
46
+ public static let serverName = " http.server_name "
47
+ /// - See: HTTPAttributes
48
+ public static let serverRoute = " http.route "
49
+ /// - See: HTTPAttributes
50
+ public static let serverClientIP = " http.client_ip "
51
+ }
49
52
}
50
53
51
54
#if swift(>=5.2)
@@ -76,68 +79,68 @@ public struct HTTPAttributes: SpanAttributeNamespace {
76
79
public init ( ) { }
77
80
78
81
/// HTTP request method. E.g. "GET".
79
- public var method : SpanAttributeKey < String > { . init( name: SpanAttributeName . httpMethod ) }
82
+ public var method : SpanAttributeKey < String > { . init( name: SpanAttributeName . HTTP . method ) }
80
83
81
84
/// Full HTTP request URL in the form scheme://host[:port]/path?query[#fragment].
82
85
/// Usually the fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless.
83
- public var url : SpanAttributeKey < String > { . init( name: SpanAttributeName . httpURL ) }
86
+ public var url : SpanAttributeKey < String > { . init( name: SpanAttributeName . HTTP . url ) }
84
87
85
88
/// The full request target as passed in a HTTP request line or equivalent, e.g. "/path/12314/?q=ddds#123".
86
- public var target : SpanAttributeKey < String > { . init( name: SpanAttributeName . httpTarget ) }
89
+ public var target : SpanAttributeKey < String > { . init( name: SpanAttributeName . HTTP . target ) }
87
90
88
91
/// The value of the HTTP host header. When the header is empty or not present, this attribute should be the same.
89
- public var host : SpanAttributeKey < String > { . init( name: SpanAttributeName . httpHost ) }
92
+ public var host : SpanAttributeKey < String > { . init( name: SpanAttributeName . HTTP . host ) }
90
93
91
94
/// The URI scheme identifying the used protocol: "http" or "https"
92
- public var scheme : SpanAttributeKey < String > { . init( name: SpanAttributeName . httpScheme ) }
95
+ public var scheme : SpanAttributeKey < String > { . init( name: SpanAttributeName . HTTP . scheme ) }
93
96
94
97
/// HTTP response status code. E.g. 200.
95
- public var statusCode : SpanAttributeKey < Int > { . init( name: SpanAttributeName . httpStatusCode ) }
98
+ public var statusCode : SpanAttributeKey < Int > { . init( name: SpanAttributeName . HTTP . statusCode ) }
96
99
97
100
/// HTTP reason phrase. E.g. "OK".
98
- public var statusText : SpanAttributeKey < String > { . init( name: SpanAttributeName . httpStatusText ) }
101
+ public var statusText : SpanAttributeKey < String > { . init( name: SpanAttributeName . HTTP . statusText ) }
99
102
100
103
/// Kind of HTTP protocol used: "1.0", "1.1", "2", "SPDY" or "QUIC".
101
- public var flavor : SpanAttributeKey < String > { . init( name: SpanAttributeName . httpFlavor ) }
104
+ public var flavor : SpanAttributeKey < String > { . init( name: SpanAttributeName . HTTP . flavor ) }
102
105
103
106
/// Value of the HTTP User-Agent header sent by the client.
104
- public var userAgent : SpanAttributeKey < String > { . init( name: SpanAttributeName . httpUserAgent ) }
107
+ public var userAgent : SpanAttributeKey < String > { . init( name: SpanAttributeName . HTTP . userAgent ) }
105
108
106
109
/// The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often,
107
110
/// but not always, present as the Content-Length header. For requests using transport encoding, this should be the
108
111
/// compressed size.
109
112
public var requestContentLength : SpanAttributeKey < Int > {
110
- . init( name: SpanAttributeName . httpRequestContentLength )
113
+ . init( name: SpanAttributeName . HTTP . requestContentLength )
111
114
}
112
115
113
116
/// The size of the uncompressed request payload body after transport decoding. Not set if transport encoding not used.
114
117
public var requestContentLengthUncompressed : SpanAttributeKey < Int > {
115
- . init( name: SpanAttributeName . httpRequestContentLengthUncompressed )
118
+ . init( name: SpanAttributeName . HTTP . requestContentLengthUncompressed )
116
119
}
117
120
118
121
/// The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and
119
122
/// is often, but not always, present as the Content-Length header. For requests using transport encoding, this
120
123
/// should be the compressed size.
121
124
public var responseContentLength : SpanAttributeKey < Int > {
122
- . init( name: SpanAttributeName . httpResponseContentLength )
125
+ . init( name: SpanAttributeName . HTTP . responseContentLength )
123
126
}
124
127
125
128
/// The size of the uncompressed response payload body after transport decoding. Not set if transport encoding not used.
126
129
public var responseContentLengthUncompressed : SpanAttributeKey < Int > {
127
- . init( name: SpanAttributeName . httpResponseContentLengthUncompressed )
130
+ . init( name: SpanAttributeName . HTTP . responseContentLengthUncompressed )
128
131
}
129
132
130
133
/// The primary server name of the matched virtual host. This should be obtained via configuration.
131
134
/// If no such configuration can be obtained, this attribute MUST NOT be set (`net.hostName` should be used instead).
132
- public var serverName : SpanAttributeKey < String > { . init( name: SpanAttributeName . httpServerName ) }
135
+ public var serverName : SpanAttributeKey < String > { . init( name: SpanAttributeName . HTTP . serverName ) }
133
136
134
137
/// The matched route (path template). E.g. "/users/:userID?".
135
- public var serverRoute : SpanAttributeKey < String > { . init( name: SpanAttributeName . httpServerRoute ) }
138
+ public var serverRoute : SpanAttributeKey < String > { . init( name: SpanAttributeName . HTTP . serverRoute ) }
136
139
137
140
/// The IP address of the original client behind all proxies, if known (e.g. from X-Forwarded-For).
138
141
/// Note that this is not necessarily the same as `net.peerIP`, which would identify the network-level peer,
139
142
/// which may be a proxy.
140
- public var serverClientIP : SpanAttributeKey < String > { . init( name: SpanAttributeName . httpServerClientIP ) }
143
+ public var serverClientIP : SpanAttributeKey < String > { . init( name: SpanAttributeName . HTTP . serverClientIP ) }
141
144
}
142
145
}
143
146
#endif
0 commit comments