Skip to content

Commit b4f8bdd

Browse files
thisthatarminru
andauthored
Add int and double types. Small bugfixes. (#30)
Co-authored-by: Armin Ruech <[email protected]>
1 parent e3aa9b4 commit b4f8bdd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+262
-93
lines changed

semantic-conventions/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
Please update changelog as part of any significant pull request.
4+
5+
# v0.3.0
6+
7+
- BREAKING CHANGE: Removed `number` and `number[]` attribute types in favor of `int`, `int[]`, `double` and `double[]`. (#30)

semantic-conventions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ docker run --rm otel/semconvgen --yaml-root {yaml_folder} code --template {jinja
7878
```
7979

8080
By default, all models are fed into the specified template at once, i.e. only a single file is generated.
81-
This is helpful to generate constants for the semantic attributes, [example from opentelemetry-java](https://github.com/open-telemetry/opentelemetry-java/blob/master/api/src/main/java/io/opentelemetry/trace/attributes/SemanticAttributes.java).
81+
This is helpful to generate constants for the semantic attributes, [example from opentelemetry-java](https://github.com/open-telemetry/opentelemetry-java/tree/main/buildscripts/semantic-convention).
8282

8383
If the parameter `--file-per-group {pattern}` is set, a single yaml model is fed into the template
8484
and the value of `pattern` is resolved from the model and attached as prefix to the output argument.

semantic-conventions/src/opentelemetry/semconv/model/semantic_attribute.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def attributes(self):
4949

5050
def unique_attributes(attributes):
5151
output = []
52-
for x in l:
52+
for x in attributes:
5353
if x.fqn not in [attr.fqn for attr in output]:
5454
output.append(x)
5555
return output
@@ -237,7 +237,14 @@ def parse_id(attribute):
237237
and examples is not None
238238
):
239239
examples = [examples]
240-
if is_simple_type and attr_type not in ["boolean", "boolean[]"]:
240+
if is_simple_type and attr_type not in [
241+
"boolean",
242+
"boolean[]",
243+
"int",
244+
"int[]",
245+
"double",
246+
"double[]",
247+
]:
241248
if examples is None or (len(examples) == 0):
242249
position = attribute.lc.data[list(attribute)[0]]
243250
msg = "Empty examples for {} are not allowed".format(attr_type)
@@ -275,17 +282,21 @@ def is_simple_type(attr_type: str):
275282
return attr_type in (
276283
"string",
277284
"string[]",
278-
"number",
279-
"number[]",
285+
"int",
286+
"int[]",
287+
"double",
288+
"double[]",
280289
"boolean",
281290
"boolean[]",
282291
)
283292

284293
@staticmethod
285294
def type_mapper(attr_type: str):
286295
type_mapper = {
287-
"number": int,
288-
"number[]": int,
296+
"int": int,
297+
"int[]": int,
298+
"double": float,
299+
"double[]": float,
289300
"string": str,
290301
"string[]": str,
291302
"boolean": bool,

semantic-conventions/src/opentelemetry/semconv/templating/markdown.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def to_markdown_attr(
121121
description += " [{}]".format(len(self.render_ctx.notes))
122122
examples = ""
123123
if isinstance(attribute.attr_type, EnumAttributeType):
124-
if attribute.is_local and not attribute.ref:
124+
if self.render_ctx.is_full or (attribute.is_local and not attribute.ref):
125125
self.render_ctx.add_enum(attribute)
126126
example_list = attribute.examples if attribute.examples else ()
127127
examples = (
@@ -399,6 +399,12 @@ def _render_table(self, semconv, parameters, output):
399399
continue
400400
if self.render_ctx.is_full or attr.is_local:
401401
attr_to_print.append(attr)
402+
if self.render_ctx.group_key is not None and not attr_to_print:
403+
raise ValueError(
404+
"No attributes retained for '{}' filtering by '{}'".format(
405+
semconv.semconv_id, self.render_ctx.group_key
406+
)
407+
)
402408
if attr_to_print:
403409
output.write(MarkdownRenderer.table_headers)
404410
for attr in attr_to_print:

semantic-conventions/src/opentelemetry/semconv/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.2.0"
15+
__version__ = "0.3.0"

semantic-conventions/src/tests/data/markdown/deprecated/expected.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| `http.target` | string | The full request target as passed in a HTTP request line or equivalent. | `/path/12314/?q=ddds#123` | No |
1010
| `http.host` | string | The value of the [HTTP host header](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is empty or not present, this attribute should be the same. | `www.example.org` | No |
1111
| `http.scheme` | string | The URI scheme identifying the used protocol. | `http`; `https` | No |
12-
| `http.status_code` | number | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | If and only if one was received/sent |
12+
| `http.status_code` | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | If and only if one was received/sent |
1313
| `http.status_text` | string | **Deprecated: Use attribute `status_description` instead.**<br>[HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). | `OK` | No |
1414
| `http.flavor` | string | **Deprecated. Use attribute `flavor_new` instead.**<br>Kind of HTTP protocol used [1] | `1.0` | No |
1515
| `http.user_agent` | string | Value of the [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the client. | `CERN-LineMode/2.15 libwww/2.17b3` | No |

semantic-conventions/src/tests/data/markdown/deprecated/general.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ groups:
4242
[RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6)
4343
examples: '127.0.0.1'
4444
- id: peer.port
45-
type: number
45+
type: int
4646
brief: 'Remote port number.'
4747
examples: [80, 8080, 443]
4848
- id: peer.name
@@ -54,7 +54,7 @@ groups:
5454
brief: 'Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.'
5555
examples: '192.168.0.1'
5656
- id: host.port
57-
type: number
57+
type: int
5858
brief: 'Like `net.peer.port` but for the host port.'
5959
examples: 35555
6060
- id: host.name

semantic-conventions/src/tests/data/markdown/deprecated/http.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ groups:
3434
brief: 'The URI scheme identifying the used protocol.'
3535
examples: ["http", "https"]
3636
- id: status_code
37-
type: number
37+
type: int
3838
required:
3939
conditional: "If and only if one was received/sent"
4040
brief: '[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).'

semantic-conventions/src/tests/data/markdown/empty/general.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ groups:
4242
[RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6)
4343
examples: '127.0.0.1'
4444
- id: peer.port
45-
type: number
45+
type: int
4646
brief: 'Remote port number.'
4747
examples: [80, 8080, 443]
4848
- id: peer.name
@@ -54,7 +54,7 @@ groups:
5454
brief: 'Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.'
5555
examples: '192.168.0.1'
5656
- id: host.port
57-
type: number
57+
type: int
5858
brief: 'Like `net.peer.port` but for the host port.'
5959
examples: 35555
6060
- id: host.name

semantic-conventions/src/tests/data/markdown/empty/http.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ groups:
3434
brief: 'The URI scheme identifying the used protocol.'
3535
examples: ["http", "https"]
3636
- id: status_code
37-
type: number
37+
type: int
3838
required:
3939
conditional: "If and only if one was received/sent"
4040
brief: '[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).'

0 commit comments

Comments
 (0)