Skip to content

Commit 8462991

Browse files
lmolkovajerbly
andauthored
Attribute groups in schema v2 (#933)
* attribute groups v2 * refactor and clean up registry * review: cleanup, more tests, docs * also suppress clippy on unused_qualifications * more clippy suppressions and proofread doc * changelog * fix unused qualifications * clean up --------- Co-authored-by: Jeremy Blythe <jeremyblythe@gmail.com>
1 parent 8e36299 commit 8462991

File tree

37 files changed

+2070
-299
lines changed

37 files changed

+2070
-299
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
if [ "$CURRENT_TOOLCHAIN" != "${{ env.MSRV }}" ]; then
7171
echo "Expected active toolchain ${{ env.MSRV }} but got $CURRENT_TOOLCHAIN"
7272
exit 1
73-
else
73+
else
7474
echo "Correct toolchain $CURRENT_TOOLCHAIN is installed and active"
7575
fi
7676
- name: Default features

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
44

55
# Unreleased
66

7+
- Add support for attribute_group (public and internal) in schema v2 ([#933](https://github.com/open-telemetry/weaver/pull/933) by @lmolkova)
78
- Live-check report changes ([#943](https://github.com/open-telemetry/weaver/pull/943) by @lmolkova)
89
- 💥 BREAKING CHANGE 💥 `value` property in `Advice` is renamed to `advice_context`
910
- Advice now contains `signal_type` and `signal_name` properties to simplify post-processing

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/weaver_forge/data/http.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
version: "2"
2+
attribute_groups:
3+
- id: http.client.server_and_port
4+
visibility: internal
5+
attributes:
6+
- ref: server.address
7+
brief: "Some HTTP specific description"
8+
requirement_level: required
9+
- ref: server.port
10+
requirement_level: required
11+
brief: "Some HTTP specific description"
12+
- ref: http.request.method
13+
spans:
14+
- type: http.client
15+
brief: HTTP client span
16+
stability: stable
17+
name:
18+
note: "{http.request.method} {server.address}:{server.port}"
19+
kind: client
20+
attributes:
21+
- ref_group: http.client.server_and_port
22+
- ref: http.request.method
23+
requirement_level: required
24+
sampling_relevant: true
25+
- ref: url.full
26+
requirement_level: required
27+
sampling_relevant: true
28+
- ref: server.address
29+
sampling_relevant: true
30+
- ref: server.port
31+
sampling_relevant: true
32+
- ref: http.response.status_code
33+
34+
metrics:
35+
- name: http.client.request.duration
36+
brief: "Duration of HTTP client requests."
37+
instrument: histogram
38+
unit: "s"
39+
stability: stable
40+
attributes:
41+
- ref_group: http.client.server_and_port
42+
- ref: http.request.method
43+
requirement_level: recommended
44+
- ref: url.scheme
45+
requirement_level: opt_in
46+
examples: ["http", "https"]
47+
- ref: http.response.status_code
48+
requirement_level: recommended
49+
brief: "[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6)."
50+
examples: [200]
Lines changed: 132 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,140 @@
1-
groups:
2-
- id: registry.http
3-
type: attribute_group
4-
brief: "This document defines semantic convention attributes in the HTTP namespace."
5-
attributes:
6-
- id: http.request.body.size
7-
type: int
8-
brief: >
9-
The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and
10-
is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length)
11-
header. For requests using transport encoding, this should be the compressed size.
12-
examples: 3495
13-
stability: experimental # this should not be marked stable with other HTTP attributes
14-
- id: http.request.header
15-
stability: stable
16-
type: template[string[]]
17-
brief: >
18-
HTTP request headers, `<key>` being the normalized HTTP Header name (lowercase), the value being the header values.
19-
note: >
20-
Instrumentations SHOULD require an explicit configuration of which headers are to be captured.
21-
Including all request headers can be a security risk - explicit configuration helps avoid leaking sensitive information.
1+
version: "2"
2+
attributes:
3+
- key: http.request.body.size
4+
type: int
5+
brief: >
6+
The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and
7+
is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length)
8+
header. For requests using transport encoding, this should be the compressed size.
9+
examples: 3495
10+
stability: experimental # this should not be marked stable with other HTTP attributes
11+
- key: http.request.header
12+
stability: stable
13+
type: template[string[]]
14+
brief: >
15+
HTTP request headers, `<key>` being the normalized HTTP Header name (lowercase), the value being the header values.
16+
note: >
17+
Instrumentations SHOULD require an explicit configuration of which headers are to be captured.
18+
Including all request headers can be a security risk - explicit configuration helps avoid leaking sensitive information.
2219
23-
The `User-Agent` header is already captured in the `user_agent.original` attribute.
24-
Users MAY explicitly configure instrumentations to capture them even though it is not recommended.
20+
The `User-Agent` header is already captured in the `user_agent.original` attribute.
21+
Users MAY explicitly configure instrumentations to capture them even though it is not recommended.
2522
26-
The attribute value MUST consist of either multiple header values as an array of strings
27-
or a single-item array containing a possibly comma-concatenated string, depending on the way
28-
the HTTP library provides access to headers.
29-
examples: [["application/json"], ["1.2.3.4", "1.2.3.5"]]
30-
- id: http.request.method
31-
stability: stable
32-
type:
33-
members:
34-
- id: connect
35-
stability: stable
36-
value: "CONNECT"
37-
brief: "CONNECT method."
38-
- id: delete
39-
stability: stable
40-
value: "DELETE"
41-
brief: "DELETE method."
42-
- id: get
43-
stability: stable
44-
value: "GET"
45-
brief: "GET method."
46-
- id: head
47-
stability: stable
48-
value: "HEAD"
49-
brief: "HEAD method."
50-
- id: options
51-
stability: stable
52-
value: "OPTIONS"
53-
brief: "OPTIONS method."
54-
- id: patch
55-
stability: stable
56-
value: "PATCH"
57-
brief: "PATCH method."
58-
- id: post
59-
stability: stable
60-
value: "POST"
61-
brief: "POST method."
62-
- id: put
63-
stability: stable
64-
value: "PUT"
65-
brief: "PUT method."
66-
- id: trace
67-
stability: stable
68-
value: "TRACE"
69-
brief: "TRACE method."
70-
- id: other
71-
stability: stable
72-
value: "_OTHER"
73-
brief: "Any HTTP method that the instrumentation has no prior knowledge of."
74-
brief: "HTTP request method."
75-
examples: ["GET", "POST", "HEAD"]
76-
note: |
77-
HTTP request method value SHOULD be "known" to the instrumentation.
78-
By default, this convention defines "known" methods as the ones listed in [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods)
79-
and the PATCH method defined in [RFC5789](https://www.rfc-editor.org/rfc/rfc5789.html).
23+
The attribute value MUST consist of either multiple header values as an array of strings
24+
or a single-item array containing a possibly comma-concatenated string, depending on the way
25+
the HTTP library provides access to headers.
26+
examples: [["application/json"], ["1.2.3.4", "1.2.3.5"]]
27+
- key: http.request.method
28+
stability: stable
29+
type:
30+
members:
31+
- id: connect
32+
stability: stable
33+
value: "CONNECT"
34+
brief: "CONNECT method."
35+
- id: delete
36+
stability: stable
37+
value: "DELETE"
38+
brief: "DELETE method."
39+
- id: get
40+
stability: stable
41+
value: "GET"
42+
brief: "GET method."
43+
- id: head
44+
stability: stable
45+
value: "HEAD"
46+
brief: "HEAD method."
47+
- id: options
48+
stability: stable
49+
value: "OPTIONS"
50+
brief: "OPTIONS method."
51+
- id: patch
52+
stability: stable
53+
value: "PATCH"
54+
brief: "PATCH method."
55+
- id: post
56+
stability: stable
57+
value: "POST"
58+
brief: "POST method."
59+
- id: put
60+
stability: stable
61+
value: "PUT"
62+
brief: "PUT method."
63+
- id: trace
64+
stability: stable
65+
value: "TRACE"
66+
brief: "TRACE method."
67+
- id: other
68+
stability: stable
69+
value: "_OTHER"
70+
brief: "Any HTTP method that the instrumentation has no prior knowledge of."
71+
brief: "HTTP request method."
72+
examples: ["GET", "POST", "HEAD"]
73+
note: |
74+
HTTP request method value SHOULD be "known" to the instrumentation.
75+
By default, this convention defines "known" methods as the ones listed in [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods)
76+
and the PATCH method defined in [RFC5789](https://www.rfc-editor.org/rfc/rfc5789.html).
8077
81-
If the HTTP request method is not known to instrumentation, it MUST set the `http.request.method` attribute to `_OTHER`.
78+
If the HTTP request method is not known to instrumentation, it MUST set the `http.request.method` attribute to `_OTHER`.
8279
83-
If the HTTP instrumentation could end up converting valid HTTP request methods to `_OTHER`, then it MUST provide a way to override
84-
the list of known HTTP methods. If this override is done via environment variable, then the environment variable MUST be named
85-
OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and support a comma-separated list of case-sensitive known HTTP methods
86-
(this list MUST be a full override of the default known method, it is not a list of known methods in addition to the defaults).
80+
If the HTTP instrumentation could end up converting valid HTTP request methods to `_OTHER`, then it MUST provide a way to override
81+
the list of known HTTP methods. If this override is done via environment variable, then the environment variable MUST be named
82+
OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and support a comma-separated list of case-sensitive known HTTP methods
83+
(this list MUST be a full override of the default known method, it is not a list of known methods in addition to the defaults).
8784
88-
HTTP method names are case-sensitive and `http.request.method` attribute value MUST match a known HTTP method name exactly.
89-
Instrumentations for specific web frameworks that consider HTTP methods to be case insensitive, SHOULD populate a canonical equivalent.
90-
Tracing instrumentations that do so, MUST also set `http.request.method_original` to the original value.
91-
- id: http.request.method_original
92-
stability: stable
93-
type: string
94-
brief: Original HTTP method sent by the client in the request line.
95-
examples: ["GeT", "ACL", "foo"]
96-
- id: http.request.resend_count
97-
stability: stable
98-
type: int
99-
brief: >
100-
The ordinal number of request resending attempt (for any reason, including redirects).
101-
note: >
102-
The resend count SHOULD be updated each time an HTTP request gets resent by the client, regardless of what
103-
was the cause of the resending (e.g. redirection, authorization failure, 503 Server Unavailable, network issues,
104-
or any other).
105-
examples: 3
106-
- id: http.response.body.size
107-
type: int
108-
brief: >
109-
The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and
110-
is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length)
111-
header. For requests using transport encoding, this should be the compressed size.
112-
examples: 3495
113-
stability: experimental # this should not be marked stable with other HTTP attributes
114-
- id: http.response.header
115-
stability: stable
116-
type: template[string[]]
117-
brief: >
118-
HTTP response headers, `<key>` being the normalized HTTP Header name (lowercase), the value being the header values.
119-
note: >
120-
Instrumentations SHOULD require an explicit configuration of which headers are to be captured.
121-
Including all response headers can be a security risk - explicit configuration helps avoid leaking sensitive information.
85+
HTTP method names are case-sensitive and `http.request.method` attribute value MUST match a known HTTP method name exactly.
86+
Instrumentations for specific web frameworks that consider HTTP methods to be case insensitive, SHOULD populate a canonical equivalent.
87+
Tracing instrumentations that do so, MUST also set `http.request.method_original` to the original value.
88+
- key: http.request.method_original
89+
stability: stable
90+
type: string
91+
brief: Original HTTP method sent by the client in the request line.
92+
examples: ["GeT", "ACL", "foo"]
93+
- key: http.request.resend_count
94+
stability: stable
95+
type: int
96+
brief: >
97+
The ordinal number of request resending attempt (for any reason, including redirects).
98+
note: >
99+
The resend count SHOULD be updated each time an HTTP request gets resent by the client, regardless of what
100+
was the cause of the resending (e.g. redirection, authorization failure, 503 Server Unavailable, network issues,
101+
or any other).
102+
examples: 3
103+
- key: http.response.body.size
104+
type: int
105+
brief: >
106+
The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and
107+
is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length)
108+
header. For requests using transport encoding, this should be the compressed size.
109+
examples: 3495
110+
stability: experimental # this should not be marked stable with other HTTP attributes
111+
- key: http.response.header
112+
stability: stable
113+
type: template[string[]]
114+
brief: >
115+
HTTP response headers, `<key>` being the normalized HTTP Header name (lowercase), the value being the header values.
116+
note: >
117+
Instrumentations SHOULD require an explicit configuration of which headers are to be captured.
118+
Including all response headers can be a security risk - explicit configuration helps avoid leaking sensitive information.
122119
123-
Users MAY explicitly configure instrumentations to capture them even though it is not recommended.
120+
Users MAY explicitly configure instrumentations to capture them even though it is not recommended.
124121
125-
The attribute value MUST consist of either multiple header values as an array of strings
126-
or a single-item array containing a possibly comma-concatenated string, depending on the way
127-
the HTTP library provides access to headers.
128-
examples: [["application/json"], ["abc", "def"]]
129-
- id: http.response.status_code
130-
stability: stable
131-
type: int
132-
brief: "[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6)."
133-
examples: [200]
134-
- id: http.route
135-
stability: stable
136-
type: string
137-
brief: >
138-
The matched route, that is, the path template in the format used by the respective server framework.
139-
examples: ["/users/:userID?", "{controller}/{action}/{id?}"]
140-
note: >
141-
MUST NOT be populated when this is not supported by the HTTP server framework as the route attribute should have low-cardinality and the URI path can NOT substitute it.
122+
The attribute value MUST consist of either multiple header values as an array of strings
123+
or a single-item array containing a possibly comma-concatenated string, depending on the way
124+
the HTTP library provides access to headers.
125+
examples: [["application/json"], ["abc", "def"]]
126+
- key: http.response.status_code
127+
stability: stable
128+
type: int
129+
brief: "[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6)."
130+
examples: [200]
131+
- key: http.route
132+
stability: stable
133+
type: string
134+
brief: >
135+
The matched route, that is, the path template in the format used by the respective server framework.
136+
examples: ["/users/:userID?", "{controller}/{action}/{id?}"]
137+
note: >
138+
MUST NOT be populated when this is not supported by the HTTP server framework as the route attribute should have low-cardinality and the URI path can NOT substitute it.
142139
143-
SHOULD include the [application root](/docs/http/http-spans.md#http-server-definitions) if there is one.
140+
SHOULD include the [application root](/docs/http/http-spans.md#http-server-definitions) if there is one.

0 commit comments

Comments
 (0)