Skip to content

Commit ab96615

Browse files
authored
[chore] Use group name for generating snippets (#1049)
1 parent 6f39cae commit ab96615

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

templates/registry/markdown/attribute_macros.j2

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
{% macro name(attribute) %}{%- if attribute.type is startingwith("template[") %}`{{ attribute.name }}.<key>`
1616
{%- else %}`{{ attribute.name }}`{%- endif %}{% endmacro %}
1717

18-
{% macro name_with_link(attribute, attribute_registry_base_url) %}[{{name(attribute)}}]({{attribute_registry_base_url}}/{{ attribute.name | split_id | list | first | kebab_case }}.md){% endmacro %}
18+
{% macro find_lineage(attr_id, lineage) %}{% if attr_id in lineage %}{{lineage[attr_id].source_group}}{% endif %}{% endmacro %}
19+
20+
{% macro name_with_link(attribute, attribute_registry_base_url, lineage_attributes) %}[{{name(attribute)}}]({{attribute_registry_base_url}}/{{ find_lineage(attribute.name, lineage_attributes) | split_id | list | reject("eq", "registry")| first | kebab_case }}.md){% endmacro %}
1921

2022
{% macro examples(attribute) %}{%- if attribute.examples %}
2123
{%- if attribute.examples is sequence %}

templates/registry/markdown/attribute_table.j2

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
{% import 'enum_macros.j2' as enums %}
66
{% import 'sampling_macros.j2' as sampling %}
77
{#- Macro for creating attribute table -#}
8-
{% macro generate(attributes, tag_filter, attribute_registry_base_url) %}{% if (tag_filter | length == 0) %}{% set filtered_attributes = attributes %}{% else %}{% set filtered_attributes = attributes | selectattr("tag", "in", tag_filter) %}{% endif %}{% if filtered_attributes | length > 0 %}| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
8+
{% macro generate(attributes, tag_filter, attribute_registry_base_url, lineage_attributes) %}{% if (tag_filter | length == 0) %}{% set filtered_attributes = attributes %}{% else %}{% set filtered_attributes = attributes | selectattr("tag", "in", tag_filter) %}{% endif %}{% if filtered_attributes | length > 0 %}| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
99
|---|---|---|---|---|---|
10-
{% for attribute in filtered_attributes | attribute_sort %}| {{ attrs.name_with_link(attribute, attribute_registry_base_url) }} | {{ attrs.type(attribute) }} | {{ attribute.brief | trim }}{{ notes.add(attribute.note) }} | {{ attrs.examples(attribute) | trim }} | {{ requirement.render(attribute.requirement_level, notes) | trim }} | {{ stability.badge(attribute.stability, attribute.deprecated) | trim }} |
11-
{% endfor %}{{ notes.render() }}{{ sampling.snippet(filtered_attributes, attribute_registry_base_url) }}{{ enums.tables(filtered_attributes | selectattr("type", "mapping"), notes) }}
10+
{% for attribute in filtered_attributes | attribute_sort %}| {{ attrs.name_with_link(attribute, attribute_registry_base_url, lineage_attributes) }} | {{ attrs.type(attribute) }} | {{ attribute.brief | trim }}{{ notes.add(attribute.note) }} | {{ attrs.examples(attribute) | trim }} | {{ requirement.render(attribute.requirement_level, notes) | trim }} | {{ stability.badge(attribute.stability, attribute.deprecated) | trim }} |
11+
{% endfor %}{{ notes.render() }}{{ sampling.snippet(filtered_attributes, attribute_registry_base_url, lineage_attributes) }}{{ enums.tables(filtered_attributes | selectattr("type", "mapping"), notes) }}
1212
{% endif %}{% endmacro %}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% import 'attribute_macros.j2' as attrs %}
2-
{% macro snippet(attributes, attribute_registry_base_url) %}{% set sampling_attributes = attributes | selectattr("sampling_relevant", "true") %}{% if sampling_attributes | length > 0 %}
2+
{% macro snippet(attributes, attribute_registry_base_url, lineage_attributes) %}{% set sampling_attributes = attributes | selectattr("sampling_relevant", "true") %}{% if sampling_attributes | length > 0 %}
33
The following attributes can be important for making sampling decisions
44
and SHOULD be provided **at span creation time** (if provided at all):
55

6-
{% for attribute in sampling_attributes | sort(attribute="name") %}* {{ attrs.name_with_link(attribute, attribute_registry_base_url) }}
6+
{% for attribute in sampling_attributes | sort(attribute="name") %}* {{ attrs.name_with_link(attribute, attribute_registry_base_url, lineage_attributes) }}
77
{% endfor %}{% endif %}{% endmacro %}

templates/registry/markdown/snippet.md.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<!-- markdownlint-capture -->
55
<!-- markdownlint-disable -->
66
{% import 'attribute_table.j2' as at %}{% import 'metric_table.j2' as mt %}{% import 'event_macros.j2' as event %}
7-
{% if snippet_type == "metric_table" %}{{ mt.generate(group) }}{% else %}{% if group.type == "event" %}{{ event.header(group) }}{% endif %}{{ at.generate(group.attributes, tag_filter, attribute_registry_base_url) }}{% endif %}
7+
{% if snippet_type == "metric_table" %}{{ mt.generate(group) }}{% else %}{% if group.type == "event" %}{{ event.header(group) }}{% endif %}{{ at.generate(group.attributes, tag_filter, attribute_registry_base_url, group.lineage.attributes) }}{% endif %}
88
<!-- markdownlint-restore -->
99
<!-- prettier-ignore-end -->
1010
<!-- END AUTOGENERATED TEXT -->

0 commit comments

Comments
 (0)