Skip to content

Commit

Permalink
Render notes on metric semconv tables (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopgrassi committed Jun 2, 2023
1 parent 6a8b919 commit 76cfefa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,14 @@ def to_markdown_metric_table(
"| Name | Instrument Type | Unit (UCUM) | Description |\n"
"| -------- | --------------- | ----------- | -------------- |\n"
)

description = semconv.brief
if semconv.note:
self.render_ctx.add_note(semconv.note)
description += f" [{len(self.render_ctx.notes)}]"

output.write(
f"| `{semconv.metric_name}` | {instrument} | `{semconv.unit}` | {semconv.brief} |\n"
f"| `{semconv.metric_name}` | {instrument} | `{semconv.unit}` | {description} |\n"
)
self.to_markdown_notes(output)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<!-- semconv metric.foo.size(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description |
| -------- | --------------- | ----------- | -------------- |
| `foo.size` | Histogram | `{bars}` | Measures the size of foo. |
| `foo.size` | Histogram | `{bars}` | Measures the size of foo. [1] |

**[1]:** Some notes on metric.foo.size
<!-- endsemconv -->

**Attributes for `foo.size`**
Expand All @@ -26,6 +28,8 @@
<!-- semconv metric.foo.active_eggs -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| `bar.egg.type` | string | Type of egg. | `chicken`; `emu`; `dragon` | Conditionally Required: if available to instrumentation. |
| `bar.egg.type` | string | Type of egg. [1] | `chicken`; `emu`; `dragon` | Conditionally Required: if available to instrumentation. |
| `http.method` | string | HTTP request method. | `GET`; `POST`; `HEAD` | Opt-In |

**[1]:** Some notes on attribute
<!-- endsemconv -->
4 changes: 4 additions & 0 deletions semantic-conventions/src/tests/data/yaml/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ groups:
type: string
brief: 'Type of egg.'
examples: ["chicken", "emu", "dragon"]
note: >
Some notes on attribute
- id: metric.foo.size
prefix: foo
Expand All @@ -18,6 +20,8 @@ groups:
brief: "Measures the size of foo."
instrument: histogram
unit: "{bars}"
note: >
Some notes on metric.foo.size
attributes:
- ref: http.method
requirement_level: required
Expand Down

0 comments on commit 76cfefa

Please sign in to comment.