-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathIncubatingSemanticAttributes.java.j2
More file actions
124 lines (114 loc) · 6.47 KB
/
IncubatingSemanticAttributes.java.j2
File metadata and controls
124 lines (114 loc) · 6.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{%- macro to_java_key_type(attribute) -%}
{%- if attribute.type is template_type -%}
{{ attribute.type | instantiated_type | map_text("java_template_key_type") }}
{%- else -%}
{{ attribute.type | instantiated_type | map_text("java_key_type") }}
{%- endif %}
{%- endmacro %}
{%- macro to_java_key_factory(attribute) -%}
{%- if attribute.type is template_type -%}
{{ attribute.type | instantiated_type | map_text("java_template_key_factory") }}
{%- else -%}
{{ attribute.type | instantiated_type | map_text("java_key_factory") }}
{%- endif %}
{%- endmacro %}
{%- set my_class_name = ctx.root_namespace | pascal_case ~ "IncubatingAttributes" -%}
{%- set stable_class_name = ctx.root_namespace | pascal_case ~ "Attributes" -%}
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.semconv.incubating;
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 static io.opentelemetry.semconv.AttributeKeyTemplate.stringArrayKeyTemplate;
import static io.opentelemetry.semconv.AttributeKeyTemplate.stringKeyTemplate;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.semconv.AttributeKeyTemplate;
import java.util.List;
// DO NOT EDIT, this is an Auto-generated file from buildscripts/templates/registry/incubating_java/IncubatingSemanticAttributes.java.j2
@SuppressWarnings("unused")
public final class {{ my_class_name }} {
{%- for attribute in ctx.attributes | rejectattr("name", "in", ctx.excluded_attributes) | rejectattr("type", "eq", "any") -%}
{%- if attribute is experimental -%}
{%- if attribute is deprecated -%}
{%- if attribute.deprecated.note == "Uncategorized." -%}
{%- set deprecated_javadoc = "@deprecated" -%}
{%- else -%}
{%- set deprecated_javadoc = "@deprecated " ~ attribute.deprecated.note -%}
{%- endif -%}
{%- else -%}
{%- set deprecated_javadoc = "" -%}
{%- endif -%}
{{ [attribute.brief, concat_if("\n\nNotes:\n\n", attribute.note), deprecated_javadoc] | comment }}
{%- if attribute is deprecated -%}
@Deprecated
{% endif %}
public static final {{ to_java_key_type(attribute) | trim }} {{ attribute.name | screaming_snake_case }} = {{ to_java_key_factory(attribute) | trim }}("{{ attribute.name }}");
{% elif attribute is stable %}
{%- set stable_class_link = "io.opentelemetry.semconv." ~ stable_class_name ~ "#" ~ (attribute.name | screaming_snake_case) -%}
{{ [attribute.brief, concat_if("\n\nNotes:\n\n", attribute.note), "@deprecated deprecated in favor of stable {@link " ~ stable_class_link ~ "} attribute."] | comment }}
@Deprecated public static final {{ to_java_key_type(attribute) | trim }} {{ attribute.name | screaming_snake_case }} = {{ to_java_key_factory(attribute) | trim }}("{{ attribute.name }}");
{% endif %}
{% endfor %}
// Enum definitions
{% for attribute in ctx.attributes | select("enum") | rejectattr("name", "in", ctx.excluded_attributes) %}
{%- set enum_deprecated_in_favor_of_stable = namespace(value=false) -%}
{%- if attribute is stable -%}
{%- set enum_deprecated_in_favor_of_stable.value = true -%}
{%- endif -%}
{%- for member in attribute.type.members %}
{% if member is experimental %}
{% if not member is deprecated %}
{%- set enum_deprecated_in_favor_of_stable.value = false -%}
{%- endif -%}
{%- endif -%}
{%- endfor %}
{%- if enum_deprecated_in_favor_of_stable.value -%}
{%- set stable_class_link = "io.opentelemetry.semconv." ~ stable_class_name ~ "." ~ (attribute.name | pascal_case) ~ "Values" -%}
/**
* Values for {@link #{{ attribute.name | screaming_snake_case }}}.
*
* @deprecated deprecated in favor of stable {@link {{stable_class_link}}}.
*/
{%- elif attribute is deprecated -%}
{%- if attribute.deprecated.note == "Uncategorized." -%}
{{ ["Values for {@link #" ~ attribute.name | screaming_snake_case ~ "}", "@deprecated"] | comment }}
{%- else -%}
{{ ["Values for {@link #" ~ attribute.name | screaming_snake_case ~ "}", "@deprecated " ~ attribute.deprecated.note ] | comment }}
{%- endif -%}
{%- else -%}
/** Values for {@link #{{ attribute.name | screaming_snake_case }}}. */
{%- endif -%}
{%- if enum_deprecated_in_favor_of_stable.value or attribute is deprecated -%}
@Deprecated
{% endif %}
public static final class {{ attribute.name | pascal_case }}IncubatingValues {
{%- for member in attribute.type.members %}
{%- if member is experimental and member is deprecated -%}
{%- if member.deprecated.note == "Uncategorized." -%}
{{ [member.brief or (member.id ~ '.'), "@deprecated"] | comment }}
{%- else -%}
{{ [member.brief or (member.id ~ '.'), "@deprecated " ~ member.deprecated.note] | comment }}
{%- endif -%}
@Deprecated public static final {{ attribute.type | instantiated_type | map_text("java_enum_type") }} {{ member.id | screaming_snake_case }} = {{ member.value | print_member_value }};
{% elif member is experimental or enum_deprecated_in_favor_of_stable.value %}
{{ [member.brief or (member.id ~ '.')] | comment }}
{%- if member is deprecated -%}
@Deprecated
{%- endif -%}
public static final {{ attribute.type | instantiated_type | map_text("java_enum_type") }} {{ member.id | screaming_snake_case }} = {{ member.value | print_member_value }};
{% elif member is stable %}
{%- set stable_class_link = "io.opentelemetry.semconv." ~ stable_class_name ~ "." ~ (attribute.name | pascal_case) ~ "Values#" ~ (member.id | screaming_snake_case) -%}
{{ [member.brief or (member.id ~ '.'), "@deprecated deprecated in favor of stable {@link " ~ stable_class_link ~ "} value."] | comment }}
@Deprecated public static final {{ attribute.type | instantiated_type | map_text("java_enum_type") }} {{ member.id | screaming_snake_case }} = {{ member.value | print_member_value }};
{%- endif -%}
{%- endfor %}
private {{ attribute.name | pascal_case }}IncubatingValues() {}
}
{% endfor %}
private {{ my_class_name }}() {}
}