Skip to content

Commit 2e9449d

Browse files
committed
Stable metric constants
1 parent 7cb3063 commit 2e9449d

File tree

10 files changed

+832
-156
lines changed

10 files changed

+832
-156
lines changed

buildscripts/templates/registry/incubating_java/IncubatingSemanticMetrics.java.j2

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,29 @@ public final class {{ my_class_name }} {
3535
{%- endif %}
3636
public static final String {{ metric.metric_name | replace(".", "_") | screaming_snake_case }}_DESCRIPTION = "{{ metric.brief | replace('\n', ' ') | replace('"', '\\"') }}";
3737
{%- elif metric is stable -%}
38+
{%- set stable_class_name = ctx.root_namespace | pascal_case ~ "Metrics" -%}
39+
{%- set stable_class_link = "io.opentelemetry.semconv." ~ stable_class_name ~ "#" ~ (metric.metric_name | replace(".", "_") | screaming_snake_case) -%}
3840

39-
/** Name of the {@code {{ metric.metric_name }}} metric. */
40-
public static final String {{ metric.metric_name | replace(".", "_") | screaming_snake_case }}_NAME = "{{ metric.metric_name }}";
41+
/**
42+
* Name of the {@code {{ metric.metric_name }}} metric.
43+
*
44+
* @deprecated deprecated in favor of stable {@link {{ stable_class_link }}_NAME} constant.
45+
*/
46+
@Deprecated public static final String {{ metric.metric_name | replace(".", "_") | screaming_snake_case }}_NAME = "{{ metric.metric_name }}";
4147

42-
/** Unit of the {@code {{ metric.metric_name }}} metric. */
43-
public static final String {{ metric.metric_name | replace(".", "_") | screaming_snake_case }}_UNIT = "{{ metric.unit }}";
48+
/**
49+
* Unit of the {@code {{ metric.metric_name }}} metric.
50+
*
51+
* @deprecated deprecated in favor of stable {@link {{ stable_class_link }}_UNIT} constant.
52+
*/
53+
@Deprecated public static final String {{ metric.metric_name | replace(".", "_") | screaming_snake_case }}_UNIT = "{{ metric.unit }}";
4454

45-
/** Description of the {@code {{ metric.metric_name }}} metric. */
46-
public static final String {{ metric.metric_name | replace(".", "_") | screaming_snake_case }}_DESCRIPTION = "{{ metric.brief | replace('\n', ' ') | replace('"', '\\"') }}";
55+
/**
56+
* Description of the {@code {{ metric.metric_name }}} metric.
57+
*
58+
* @deprecated deprecated in favor of stable {@link {{ stable_class_link }}_DESCRIPTION} constant.
59+
*/
60+
@Deprecated public static final String {{ metric.metric_name | replace(".", "_") | screaming_snake_case }}_DESCRIPTION = "{{ metric.brief | replace('\n', ' ') | replace('"', '\\"') }}";
4761
{%- endif -%}
4862
{%- endfor %}
4963

buildscripts/templates/registry/java/weaver.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ templates:
2929
})
3030
application_mode: each
3131
file_name: "{{ctx.root_namespace | pascal_case}}Attributes.java"
32-
# - pattern: SemanticMetrics.java.j2
33-
# filter: >
34-
# semconv_grouped_metrics({
35-
# "exclude_root_namespace": $excluded_namespaces,
36-
# "exclude_stability": ["experimental", "deprecated"]
37-
# }) | map({
38-
# root_namespace: .root_namespace,
39-
# metrics: .metrics
40-
# })
41-
# application_mode: each
42-
# file_name: "{{ctx.root_namespace | pascal_case}}Metrics.java"
32+
- pattern: SemanticMetrics.java.j2
33+
filter: >
34+
semconv_grouped_metrics({
35+
"exclude_root_namespace": $excluded_namespaces,
36+
"exclude_stability": ["experimental", "deprecated"]
37+
}) | map({
38+
root_namespace: .root_namespace,
39+
metrics: .metrics
40+
})
41+
application_mode: each
42+
file_name: "{{ctx.root_namespace | pascal_case}}Metrics.java"
4343
text_maps:
4444
java_enum_type:
4545
int: long

semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/DbIncubatingMetrics.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,30 @@ public final class DbIncubatingMetrics {
241241
public static final String DB_CLIENT_COSMOSDB_OPERATION_REQUEST_CHARGE_DESCRIPTION =
242242
"Deprecated, use `azure.cosmosdb.client.operation.request_charge` instead.";
243243

244-
/** Name of the {@code db.client.operation.duration} metric. */
244+
/**
245+
* Name of the {@code db.client.operation.duration} metric.
246+
*
247+
* @deprecated deprecated in favor of stable {@link
248+
* io.opentelemetry.semconv.DbMetrics#DB_CLIENT_OPERATION_DURATION_NAME} constant.
249+
*/
250+
@Deprecated
245251
public static final String DB_CLIENT_OPERATION_DURATION_NAME = "db.client.operation.duration";
246252

247-
/** Unit of the {@code db.client.operation.duration} metric. */
248-
public static final String DB_CLIENT_OPERATION_DURATION_UNIT = "s";
249-
250-
/** Description of the {@code db.client.operation.duration} metric. */
253+
/**
254+
* Unit of the {@code db.client.operation.duration} metric.
255+
*
256+
* @deprecated deprecated in favor of stable {@link
257+
* io.opentelemetry.semconv.DbMetrics#DB_CLIENT_OPERATION_DURATION_UNIT} constant.
258+
*/
259+
@Deprecated public static final String DB_CLIENT_OPERATION_DURATION_UNIT = "s";
260+
261+
/**
262+
* Description of the {@code db.client.operation.duration} metric.
263+
*
264+
* @deprecated deprecated in favor of stable {@link
265+
* io.opentelemetry.semconv.DbMetrics#DB_CLIENT_OPERATION_DURATION_DESCRIPTION} constant.
266+
*/
267+
@Deprecated
251268
public static final String DB_CLIENT_OPERATION_DURATION_DESCRIPTION =
252269
"Duration of database client operations.";
253270

semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/HttpIncubatingMetrics.java

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,30 @@ public final class HttpIncubatingMetrics {
5151
public static final String HTTP_CLIENT_REQUEST_BODY_SIZE_DESCRIPTION =
5252
"Size of HTTP client request bodies.";
5353

54-
/** Name of the {@code http.client.request.duration} metric. */
54+
/**
55+
* Name of the {@code http.client.request.duration} metric.
56+
*
57+
* @deprecated deprecated in favor of stable {@link
58+
* io.opentelemetry.semconv.HttpMetrics#HTTP_CLIENT_REQUEST_DURATION_NAME} constant.
59+
*/
60+
@Deprecated
5561
public static final String HTTP_CLIENT_REQUEST_DURATION_NAME = "http.client.request.duration";
5662

57-
/** Unit of the {@code http.client.request.duration} metric. */
58-
public static final String HTTP_CLIENT_REQUEST_DURATION_UNIT = "s";
59-
60-
/** Description of the {@code http.client.request.duration} metric. */
63+
/**
64+
* Unit of the {@code http.client.request.duration} metric.
65+
*
66+
* @deprecated deprecated in favor of stable {@link
67+
* io.opentelemetry.semconv.HttpMetrics#HTTP_CLIENT_REQUEST_DURATION_UNIT} constant.
68+
*/
69+
@Deprecated public static final String HTTP_CLIENT_REQUEST_DURATION_UNIT = "s";
70+
71+
/**
72+
* Description of the {@code http.client.request.duration} metric.
73+
*
74+
* @deprecated deprecated in favor of stable {@link
75+
* io.opentelemetry.semconv.HttpMetrics#HTTP_CLIENT_REQUEST_DURATION_DESCRIPTION} constant.
76+
*/
77+
@Deprecated
6178
public static final String HTTP_CLIENT_REQUEST_DURATION_DESCRIPTION =
6279
"Duration of HTTP client requests.";
6380

@@ -91,13 +108,30 @@ public final class HttpIncubatingMetrics {
91108
public static final String HTTP_SERVER_REQUEST_BODY_SIZE_DESCRIPTION =
92109
"Size of HTTP server request bodies.";
93110

94-
/** Name of the {@code http.server.request.duration} metric. */
111+
/**
112+
* Name of the {@code http.server.request.duration} metric.
113+
*
114+
* @deprecated deprecated in favor of stable {@link
115+
* io.opentelemetry.semconv.HttpMetrics#HTTP_SERVER_REQUEST_DURATION_NAME} constant.
116+
*/
117+
@Deprecated
95118
public static final String HTTP_SERVER_REQUEST_DURATION_NAME = "http.server.request.duration";
96119

97-
/** Unit of the {@code http.server.request.duration} metric. */
98-
public static final String HTTP_SERVER_REQUEST_DURATION_UNIT = "s";
99-
100-
/** Description of the {@code http.server.request.duration} metric. */
120+
/**
121+
* Unit of the {@code http.server.request.duration} metric.
122+
*
123+
* @deprecated deprecated in favor of stable {@link
124+
* io.opentelemetry.semconv.HttpMetrics#HTTP_SERVER_REQUEST_DURATION_UNIT} constant.
125+
*/
126+
@Deprecated public static final String HTTP_SERVER_REQUEST_DURATION_UNIT = "s";
127+
128+
/**
129+
* Description of the {@code http.server.request.duration} metric.
130+
*
131+
* @deprecated deprecated in favor of stable {@link
132+
* io.opentelemetry.semconv.HttpMetrics#HTTP_SERVER_REQUEST_DURATION_DESCRIPTION} constant.
133+
*/
134+
@Deprecated
101135
public static final String HTTP_SERVER_REQUEST_DURATION_DESCRIPTION =
102136
"Duration of HTTP server requests.";
103137

0 commit comments

Comments
 (0)