forked from open-telemetry/opentelemetry-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SemanticAttributes.java.j2
183 lines (161 loc) · 6.36 KB
/
SemanticAttributes.java.j2
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
{%- macro to_java_return_type(type) -%}
{%- if type == "string" -%}
String
{%- elif type == "string[]" -%}
List<String>
{%- 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 %}
*
* <p>Notes:
<ul> {{attribute.note | render_markdown(code="{{@code {0}}}", paragraph="<li>{0}</li>", list="{0}")}} </ul>
{%- 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 %}
{%- if class_name == "NetTransportValues" %}
/** @deprecated This item has been removed as of 1.13.0 of the semantic conventions. */
@Deprecated
public static final String IP = "ip";
/** @deprecated This item has been removed as of 1.13.0 of the semantic conventions. */
@Deprecated
public static final String UNIX = "unix";
{%- endif %}
private {{ class_name }}() {}
}
{% endif %}
{%- endfor %}
{%- if class == "SemanticAttributes" %}
// Manually defined and not YET in the YAML
/**
* The name of an event describing an exception.
*
* <p>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";
/**
* The name of the keyspace being accessed.
*
* @deprecated this item has been removed as of 1.8.0 of the semantic conventions. Please use {@link SemanticAttributes#DB_NAME} instead.
*/
@Deprecated
public static final AttributeKey<String> DB_CASSANDRA_KEYSPACE =
stringKey("db.cassandra.keyspace");
/**
* The <a href="https://hbase.apache.org/book.html#_namespace">HBase namespace</a> being accessed.
*
* @deprecated this item has been removed as of 1.8.0 of the semantic conventions. Please use {@link SemanticAttributes#DB_NAME} instead.
*/
@Deprecated
public static final AttributeKey<String> DB_HBASE_NAMESPACE = stringKey("db.hbase.namespace");
/**
* The size of the uncompressed request payload body after transport decoding. Not set if
* transport encoding not used.
*
* @deprecated this item has been removed as of 1.13.0 of the semantic conventions. Please use {@link SemanticAttributes#HTTP_REQUEST_CONTENT_LENGTH} instead.
*/
@Deprecated
public static final AttributeKey<Long> HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED =
longKey("http.request_content_length_uncompressed");
/**
* @deprecated This item has been removed as of 1.13.0 of the semantic conventions. Please use {@link SemanticAttributes#HTTP_RESPONSE_CONTENT_LENGTH} instead.
*/
@Deprecated
public static final AttributeKey<Long> HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED =
longKey("http.response_content_length_uncompressed");
/**
* @deprecated This item has been removed as of 1.13.0 of the semantic conventions. Please use
* {@link SemanticAttributes#NET_HOST_NAME} instead.
*/
@Deprecated
public static final AttributeKey<String> HTTP_SERVER_NAME = stringKey("http.server_name");
/**
* @deprecated This item has been removed as of 1.13.0 of the semantic conventions. Please use
* {@link SemanticAttributes#NET_HOST_NAME} instead.
*/
@Deprecated
public static final AttributeKey<String> HTTP_HOST = stringKey("http.host");
/**
* @deprecated This item has been removed as of 1.13.0 of the semantic conventions. Please use {@link SemanticAttributes#NET_SOCK_PEER_ADDR} instead.
*/
@Deprecated
public static final AttributeKey<String> NET_PEER_IP = stringKey("net.peer.ip");
/**
* @deprecated This item has been removed as of 1.13.0 of the semantic conventions. Please use {@link SemanticAttributes#NET_SOCK_HOST_ADDR} instead.
*/
@Deprecated
public static final AttributeKey<String> NET_HOST_IP = stringKey("net.host.ip");
{% endif %}
private {{class}}() {}
}