Skip to content

Commit

Permalink
update build tools to support embedding of attribute implemented in w…
Browse files Browse the repository at this point in the history
…eaver
  • Loading branch information
trisch-me committed Jul 3, 2024
1 parent ffcffc7 commit 8633572
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 1 deletion.
5 changes: 5 additions & 0 deletions semantic-conventions/semconv.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@
"tag": {
"type": "string",
"description": "associates a tag to the attribute"
},
"prefix": {
"type": "boolean",
"description": "specifies if it is embedded attribute from other namespace. It defaults to false.",
"default": false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def parse(
"requirement_level",
"sampling_relevant",
"note",
"prefix",
)
if not yaml_attributes:
return attributes
Expand Down Expand Up @@ -136,8 +137,12 @@ def parse(
validation_ctx.raise_or_warn(position, msg, ref)
brief = attribute.get("brief")
examples = attribute.get("examples")
ref_prefix = attribute.get("prefix", False)
ref = ref.strip()
fqn = ref
if ref_prefix:
fqn = f"{prefix}.{ref}"
else:
fqn = ref

required_value_map = {
"required": RequirementLevel.REQUIRED,
Expand Down
17 changes: 17 additions & 0 deletions semantic-conventions/src/tests/data/markdown/ref_embed/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Server

<!-- semconv registry.geo(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `geo.country` | string | country of the geo coordinates. | `US` | `Recommended` | Experimental |
| `geo.lat` | string | latitude of the geo coordinates. | `123.456` | `Recommended` | Experimental |
| `geo.lon` | string | longitude of the geo coordinates. | `234.456` | `Recommended` | Experimental |
<!-- endsemconv -->


<!-- semconv registry.server(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `server.geo.lat` | string | My own latitude | `123.456` | `Recommended` | Experimental |
| `server.id` | string | some server id | `123` | `Recommended` | Experimental |
<!-- endsemconv -->
24 changes: 24 additions & 0 deletions semantic-conventions/src/tests/data/markdown/ref_embed/geo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
groups:
- id: registry.geo
brief: Attributes describing geo.
type: attribute_group
prefix: geo
attributes:
- id: lat
type: string
stability: experimental
brief: >
latitude of the geo coordinates.
examples: ["123.456"]
- id: lon
type: string
stability: experimental
brief: >
longitude of the geo coordinates.
examples: [ "234.456" ]
- id: country
type: string
stability: experimental
brief: >
country of the geo coordinates.
examples: [ "US" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Server

<!-- semconv registry.geo(full) -->
<!-- endsemconv -->


<!-- semconv registry.server(full) -->
<!-- endsemconv -->
15 changes: 15 additions & 0 deletions semantic-conventions/src/tests/data/markdown/ref_embed/server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
groups:
- id: registry.server
prefix: server
type: attribute_group
brief: "Describes information about the server."
attributes:
- id: id
type: string
stability: experimental
brief: >
some server id
examples: ['123']
- ref: geo.lat
prefix: true
brief: My own latitude
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def testRef(self):
def testRefExtends(self):
self.check("markdown/ref_extends/")

def testRefEmbed(self):
self.check("markdown/ref_embed/")


def testDeprecated(self):
self.check("markdown/deprecated/")

Expand Down

0 comments on commit 8633572

Please sign in to comment.