Skip to content

Commit

Permalink
Add int and double types. Small bugfixes. (#30)
Browse files Browse the repository at this point in the history
Co-authored-by: Armin Ruech <[email protected]>
  • Loading branch information
thisthat and arminru authored Mar 16, 2021
1 parent e3aa9b4 commit b4f8bdd
Show file tree
Hide file tree
Showing 68 changed files with 262 additions and 93 deletions.
7 changes: 7 additions & 0 deletions semantic-conventions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

Please update changelog as part of any significant pull request.

# v0.3.0

- BREAKING CHANGE: Removed `number` and `number[]` attribute types in favor of `int`, `int[]`, `double` and `double[]`. (#30)
2 changes: 1 addition & 1 deletion semantic-conventions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ docker run --rm otel/semconvgen --yaml-root {yaml_folder} code --template {jinja
```

By default, all models are fed into the specified template at once, i.e. only a single file is generated.
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).
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).

If the parameter `--file-per-group {pattern}` is set, a single yaml model is fed into the template
and the value of `pattern` is resolved from the model and attached as prefix to the output argument.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def attributes(self):

def unique_attributes(attributes):
output = []
for x in l:
for x in attributes:
if x.fqn not in [attr.fqn for attr in output]:
output.append(x)
return output
Expand Down Expand Up @@ -237,7 +237,14 @@ def parse_id(attribute):
and examples is not None
):
examples = [examples]
if is_simple_type and attr_type not in ["boolean", "boolean[]"]:
if is_simple_type and attr_type not in [
"boolean",
"boolean[]",
"int",
"int[]",
"double",
"double[]",
]:
if examples is None or (len(examples) == 0):
position = attribute.lc.data[list(attribute)[0]]
msg = "Empty examples for {} are not allowed".format(attr_type)
Expand Down Expand Up @@ -275,17 +282,21 @@ def is_simple_type(attr_type: str):
return attr_type in (
"string",
"string[]",
"number",
"number[]",
"int",
"int[]",
"double",
"double[]",
"boolean",
"boolean[]",
)

@staticmethod
def type_mapper(attr_type: str):
type_mapper = {
"number": int,
"number[]": int,
"int": int,
"int[]": int,
"double": float,
"double[]": float,
"string": str,
"string[]": str,
"boolean": bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def to_markdown_attr(
description += " [{}]".format(len(self.render_ctx.notes))
examples = ""
if isinstance(attribute.attr_type, EnumAttributeType):
if attribute.is_local and not attribute.ref:
if self.render_ctx.is_full or (attribute.is_local and not attribute.ref):
self.render_ctx.add_enum(attribute)
example_list = attribute.examples if attribute.examples else ()
examples = (
Expand Down Expand Up @@ -399,6 +399,12 @@ def _render_table(self, semconv, parameters, output):
continue
if self.render_ctx.is_full or attr.is_local:
attr_to_print.append(attr)
if self.render_ctx.group_key is not None and not attr_to_print:
raise ValueError(
"No attributes retained for '{}' filtering by '{}'".format(
semconv.semconv_id, self.render_ctx.group_key
)
)
if attr_to_print:
output.write(MarkdownRenderer.table_headers)
for attr in attr_to_print:
Expand Down
2 changes: 1 addition & 1 deletion semantic-conventions/src/opentelemetry/semconv/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.2.0"
__version__ = "0.3.0"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| `http.target` | string | The full request target as passed in a HTTP request line or equivalent. | `/path/12314/?q=ddds#123` | No |
| `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 |
| `http.scheme` | string | The URI scheme identifying the used protocol. | `http`; `https` | No |
| `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 |
| `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 |
| `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 |
| `http.flavor` | string | **Deprecated. Use attribute `flavor_new` instead.**<br>Kind of HTTP protocol used [1] | `1.0` | No |
| `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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ groups:
[RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6)
examples: '127.0.0.1'
- id: peer.port
type: number
type: int
brief: 'Remote port number.'
examples: [80, 8080, 443]
- id: peer.name
Expand All @@ -54,7 +54,7 @@ groups:
brief: 'Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.'
examples: '192.168.0.1'
- id: host.port
type: number
type: int
brief: 'Like `net.peer.port` but for the host port.'
examples: 35555
- id: host.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ groups:
brief: 'The URI scheme identifying the used protocol.'
examples: ["http", "https"]
- id: status_code
type: number
type: int
required:
conditional: "If and only if one was received/sent"
brief: '[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ groups:
[RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6)
examples: '127.0.0.1'
- id: peer.port
type: number
type: int
brief: 'Remote port number.'
examples: [80, 8080, 443]
- id: peer.name
Expand All @@ -54,7 +54,7 @@ groups:
brief: 'Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.'
examples: '192.168.0.1'
- id: host.port
type: number
type: int
brief: 'Like `net.peer.port` but for the host port.'
examples: 35555
- id: host.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ groups:
brief: 'The URI scheme identifying the used protocol.'
examples: ["http", "https"]
- id: status_code
type: number
type: int
required:
conditional: "If and only if one was received/sent"
brief: '[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ groups:
[RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6)
examples: '127.0.0.1'
- id: peer.port
type: number
type: int
brief: 'Remote port number.'
examples: [80, 8080, 443]
- id: peer.name
Expand All @@ -54,7 +54,7 @@ groups:
brief: 'Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.'
examples: '192.168.0.1'
- id: host.port
type: number
type: int
brief: 'Like `net.peer.port` but for the host port.'
examples: 35555
- id: host.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ groups:
brief: 'The URI scheme identifying the used protocol.'
examples: ["http", "https"]
- id: status_code
type: number
type: int
required:
conditional: If and only if one was received/sent.
brief: '[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ groups:
Call-level attributes for Redis
attributes:
- id: database_index
type: number
type: int
required:
conditional: Required, if other than the default database (`0`).
brief: >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Some database systems may allow a connection to switch to a different `db.user`,
| `db.user` | string | Username for accessing the database. | `readonly_user`; `reporting_user` | No |
| `net.peer.ip` | string | Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6) | `127.0.0.1` | See below. |
| `net.peer.name` | string | Remote hostname or similar, see note below. | `example.com` | See below. |
| `net.peer.port` | number | Remote port number. | `80`; `8080`; `443` | Conditional [2] |
| `net.peer.port` | int | Remote port number. | `80`; `8080`; `443` | Conditional [2] |
| `net.transport` | string | Transport protocol used. See note below. | `IP.TCP` | Conditional [3] |

**[1]:** It is recommended to remove embedded credentials.
Expand Down Expand Up @@ -187,7 +187,7 @@ For example, when retrieving a document, `db.operation` would be set to (literal
<!-- semconv db.redis -->
| Attribute | Type | Description | Examples | Required |
|---|---|---|---|---|
| `db.redis.database_index` | number | The index of the database being accessed as used in the [`SELECT` command](https://redis.io/commands/select), provided as an integer. To be used instead of the generic `db.name` attribute. | `0`; `1`; `15` | Conditional [1] |
| `db.redis.database_index` | int | The index of the database being accessed as used in the [`SELECT` command](https://redis.io/commands/select), provided as an integer. To be used instead of the generic `db.name` attribute. | `0`; `1`; `15` | Conditional [1] |

**[1]:** Required, if other than the default database (`0`).
<!-- endsemconv -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ groups:
[RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6)
examples: '127.0.0.1'
- id: peer.port
type: number
type: int
brief: 'Remote port number.'
examples: [80, 8080, 443]
- id: peer.name
Expand All @@ -54,7 +54,7 @@ groups:
brief: 'Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.'
examples: '192.168.0.1'
- id: host.port
type: number
type: int
brief: 'Like `net.peer.port` but for the host port.'
examples: 35555
- id: host.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Some database systems may allow a connection to switch to a different `db.user`,
| `db.user` | string | Username for accessing the database. | `readonly_user`<br>`reporting_user` | No |
| `net.peer.ip` | string | Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6) | `127.0.0.1` | Conditional<br>See below. |
| `net.peer.name` | string | Remote hostname or similar, see note below. | `example.com` | Conditional<br>See below. |
| `net.peer.port` | number | Remote port number. | `80`<br>`8080`<br>`443` | Conditional [2] |
| `net.peer.port` | int | Remote port number. | `80`<br>`8080`<br>`443` | Conditional [2] |
| `net.transport` | string enum | Transport protocol used. See note below. | `IP.TCP` | Conditional [3] |

**[1]:** It is recommended to remove embedded credentials.
Expand Down Expand Up @@ -187,7 +187,7 @@ For example, when retrieving a document, `db.operation` would be set to (literal
<!-- semconv db.redis -->
| Attribute | Type | Description | Examples | Required |
|---|---|---|---|---|
| `db.redis.database_index` | number | The index of the database being accessed as used in the [`SELECT` command](https://redis.io/commands/select), provided as an integer. To be used instead of the generic `db.name` attribute. | `0`<br>`1`<br>`15` | Conditional [1] |
| `db.redis.database_index` | int | The index of the database being accessed as used in the [`SELECT` command](https://redis.io/commands/select), provided as an integer. To be used instead of the generic `db.name` attribute. | `0`<br>`1`<br>`15` | Conditional [1] |

**[1]:** Required, if other than the default database (`0`).
<!-- endsemconv -->
Expand Down
22 changes: 21 additions & 1 deletion semantic-conventions/src/tests/data/markdown/include/expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| `http.target` | string | The full request target as passed in a HTTP request line or equivalent. | `/path/12314/?q=ddds#123` | See below |
| `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` | See below |
| `http.scheme` | string | The URI scheme identifying the used protocol. | `http`; `https` | See below |
| `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 |
| `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 |
| `http.status_text` | string | [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). | `OK` | No |
| `http.flavor` | string | Kind of HTTP protocol used [1] | `1.0` | No |
| `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 |
Expand All @@ -28,4 +28,24 @@
* `http.scheme`, `http.host`, `http.target`
* `http.scheme`, [`http.server_name`](input_http.md), `net.host.port`, `http.target`
* `http.scheme`, `net.host.name`, `net.host.port`, `http.target`

`faas.trigger` MUST be one of the following:

| Value | Description |
|---|---|
| `datasource` | A response to some data source operation such as a database or filesystem read/write. |
| `http` | To provide an answer to an inbound HTTP request |
| `pubsub` | A function is set to be executed when messages are sent to a messaging system. |
| `timer` | A function is scheduled to be executed regularly. |
| `other` | other |

`http.flavor` MUST be one of the following or, if none of the listed values apply, a custom value:

| Value | Description |
|---|---|
| `1.0` | HTTP 1.0 |
| `1.1` | HTTP 1.1 |
| `2.0` | HTTP 2 |
| `SPDY` | SPDY protocol. |
| `QUIC` | QUIC protocol. |
<!-- endsemconv -->
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ groups:
[RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6)
examples: '127.0.0.1'
- id: peer.port
type: number
type: int
brief: 'Remote port number.'
examples: [80, 8080, 443]
- id: peer.name
Expand All @@ -54,7 +54,7 @@ groups:
brief: 'Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.'
examples: '192.168.0.1'
- id: host.port
type: number
type: int
brief: 'Like `net.peer.port` but for the host port.'
examples: 35555
- id: host.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ groups:
brief: 'The URI scheme identifying the used protocol.'
examples: ["http", "https"]
- id: status_code
type: number
type: int
required:
conditional: "If and only if one was received/sent"
brief: '[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ groups:
[RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6)
examples: '127.0.0.1'
- id: peer.port
type: number
type: int
brief: 'Remote port number.'
examples: [80, 8080, 443]
- id: peer.name
Expand All @@ -54,7 +54,7 @@ groups:
brief: 'Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.'
examples: '192.168.0.1'
- id: host.port
type: number
type: int
brief: 'Like `net.peer.port` but for the host port.'
examples: 35555
- id: host.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ groups:
brief: 'The URI scheme identifying the used protocol.'
examples: ["http", "https"]
- id: status_code
type: number
type: int
required:
conditional: "If and only if one was received/sent"
brief: '[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| `http.target` | string | The full request target as passed in a HTTP request line or equivalent. | `/path/12314/?q=ddds#123` | No |
| `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 |
| `http.scheme` | string | The URI scheme identifying the used protocol. | `http`; `https` | No |
| `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 |
| `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 |
| `http.status_text` | string | [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). | `OK` | No |
| `http.flavor` | string | Kind of HTTP protocol used [1] | `1.0` | No |
| `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 |
Expand All @@ -35,7 +35,7 @@
| `http.target` | string | The full request target as passed in a HTTP request line or equivalent. | `/path/12314/?q=ddds#123` | No |
| `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 |
| `http.scheme` | string | The URI scheme identifying the used protocol. | `http`; `https` | No |
| `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 |
| `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 |
| `http.status_text` | string | [HTTP reason phrase](https://tools.ietf.org/html/rfc7230#section-3.1.2). | `OK` | No |
| `http.flavor` | string | Kind of HTTP protocol used [1] | `1.0` | No |
| `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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ groups:
[RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6)
examples: '127.0.0.1'
- id: peer.port
type: number
type: int
brief: 'Remote port number.'
examples: [80, 8080, 443]
- id: peer.name
Expand All @@ -54,7 +54,7 @@ groups:
brief: 'Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.'
examples: '192.168.0.1'
- id: host.port
type: number
type: int
brief: 'Like `net.peer.port` but for the host port.'
examples: 35555
- id: host.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ groups:
brief: 'The URI scheme identifying the used protocol.'
examples: ["http", "https"]
- id: status_code
type: number
type: int
required:
conditional: "If and only if one was received/sent"
brief: '[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6).'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ groups:
[RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6)
examples: '127.0.0.1'
- id: peer.port
type: number
type: int
brief: 'Remote port number.'
examples: [80, 8080, 443]
- id: peer.name
Expand All @@ -54,7 +54,7 @@ groups:
brief: 'Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host.'
examples: '192.168.0.1'
- id: host.port
type: number
type: int
brief: 'Like `net.peer.port` but for the host port.'
examples: 35555
- id: host.name
Expand Down
Loading

0 comments on commit b4f8bdd

Please sign in to comment.