Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova committed Jul 30, 2024
1 parent 8ccb8c3 commit 03d7995
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
DNS_QUESTION_NAME: Final = "dns.question.name"
"""
The name being queried.
Note: If the name field contains non-printable characters (below 32 or above 126), those characters should be represented as escaped base 10 integers (\DDD). Back slashes and quotes should be escaped. Tabs, carriage returns, and line feeds should be converted to \t, \r, and \n respectively.
Note: If the name field contains non-printable characters (below 32 or above 126), those characters should be represented as escaped base 10 integers (\\DDD). Back slashes and quotes should be escaped. Tabs, carriage returns, and line feeds should be converted to \\t, \\r, and \\n respectively.
"""
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
"""

# MESSAGING_CLIENT_ID : Final = "messaging.client_id"
"""
Deprecated: Replaced by `messaging.client.id`.
"""
# Deprecated: Replaced by `messaging.client.id`.

MESSAGING_DESTINATION_ANONYMOUS: Final = "messaging.destination.anonymous"
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def create_system_disk_io(meter: Meter) -> Counter:
- Linux: Field 13 from [procfs-diskstats](https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats)
- Windows: The complement of
["Disk\% Idle Time"](https://learn.microsoft.com/archive/blogs/askcore/windows-performance-monitor-disk-counters-explained#windows-performance-monitor-disk-counters-explained)
performance counter: `uptime * (100 - "Disk\% Idle Time") / 100`.
["Disk\\% Idle Time"](https://learn.microsoft.com/archive/blogs/askcore/windows-performance-monitor-disk-counters-explained#windows-performance-monitor-disk-counters-explained)
performance counter: `uptime * (100 - "Disk\\% Idle Time") / 100`.
"""


Expand Down
2 changes: 1 addition & 1 deletion scripts/semconv/templates/registry/common.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{%- endmacro -%}

{%- macro comment_with_prefix(str, prefix) -%}
{{remove_trailing_dots(str | trim(' \n')) | comment_with_prefix(prefix)}}
{{remove_trailing_dots(str | trim(' \n')) | comment_with_prefix(prefix) | replace("\\", "\\\\")}}
{%- endmacro %}

{%- macro import_deprecated(semconv) -%}
Expand Down
27 changes: 14 additions & 13 deletions scripts/semconv/templates/registry/semantic_attributes.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,37 @@ from typing import Final
{{c.import_deprecated(enum_attributes)}}

{%- macro attribute_name(attribute) -%}
{{c.to_const_name(attribute.name)}}{%- if "template" in attribute.type -%}_TEMPLATE{%- endif -%}
{{c.to_const_name(attribute.name)}}{%- if attribute.type is template_type -%}_TEMPLATE{%- endif -%}
{%- endmacro -%}

{%- macro stable_class_ref(const_name, separator) -%}
{{ctx.stable_package_name}}.{{ctx.root_namespace}}_attributes{{separator}}{{const_name}}
{%- endmacro %}

{%- macro write_docstring(name, brief, note, deprecated, stability, prefix) -%}
{%- macro write_docstring(name, brief, note, deprecated, stability, multiline) -%}
{%- if multiline %}"""
{% endif %}
{%- if c.str_or_empty(deprecated)|length -%}
{{prefix}}Deprecated: {{c.comment_with_prefix(deprecated, prefix)}}.
{{prefix}}Deprecated: {{c.comment_with_prefix(deprecated, "")}}.
{%- elif ctx.filter == "any" and stability == "stable" -%}
{{prefix}}Deprecated in favor of stable :py:const:`{{stable_class_ref(name, '.')}}`.
{%- elif c.str_or_empty(brief)|length -%}
{{prefix}}{{c.comment_with_prefix(brief, prefix)}}.
{{prefix}}{{c.comment_with_prefix(brief, "")}}.
{%- if c.str_or_empty(note)|length %}
{{prefix}}Note: {{c.comment_with_prefix(note, prefix)}}.
{{prefix}}Note: {{c.comment_with_prefix(note, "")}}.
{%- endif -%}
{%- endif -%}
{%- if multiline %}
"""{%- endif %}
{%- endmacro -%}

{% for attribute in attributes %}
{% set attr_name = attribute_name(attribute) %}
{%- set prefix = "# " if attribute.name in ctx.excluded_attributes else "" -%}
{%- set doc_string=write_docstring(attr_name, attribute.brief, attribute.note, attribute.deprecated, attribute.stability, "")-%}
{%- set multiline = attribute.name not in ctx.excluded_attributes -%}
{%- set doc_string = write_docstring(attr_name, attribute.brief, attribute.note, attribute.deprecated, attribute.stability, multiline)-%}
{%- set prefix = "" if multiline else "# " -%}
{{prefix}}{{attr_name}} : Final = "{{attribute.name}}"
{%- if doc_string %}
"""
{{doc_string}}
"""
{%- endif %}
{{prefix}}{{doc_string}}
{% endfor %}

{% for attribute in enum_attributes %}{%- set class_name = attribute.name | pascal_case ~ "Values" -%}
Expand All @@ -65,7 +66,7 @@ from typing import Final
class {{class_name}}(Enum):
{%- for member in attribute.type.members %}
{% set member_name = c.to_const_name(member.id) -%}
{%- set doc_string=write_docstring(class_name + '.' + member_name, member.brief or member.id, "", member.deprecated, member.stability, "")-%}
{%- set doc_string=write_docstring(class_name + '.' + member_name, member.brief or member.id, "", member.deprecated, member.stability, false)-%}
{{member_name}} = {{c.print_value(attribute.type | instantiated_type, member.value) }}
{% if doc_string %}"""{{doc_string}}"""{% endif %}
{%- endfor %}
Expand Down

0 comments on commit 03d7995

Please sign in to comment.