1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-12 10:04:29 +02:00
opentelemetry-go/semconv/template.j2
Anthony Mirabella 23cb939611
Remove internal/semconv-gen (#2155)
* Removed internal semconvgen

* fix Makefile and update releasing docs

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

Co-authored-by: Eddy Lin <elindy26@gmail.com>
2021-08-02 14:39:18 -04:00

81 lines
2.5 KiB
Django/Jinja

{%- macro to_go_attr_type(type, val) -%}
{%- if type == "string" -%}
String("{{val}}")
{%- elif type == "int" -%}
Int({{val}})
{%- endif -%}
{%- endmacro -%}
{%- macro to_go_name(fqn) -%}
{{fqn | replace(".", " ") | replace("_", " ") | title | replace(" ", "")}}
{%- endmacro -%}
{%- macro godoc(attr) -%}
{{ attr.brief }}
//
{%- if attr.attr_type is string %}
Type: {{ attr.attr_type }}
{%- else %}
Type: Enum
{%- endif %}
{%- if attr.required == Required.ALWAYS %}
Required: Always
{%- elif attr.required == Required.CONDITIONAL %}
Required: {{ attr.required_msg }}
{%- else %}
Required: No
{%- endif %}
{{ attr.stability | replace("Level.", ": ") | capitalize }}
{%- if attr.deprecated != None %}
Deprecated: {{ attr.deprecated }}
{%- endif %}
{%- if attr.examples is iterable %}
Examples: {{ attr.examples | pprint | trim("[]") }}
{%- endif %}
{%- if attr.note %}
Note: {{ attr.note }}
{%- endif %}
{%- endmacro -%}
// 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.
// Code generated from semantic convention specification. DO NOT EDIT.
package semconv // import [[IMPORTPATH]]
import "go.opentelemetry.io/otel/attribute"
{% for semconv in semconvs -%}
{%- if semconvs[semconv].attributes | rejectattr("ref") | selectattr("is_local") | sort(attribute=fqn) | length > 0 -%}
// {{ semconvs[semconv].brief }}
const (
{% for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref -%}
// {{ godoc(attr) | wordwrap | indent(3) | replace(" ", "\t// ") | replace("// //", "//") }}
{{to_go_name(attr.fqn)}}Key = attribute.Key("{{attr.fqn}}")
{% endfor %}
)
{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref -%}
{%- if attr.attr_type is not string %}
var (
{%- for val in attr.attr_type.members %}
// {{ val.brief | to_doc_brief }}
{{to_go_name("{}.{}".format(attr.fqn, val.member_id))}} = {{to_go_name(attr.fqn)}}Key.{{to_go_attr_type(attr.attr_type.enum_type, val.value)}}
{%- endfor %}
)
{%- endif -%}
{%- endfor %}
{% endif %}
{% endfor -%}