Skip to content

Commit

Permalink
Fixes #47 multiple lines added in table generation (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryce-b authored Jun 22, 2021
1 parent 95d152e commit c7067fa
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ def to_markdown_enum(self, output: io.StringIO):
for note in notes:
output.write("\n\n**[{}]:** {}".format(counter, note))
counter += 1
if notes:
output.write("\n")

def render_attribute_id(self, attribute_id):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Common Attributes

<!-- Re-generate TOC with `TODO: ADD cmd` -->
<!-- semconv network -->
| Attribute | Type | Description | Examples | Required |
|---|---|---|---|---|
| `net.transport` | string | Transport protocol used. See note below. | `IP.TCP` | No |
| `net.host.connection.type` | string | unavailable | `wifi` | No |
| `net.host.connection.subtype` | string | This describes more details regarding the connection.type. It may be the type of cell connection, but it could be used for describing details about a wifi connection. | `4G` | No |
| `net.host.carrier.name` | string | host.carrier.name | `sprint` | No |
| `net.host.carrier.mcc` | string | host.carrier.mcc | `310` | No |
| `net.host.carrier.mnc` | string | host.carrier.mnc | `001` | No |
| `net.host.carrier.icc` | string | host.carrier.icc | `DE` | 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` | No |
| `net.peer.port` | int | Remote port number. | `80`; `8080`; `443` | No |
| `net.peer.name` | string | Remote hostname or similar, see note below. | `example.com` | No |
| `net.host.ip` | string | Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. | `192.168.0.1` | No |
| `net.host.port` | int | Like `net.peer.port` but for the host port. | `35555` | No |
| `net.host.name` | string | Local hostname or similar, see note below. | `localhost` | No |

`net.transport` MUST be one of the following:

| Value | Description |
|---|---|
| `IP.TCP` | IP.TCP |
| `IP.UDP` | IP.UDP |
| `IP` | Another IP-based protocol |
| `Unix` | Unix Domain socket. See below. |
| `pipe` | Named or anonymous pipe. See note below. |
| `inproc` | In-process communication. [1] |
| `other` | Something else (non IP-based). |

**[1]:** Signals that there is only in-process communication not using a "real" network protocol in cases where network attributes would normally be expected. Usually all other network attributes can be left out in that case.

`net.host.connection.type` MUST be one of the following or, if none of the listed values apply, a custom value:

| Value | Description |
|---|---|
| `wifi` | wifi |
| `wired` | wired |
| `cell` | cell |
| `unavailable` | unavailable |

`net.host.connection.subtype` MUST be one of the following or, if none of the listed values apply, a custom value:

| Value | Description |
|---|---|
| `1G` | 1G
|
| `2G` | 2G
|
| `3G` | 3G
|
| `4G` | 4G
|
| `5G` | 5G
|
<!-- endsemconv -->


Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
groups:
- id: network
prefix: net
type: span
brief: >
These attributes may be used for any network related operation.
attributes:
- id: transport
type:
allow_custom_values: false
members:
- id: IP.TCP
value: "IP.TCP"
- id: IP.UDP
value: "IP.UDP"
- id: IP
value: "IP"
brief: 'Another IP-based protocol'
- id: Unix
value: "Unix"
brief: 'Unix Domain socket. See below.'
- id: pipe
value: "pipe"
brief: 'Named or anonymous pipe. See note below.'
- id: inproc
value: "inproc"
brief: 'In-process communication.'
note: >
Signals that there is only in-process communication not using a "real" network protocol
in cases where network attributes would normally be expected. Usually all other network
attributes can be left out in that case.
- id: other
value: "other"
brief: 'Something else (non IP-based).'
brief: >
Transport protocol used. See note below.
examples: 'IP.TCP'
- id: host.connection.type
type:
allow_custom_values: true
members:
- id: wifi
value: "wifi"
- id: wired
value: "wired"
- id: cell
value: "cell"
- id: unavailable
value: "unavailable"
brief: 'unavailable'
examples: 'wifi'
- id: host.connection.subtype
type:
allow_custom_values: true
members:
- id: 1G
value: "1G"
brief: >
1G
- id: 2G
value: "2G"
brief: >
2G
- id: 3G
value: "3G"
brief: >
3G
- id: 4G
value: "4G"
brief: >
4G
- id: 5G
value: "5G"
brief: >
5G
brief: 'This describes more details regarding the connection.type. It may be the type of cell connection, but it could be used for describing details about a wifi connection.'
examples: '4G'
- id: host.carrier.name
type: string
brief: "host.carrier.name"
examples: "sprint"
- id: host.carrier.mcc
type: string
brief: "host.carrier.mcc"
examples: "310"
- id: host.carrier.mnc
type: string
brief: "host.carrier.mnc"
examples: "001"
- id: host.carrier.icc
type: string
brief: "host.carrier.icc"
examples: "DE"
- id: peer.ip
type: string
brief: >
Remote address of the peer (dotted decimal for IPv4 or
[RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6)
examples: '127.0.0.1'
- id: peer.port
type: int
brief: 'Remote port number.'
examples: [80, 8080, 443]
- id: peer.name
type: string
brief: 'Remote hostname or similar, see note below.'
examples: 'example.com'
- id: host.ip
type: string
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: int
brief: 'Like `net.peer.port` but for the host port.'
examples: 35555
- id: host.name
type: string
brief: 'Local hostname or similar, see note below.'
examples: 'localhost'
- id: identity
type: span
prefix: enduser
brief: >
These attributes may be used for any operation with an authenticated and/or authorized enduser.
attributes:
- id: id
type: string
brief: >
Username or client_id extracted from the access token or Authorization header
in the inbound request from outside the system.
examples: 'username'
- id: role
type: string
brief: 'Actual/assumed role the client is making the request under extracted from token or application security context.'
examples: 'admin'
- id: scope
type: string
brief: >
Scopes or granted authorities the client currently possesses extracted from token
or application security context. The value would come from the scope associated
with an OAuth 2.0 Access Token or an attribute value in a SAML 2.0 Assertion.
examples: 'read:message, write:files'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Common Attributes

<!-- Re-generate TOC with `TODO: ADD cmd` -->
<!-- semconv network -->
<!-- endsemconv -->


17 changes: 17 additions & 0 deletions semantic-conventions/src/tests/semconv/templating/test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,23 @@ def testMultiple(self):
expected,
)

def testMultipleEnum(self):
semconv = SemanticConventionSet(debug=False)
semconv.parse(self.load_file("markdown/multiple_enum/general.yaml"))
semconv.finish()
self.assertEqual(len(semconv.models), 2)
with open(self.load_file("markdown/multiple_enum/input.md"), "r") as markdown:
content = markdown.read()
with open(self.load_file("markdown/multiple_enum/expected.md"), "r") as markdown:
expected = markdown.read()
self.check_render(
semconv,
"markdown/multiple_enum/",
"markdown/multiple_enum/input.md",
content,
expected,
)

def testEnumInt(self):
semconv = SemanticConventionSet(debug=False)
semconv.parse(self.load_file("markdown/enum_int/rpc.yaml"))
Expand Down

0 comments on commit c7067fa

Please sign in to comment.