diff --git a/semantic-conventions/semconv.schema.json b/semantic-conventions/semconv.schema.json index a22365c8..b0f61ce5 100644 --- a/semantic-conventions/semconv.schema.json +++ b/semantic-conventions/semconv.schema.json @@ -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 } } }, diff --git a/semantic-conventions/src/opentelemetry/semconv/model/semantic_attribute.py b/semantic-conventions/src/opentelemetry/semconv/model/semantic_attribute.py index 233e2e64..5c4afa9b 100644 --- a/semantic-conventions/src/opentelemetry/semconv/model/semantic_attribute.py +++ b/semantic-conventions/src/opentelemetry/semconv/model/semantic_attribute.py @@ -100,6 +100,7 @@ def parse( "requirement_level", "sampling_relevant", "note", + "prefix", ) if not yaml_attributes: return attributes @@ -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, diff --git a/semantic-conventions/src/tests/data/markdown/ref_embed/expected.md b/semantic-conventions/src/tests/data/markdown/ref_embed/expected.md new file mode 100644 index 00000000..b96e69e9 --- /dev/null +++ b/semantic-conventions/src/tests/data/markdown/ref_embed/expected.md @@ -0,0 +1,17 @@ +# Server + + +| 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 | + + + + +| 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 | + diff --git a/semantic-conventions/src/tests/data/markdown/ref_embed/geo.yaml b/semantic-conventions/src/tests/data/markdown/ref_embed/geo.yaml new file mode 100644 index 00000000..51693c48 --- /dev/null +++ b/semantic-conventions/src/tests/data/markdown/ref_embed/geo.yaml @@ -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" ] diff --git a/semantic-conventions/src/tests/data/markdown/ref_embed/input.md b/semantic-conventions/src/tests/data/markdown/ref_embed/input.md new file mode 100644 index 00000000..c5deb310 --- /dev/null +++ b/semantic-conventions/src/tests/data/markdown/ref_embed/input.md @@ -0,0 +1,8 @@ +# Server + + + + + + + diff --git a/semantic-conventions/src/tests/data/markdown/ref_embed/server.yaml b/semantic-conventions/src/tests/data/markdown/ref_embed/server.yaml new file mode 100644 index 00000000..0924d97f --- /dev/null +++ b/semantic-conventions/src/tests/data/markdown/ref_embed/server.yaml @@ -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 diff --git a/semantic-conventions/src/tests/semconv/templating/test_markdown.py b/semantic-conventions/src/tests/semconv/templating/test_markdown.py index 5d006535..c93ae706 100644 --- a/semantic-conventions/src/tests/semconv/templating/test_markdown.py +++ b/semantic-conventions/src/tests/semconv/templating/test_markdown.py @@ -31,6 +31,9 @@ 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/")