Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(semantic-conventions): bump weaver; use comment filter rather than deprecated comment_with_prefix #5100

Merged
merged 6 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/semconv/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ROOT_DIR="${SCRIPT_DIR}/../../"

# freeze the spec version to make SpanAttributess generation reproducible
SPEC_VERSION=v1.27.0
GENERATOR_VERSION=0.8.0
GENERATOR_VERSION=v0.10.0

# When running on windows and your are getting references to ";C" (like Telemetry;C)
# then this is an issue with the bash shell, so first run the following in your shell:
Expand Down
53 changes: 33 additions & 20 deletions scripts/semconv/templates/registry/stable/docstring.ts.j2
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
{% macro strong_reqs(string) -%}{{ string | replace(" MUST ", " **MUST** ") | replace(" MUST NOT ", " **MUST NOT** ") | replace(" SHOULD ", " **SHOULD** ") | replace(" SHOULD NOT ", " **SHOULD NOT** ") | replace(" MAY ", " **MAY** ") | replace(" NOT ", " **NOT** ") }}{% endmacro -%}
{% macro strong_rfc2119(string) -%}{{ string | regex_replace("\\b(MUST NOT|MUST|REQUIRED|SHALL NOT|SHALL|SHOULD NOT|SHOULD|RECOMMENDED|MAY|OPTIONAL)\\b", "**$1**") }}{% endmacro -%}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I support the strong_rfc2119 renaming. More clear what's actually going on.

{% macro docstring(obj, type="value") -%}/**
{{ strong_reqs(obj.brief | comment_with_prefix(" * ")) }}
{% if obj.examples is sequence %}{% for example in obj.examples %}
*
* @example {{ example }}
{% endfor %}{%elif obj.examples%}
*
* @example {{ obj.examples | print_member_value }}
{% endif %}{% if obj.note %}
*
{{ ("@note " ~ strong_reqs(obj.note)) | comment_with_prefix(" * ") }}
{% endif %}{% if (obj.stability) != "stable" %}
*
* @experimental This {{type}} is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
{% endif %}{% if obj.deprecated %}
*
* @deprecated {{ strong_reqs(obj.deprecated) | comment_with_prefix(" * ") }}
{% endif %}
*/{% endmacro -%}
{% macro docstring(obj, type="value") -%}
{%- set examples_jsdoc %}
{% if obj.examples is sequence %}
{% for example in obj.examples %}
@example {{ example }}
{% endfor %}
{% elif obj.examples %}
@example {{ obj.examples | print_member_value }}
{% endif %}
{% endset -%}

{%- if obj.note %}
{% set note_jsdoc = "@note " ~ strong_rfc2119(obj.note) %}
{% endif -%}

{%- if obj.stability != "stable" %}
{% set stability_jsdoc = "@experimental This " ~ type ~ " is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`." %}
{% endif -%}

{%- if obj is deprecated %}
{%- set deprecated_jsdoc = "\n@deprecated " ~ strong_rfc2119(obj.deprecated) -%}
{%- endif -%}

{{ [
strong_rfc2119(obj.brief) | trim,
"\n",
examples_jsdoc,
note_jsdoc,
stability_jsdoc,
deprecated_jsdoc,
] | comment }}
{%- endmacro -%}
15 changes: 15 additions & 0 deletions scripts/semconv/templates/registry/stable/weaver.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@

params:
excluded_attributes: ["messaging.client_id"]

# https://github.com/open-telemetry/weaver/blob/main/crates/weaver_forge/README.md#comment-filter
comment_formats:
jsdoc:
format: markdown
header: '/**'
# Note: This results in trailing whitespace on empty lines. IMHO the
# 'comment' filter should handle those.
prefix: ' * '
footer: ' */'
trim: true
indent_first_level_list_items: true
escape_backslashes: true
default_comment_format: jsdoc

templates:
- pattern: attributes.ts.j2
# Remove file name prefix when per-pattern params are available https://github.com/open-telemetry/weaver/issues/288
Expand Down
2 changes: 2 additions & 0 deletions semantic-conventions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ All notable changes to the semantic-conventions package will be documented in th

### :house: (Internal)

* chore: Minor improvements to formatting of comments. [#5100](https://github.com/open-telemetry/opentelemetry-js/pull/5100) @trentm

## 1.27.0

* Version bump only
Expand Down
Loading
Loading