/* * Copyright The OpenTelemetry Authors * SPDX-License-Identifier: Apache-2.0 */ {%- macro to_java_return_type(type) -%} {%- if type == "string" -%} String {%- elif type == "string[]" -%} List {%- elif type == "boolean" -%} boolean {%- elif type == "int" -%} long {%- elif type == "double" -%} double {%- else -%} {{type}} {%- endif -%} {%- endmacro %} {%- macro to_java_key_type(type) -%} {%- if type == "string" -%} stringKey {%- elif type == "string[]" -%} stringArrayKey {%- elif type == "boolean" -%} booleanKey {%- elif type == "int" -%} longKey {%- elif type == "double" -%} doubleKey {%- else -%} {{lowerFirst(type)}}Key {%- endif -%} {%- endmacro %} {%- macro print_value(type, value) -%} {{ "\"" if type == "String"}}{{value}}{{ "\"" if type == "String"}} {%- endmacro %} {%- macro upFirst(text) -%} {{ text[0]|upper}}{{text[1:] }} {%- endmacro %} {%- macro lowerFirst(text) -%} {{ text[0]|lower}}{{text[1:] }} {%- endmacro %} package {{pkg | trim}}; import static io.opentelemetry.api.common.AttributeKey.booleanKey; import static io.opentelemetry.api.common.AttributeKey.doubleKey; import static io.opentelemetry.api.common.AttributeKey.longKey; import static io.opentelemetry.api.common.AttributeKey.stringKey; import static io.opentelemetry.api.common.AttributeKey.stringArrayKey; import io.opentelemetry.api.common.AttributeKey; import java.util.List; // DO NOT EDIT, this is an Auto-generated file from buildscripts/semantic-convention{{template}} public final class {{class}} { /** * The URL of the OpenTelemetry schema for these keys and values. */ public static final String SCHEMA_URL = "{{schemaUrl}}"; {%- for attribute in attributes if attribute.is_local and not attribute.ref %} /** * {{attribute.brief | render_markdown(code="{{@code {0}}}", paragraph="{0}")}} {%- if attribute.note %} * *

Notes:

{%- endif %} {%- if attribute.deprecated %} * * @deprecated {{attribute.deprecated | to_doc_brief}}. {%- endif %} */ {%- if attribute.deprecated %} @Deprecated {%- endif %} public static final AttributeKey<{{upFirst(to_java_return_type(attribute.attr_type | string))}}> {{attribute.fqn | to_const_name}} = {{to_java_key_type(attribute.attr_type | string)}}("{{attribute.fqn}}"); {%- endfor %} // Enum definitions {%- for attribute in attributes if attribute.is_local and not attribute.ref %} {%- if attribute.is_enum %} {%- set class_name = attribute.fqn | to_camelcase(True) ~ "Values" %} {%- set type = to_java_return_type(attribute.attr_type.enum_type) %} public static final class {{class_name}} { {%- for member in attribute.attr_type.members %} /** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */ public static final {{ type }} {{ member.member_id | to_const_name }} = {{ print_value(type, member.value) }}; {%- endfor %} private {{ class_name }}() {} } {% endif %} {%- endfor %} {%- if class == "SemanticAttributes" %} // Manually defined and not YET in the YAML /** * The name of an event describing an exception. * *

Typically an event with that name should not be manually created. Instead {@link * io.opentelemetry.api.trace.Span#recordException(Throwable)} should be used. */ public static final String EXCEPTION_EVENT_NAME = "exception"; {% endif %} private {{class}}() {} }