blob: a91e8a554c411ce5b743c6cb1e3fd9e655985970 [file] [edit]
{%- 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 | render_markdown(paragraph="{0}", code="{0}", link="{1}", emphasis="{0}", strong="{0}") }}
//
{%- if attr.attr_type is string %}
Type: {{ attr.attr_type }}
{%- else %}
Type: Enum
{%- endif %}
{%- if attr.requirement_level == RequirementLevel.REQUIRED %}
Requirement Level: Required
{%- elif attr.requirement_level == RequirementLevel.CONDITIONALLY_REQUIRED %}
Requirement Level: Conditionally Required{% if attr.requirement_level_msg != "" %} - {{ attr.requirement_level_msg }} {% endif %}
{%- elif attr.requirement_level == RequirementLevel.RECOMMENDED %}
Requirement Level: Recommended{% if attr.requirement_level_msg != "" %} - {{ attr.requirement_level_msg }} {% endif %}
{%- else %}
Requirement Level: Optional
{%- 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 | render_markdown(paragraph="{0}", code="{0}", link="{1}", emphasis="{0}", strong="{0}") }}
{%- endif %}
{%- endmacro -%}
{%- macro sentence_case(text) -%}
{{ text[0]|upper}}{{text[1:] }}
{%- endmacro -%}
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
// Code generated from semantic convention specification. DO NOT EDIT.
package semconv
{% for semconv in semconvs -%}
{%- if semconvs[semconv].attributes | rejectattr("ref") | selectattr("is_local") | sort(attribute=fqn) | length > 0 -%}
// {{ sentence_case(semconvs[semconv].brief | replace("This document defines ", "")) | wordwrap(76, break_long_words=false, break_on_hyphens=false, wrapstring="\n// ") }}
const (
{% for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref -%}
// {{ godoc(attr) | wordwrap | indent(3) | replace(" ", "\t// ") | replace("// //", "//") }}
Attribute{{to_go_name(attr.fqn)}} = "{{attr.fqn}}"
{% endfor %}
)
{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref -%}
{%- if attr.attr_type is not string %}
const (
{%- for val in attr.attr_type.members %}
// {{ val.brief | to_doc_brief }}
Attribute{{to_go_name("{}.{}".format(attr.fqn, val.member_id))}} = "{{val.value}}"
{%- endfor %}
)
{%- endif -%}
{%- endfor %}
{% endif %}
{% endfor -%}
func Get{{ conventionType | title }}SemanticConventionAttributeNames() []string {
return []string{
{% for semconv in semconvs -%}
{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref -%}
Attribute{{to_go_name(attr.fqn)}},
{% endfor %}
{%- endfor %}
}
}