-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use weaver to generate semconv (#1398)
update semconv generation to use the new tooling. This is fairly close to a 1:1 of what we have now, although I noted a couple of TODOs which we might consider in future to align with what Java is doing: split attribute up into file-per-type, and split stable/unstable.
- Loading branch information
Showing
18 changed files
with
1,359 additions
and
2,633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
script/semantic-conventions/templates/AttributeValues.php.j2
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version.txt |
30 changes: 30 additions & 0 deletions
30
script/semantic-conventions/templates/registry/php/AttributeValues.php.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% import 'common.j2' as c %} | ||
<?php | ||
|
||
// DO NOT EDIT, this is an Auto-generated file from script/semantic-conventions/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\SemConv; | ||
|
||
interface TraceAttributeValues | ||
{ | ||
/** | ||
* The URL of the OpenTelemetry schema for these values. | ||
*/ | ||
public const SCHEMA_URL = '{% include "version.txt" without context %}'; | ||
{% for section in ctx %} | ||
{% for attribute in section.attributes %} | ||
{% if "members" in attribute.type and attribute.type.members | length > 0 %} | ||
{% for member in attribute.type.members %} | ||
{%- set see = "@see TraceAttributes::" ~ c.attribute_name(attribute) -%} | ||
{%- set deprecated = "@deprecated " ~ member.deprecated if member.deprecated != none else "" -%} | ||
{{ [member.brief or member.id, '\n', see, deprecated] | comment(indent=4) | replace(' \n', '\n') }} | ||
public const {{ c.attribute_name(attribute) + "_" + c.attribute_value_name(member) }} = '{{ member.value }}'; | ||
|
||
{% endfor %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endfor %} | ||
} | ||
{# blank line #} |
33 changes: 33 additions & 0 deletions
33
script/semantic-conventions/templates/registry/php/Attributes.php.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% import 'common.j2' as c %} | ||
<?php | ||
|
||
// DO NOT EDIT, this is an Auto-generated file from script/semantic-conventions | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\SemConv; | ||
|
||
interface TraceAttributes | ||
{ | ||
/** | ||
* The URL of the OpenTelemetry schema for these keys and values. | ||
*/ | ||
public const SCHEMA_URL = '{% include "version.txt" without context %}'; | ||
|
||
{% for section in ctx %} | ||
{#{ debug(section) }#} | ||
{% for attribute in section.attributes %} | ||
{% if attribute.name not in section.excluded_attributes %} | ||
{%- if attribute is deprecated %} | ||
{%- set deprecated_phpdoc = "@deprecated " ~ attribute.deprecated -%} | ||
{% else %} | ||
{% set deprecated_phpdoc = "" %} | ||
{%- endif -%} | ||
{{ [attribute.brief, concat_if(attribute.note), deprecated_phpdoc] | comment(indent=4) | replace(' \n', '\n') }} | ||
public const {{ c.attribute_name(attribute) }} = '{{ attribute.name }}'; | ||
|
||
{% endif %} | ||
{% endfor %} | ||
{% endfor %} | ||
} | ||
{# blank line #} |
34 changes: 34 additions & 0 deletions
34
script/semantic-conventions/templates/registry/php/ResourceAttributeValues.php.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{% import 'common.j2' as c %} | ||
<?php | ||
|
||
// DO NOT EDIT, this is an Auto-generated file from script/semantic-conventions | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\SemConv; | ||
|
||
interface ResourceAttributeValues | ||
{ | ||
/** | ||
* The URL of the OpenTelemetry schema for these values. | ||
*/ | ||
public const SCHEMA_URL = '{% include "version.txt" without context %}'; | ||
|
||
{% for attribute in ctx %} | ||
{% if "members" in attribute.type and attribute.type.members | length > 0 %} | ||
{% for member in attribute.type.members %} | ||
/** | ||
* {{ member.brief or member.id }} | ||
* | ||
* @see ResourceAttributes::{{ c.attribute_name(attribute) }} | ||
{% if attribute.deprecated %} | ||
* @deprecated {{ attribute.deprecated }} | ||
{% endif %} | ||
*/ | ||
public const {{ c.attribute_name(attribute) + "_" + c.attribute_value_name(member) }} = '{{ member.value }}'; | ||
|
||
{% endfor %} | ||
{% endif %} | ||
{% endfor %} | ||
} | ||
{# blank line #} |
26 changes: 26 additions & 0 deletions
26
script/semantic-conventions/templates/registry/php/ResourceAttributes.php.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% import 'common.j2' as c %} | ||
<?php | ||
|
||
// DO NOT EDIT, this is an Auto-generated file from script/semantic-conventions | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\SemConv; | ||
|
||
interface ResourceAttributes | ||
{ | ||
/** | ||
* The URL of the OpenTelemetry schema for these keys and values. | ||
*/ | ||
public const SCHEMA_URL = '{% include "version.txt" without context %}'; | ||
|
||
{% for attribute in ctx %} | ||
{%- if attribute is deprecated %} | ||
{%- set deprecated_phpdoc = "@deprecated " ~ attribute.deprecated -%} | ||
{%- endif -%} | ||
{{ [attribute.brief, concat_if(attribute.note), deprecated_phpdoc] | comment(indent=4) | replace(' \n', '\n') }} | ||
public const {{ c.attribute_name(attribute) }} = '{{ attribute.name }}'; | ||
|
||
{% endfor %} | ||
} | ||
{# blank line #} |
36 changes: 36 additions & 0 deletions
36
script/semantic-conventions/templates/registry/php/common.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{%- macro file_header() -%} | ||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
{% endmacro -%} | ||
|
||
{%- macro to_const_name(attr_name) -%} | ||
{{attr_name | upper | replace('.', '_')}} | ||
{%- endmacro %} | ||
|
||
{%- macro print_value(type, value) -%} | ||
{%- if type == "string" -%}"{{value}}"{%-else-%}{{value}}{%-endif-%} | ||
{%- endmacro -%} | ||
|
||
{%- macro attribute_name(attribute) -%} | ||
{{to_const_name(attribute.name)}} | ||
{%- endmacro -%} | ||
|
||
{%- macro attribute_value_name(member) -%} | ||
{{to_const_name(member.id)}} | ||
{%- endmacro -%} | ||
|
||
{%- macro attribute_stability(attribute) -%} | ||
{% if attribute.deprecated %}deprecated{% else %}{{attribute.stability}}{%endif%} | ||
{%- endmacro -%} |
Oops, something went wrong.