Skip to content

Commit 6738564

Browse files
authored
Update to semantic conventions (#9)
* Add deprecations to template * Remove redundant deprecations, fix template formating * Fix formatting * Add explanatory comment
1 parent b3f3d02 commit 6738564

File tree

4 files changed

+1202
-251
lines changed

4 files changed

+1202
-251
lines changed

build.gradle.kts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ dependencies {
2020
testImplementation("org.assertj:assertj-core")
2121
}
2222

23-
val specificationVersion = "1.20.0"
23+
val semanticConventionsVersion = "1.21.0"
2424
var generatorVersion = "0.18.0"
2525

26-
val specificationRepoZip = "https://github.com/open-telemetry/opentelemetry-specification/archive/v$specificationVersion.zip"
27-
val schemaUrl = "https://opentelemetry.io/schemas/$specificationVersion"
26+
val semanticConventionsRepoZip = "https://github.com/open-telemetry/semantic-conventions/archive/v$semanticConventionsVersion.zip"
27+
val schemaUrl = "https://opentelemetry.io/schemas/$semanticConventionsVersion"
2828

29-
val downloadSpecification by tasks.registering(Download::class) {
30-
src(specificationRepoZip)
31-
dest("$buildDir/opentelemetry-specification/opentelemetry-specification.zip")
29+
val downloadSemanticConventions by tasks.registering(Download::class) {
30+
src(semanticConventionsRepoZip)
31+
dest("$buildDir/semantic-conventions/semantic-conventions.zip")
3232
overwrite(false)
3333
}
3434

3535
val unzipConfigurationSchema by tasks.registering(Copy::class) {
36-
dependsOn(downloadSpecification)
36+
dependsOn(downloadSemanticConventions)
3737

38-
from(zipTree(downloadSpecification.get().dest))
38+
from(zipTree(downloadSemanticConventions.get().dest))
3939
eachFile(closureOf<FileCopyDetails> {
40-
// Remove the top level folder "/opentelemetry-specification-$semanticConventionsVersion"
40+
// Remove the top level folder "/semantic-conventions-$semanticConventionsVersion"
4141
val pathParts = path.split("/")
4242
path = pathParts.subList(1, pathParts.size).joinToString("/")
4343
})
44-
into("$buildDir/opentelemetry-specification/")
44+
into("$buildDir/semantic-conventions/")
4545
}
4646

4747
val generateSemanticAttributes by tasks.registering(Exec::class) {
@@ -52,7 +52,7 @@ val generateSemanticAttributes by tasks.registering(Exec::class) {
5252
setArgs(listOf(
5353
"run",
5454
"--rm",
55-
"-v", "$buildDir/opentelemetry-specification/semantic_conventions:/source",
55+
"-v", "$buildDir/semantic-conventions/model:/source",
5656
"-v", "$projectDir/buildscripts/templates:/templates",
5757
"-v", "$projectDir/src/main/java/io/opentelemetry/semconv/trace/attributes/:/output",
5858
"otel/semconvgen:$generatorVersion",
@@ -74,7 +74,7 @@ val generateResourceAttributes by tasks.registering(Exec::class) {
7474
setArgs(listOf(
7575
"run",
7676
"--rm",
77-
"-v", "$buildDir/opentelemetry-specification/semantic_conventions:/source",
77+
"-v", "$buildDir/semantic-conventions/model:/source",
7878
"-v", "$projectDir/buildscripts/templates:/templates",
7979
"-v", "$projectDir/src/main/java/io/opentelemetry/semconv/resource/attributes/:/output",
8080
"otel/semconvgen:$generatorVersion",

buildscripts/templates/SemanticAttributes.java.j2

Lines changed: 254 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ public final class {{class}} {
6969
{%- if attribute.note %}
7070
*
7171
* <p>Notes:
72-
<ul> {{attribute.note | render_markdown(code="{{@code {0}}}", paragraph="<li>{0}</li>", list="{0}")}} </ul>
72+
{# NOTE: replace("> ", "") removes the following problematic characters which produce mangled javadoc: #}
73+
{# https://github.com/open-telemetry/semantic-conventions/blob/c83a10a9c33c18a769835e959200d0e24dc708fe/model/resource/k8s.yaml#L34-L38 #}
74+
<ul> {{attribute.note | replace("> ", "") | render_markdown(code="{{@code {0}}}", paragraph="<li>{0}</li>", list="{0}")}} </ul>
75+
7376
{%- endif %}
7477
{%- if (attribute.stability | string()) == "StabilityLevel.DEPRECATED" %}
7578
*
@@ -94,16 +97,6 @@ public final class {{class}} {
9497

9598
{%- endfor %}
9699

97-
{%- if class_name == "NetTransportValues" %}
98-
/** @deprecated This item has been removed as of 1.13.0 of the semantic conventions. */
99-
@Deprecated
100-
public static final String IP = "ip";
101-
102-
/** @deprecated This item has been removed as of 1.13.0 of the semantic conventions. */
103-
@Deprecated
104-
public static final String UNIX = "unix";
105-
{%- endif %}
106-
107100
private {{ class_name }}() {}
108101
}
109102

@@ -424,6 +417,256 @@ public final class {{class}} {
424417
private MessagingSourceKindValues() {}
425418
}
426419

420+
/**
421+
* The internet connection type currently being used by the host.
422+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions. Use {@link SemanticAttributes#NETWORK_CONNECTION_TYPE} instead.
423+
*/
424+
@Deprecated
425+
public static final AttributeKey<String> NET_HOST_CONNECTION_TYPE =
426+
stringKey("net.host.connection.type");
427+
428+
/**
429+
* This describes more details regarding the connection.type. It may be the type of cell
430+
* technology connection, but it could be used for describing details about a wifi connection.
431+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions. Use {@link SemanticAttributes#NETWORK_CONNECTION_SUBTYPE} instead.
432+
*/
433+
@Deprecated
434+
public static final AttributeKey<String> NET_HOST_CONNECTION_SUBTYPE =
435+
stringKey("net.host.connection.subtype");
436+
437+
/**
438+
* The name of the mobile carrier.
439+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions. Use {@link SemanticAttributes#NETWORK_CARRIER_NAME} instead.
440+
*/
441+
@Deprecated
442+
public static final AttributeKey<String> NET_HOST_CARRIER_NAME =
443+
stringKey("net.host.carrier.name");
444+
445+
/**
446+
* The mobile carrier country code.
447+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions. Use {@link SemanticAttributes#NETWORK_CARRIER_MCC} instead.
448+
*/
449+
@Deprecated
450+
public static final AttributeKey<String> NET_HOST_CARRIER_MCC = stringKey("net.host.carrier.mcc");
451+
452+
/**
453+
* The mobile carrier network code.
454+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions. Use {@link SemanticAttributes#NETWORK_CARRIER_MNC} instead.
455+
*/
456+
@Deprecated
457+
public static final AttributeKey<String> NET_HOST_CARRIER_MNC = stringKey("net.host.carrier.mnc");
458+
459+
/**
460+
* The ISO 3166-1 alpha-2 2-character country code associated with the mobile carrier network.
461+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions. Use {@link SemanticAttributes#NETWORK_CARRIER_ICC} instead.
462+
*/
463+
@Deprecated
464+
public static final AttributeKey<String> NET_HOST_CARRIER_ICC = stringKey("net.host.carrier.icc");
465+
466+
/**
467+
* The IP address of the original client behind all proxies, if known (e.g. from <a
468+
* href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For">X-Forwarded-For</a>).
469+
*
470+
* <p>Notes:
471+
*
472+
* <ul>
473+
* <li>This is not necessarily the same as {@code net.sock.peer.addr}, which would identify the
474+
* network-level peer, which may be a proxy.
475+
* <li>This attribute should be set when a source of information different from the one used for
476+
* {@code net.sock.peer.addr}, is available even if that other source just confirms the same
477+
* value as {@code net.sock.peer.addr}. Rationale: For {@code net.sock.peer.addr}, one
478+
* typically does not know if it comes from a proxy, reverse proxy, or the actual client.
479+
* Setting {@code http.client_ip} when it's the same as {@code net.sock.peer.addr} means
480+
* that one is at least somewhat confident that the address is not that of the closest
481+
* proxy.
482+
* </ul>
483+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions. Use {@link SemanticAttributes#CLIENT_ADDRESS} instead.
484+
*/
485+
@Deprecated
486+
public static final AttributeKey<String> HTTP_CLIENT_IP = stringKey("http.client_ip");
487+
488+
/**
489+
* The message source name.
490+
*
491+
* <p>Notes:
492+
*
493+
* <ul>
494+
* <li>Source name SHOULD uniquely identify a specific queue, topic, or other entity within the
495+
* broker. If the broker does not have such notion, the source name SHOULD uniquely identify
496+
* the broker.
497+
* </ul>
498+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions.
499+
*/
500+
@Deprecated
501+
public static final AttributeKey<String> MESSAGING_SOURCE_NAME =
502+
stringKey("messaging.source.name");
503+
504+
/**
505+
* Low cardinality representation of the messaging source name.
506+
*
507+
* <p>Notes:
508+
*
509+
* <ul>
510+
* <li>Source names could be constructed from templates. An example would be a source name
511+
* involving a user name or product id. Although the source name in this case is of high
512+
* cardinality, the underlying template is of low cardinality and can be effectively used
513+
* for grouping and aggregation.
514+
* </ul>
515+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions.
516+
*/
517+
@Deprecated
518+
public static final AttributeKey<String> MESSAGING_SOURCE_TEMPLATE =
519+
stringKey("messaging.source.template");
520+
521+
/**
522+
* A boolean that is true if the message source is temporary and might not exist anymore after
523+
* messages are processed.
524+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions.
525+
*/
526+
@Deprecated
527+
public static final AttributeKey<Boolean> MESSAGING_SOURCE_TEMPORARY =
528+
booleanKey("messaging.source.temporary");
529+
530+
/**
531+
* A boolean that is true if the message source is anonymous (could be unnamed or have
532+
* auto-generated name).
533+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions.
534+
*/
535+
@Deprecated
536+
public static final AttributeKey<Boolean> MESSAGING_SOURCE_ANONYMOUS =
537+
booleanKey("messaging.source.anonymous");
538+
539+
/**
540+
* The identifier for the consumer receiving a message. For Kafka, set it to {@code
541+
* {messaging.kafka.consumer.group} - {messaging.kafka.client_id}}, if both are present, or only
542+
* {@code messaging.kafka.consumer.group}. For brokers, such as RabbitMQ and Artemis, set it to
543+
* the {@code client_id} of the client consuming the message.
544+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions. See {@link SemanticAttributes#MESSAGING_CLIENT_ID}.
545+
*/
546+
@Deprecated
547+
public static final AttributeKey<String> MESSAGING_CONSUMER_ID =
548+
stringKey("messaging.consumer.id");
549+
550+
/**
551+
* Client Id for the Consumer or Producer that is handling the message.
552+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions. See {@link SemanticAttributes#MESSAGING_CLIENT_ID}.
553+
*/
554+
@Deprecated
555+
public static final AttributeKey<String> MESSAGING_KAFKA_CLIENT_ID =
556+
stringKey("messaging.kafka.client_id");
557+
558+
/**
559+
* Partition the message is received from.
560+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions.
561+
*/
562+
@Deprecated
563+
public static final AttributeKey<Long> MESSAGING_KAFKA_SOURCE_PARTITION =
564+
longKey("messaging.kafka.source.partition");
565+
566+
/**
567+
* The unique identifier for each client.
568+
* @deprecated This item has been removed in 1.21.0 version of the semantic conventions. See {@link SemanticAttributes#MESSAGING_CLIENT_ID}.
569+
*/
570+
@Deprecated
571+
public static final AttributeKey<String> MESSAGING_ROCKETMQ_CLIENT_ID =
572+
stringKey("messaging.rocketmq.client_id");
573+
574+
/**
575+
* Enum values for {@link #NET_HOST_CONNECTION_TYPE}.
576+
* @deprecated This item has been removed as of 1.21.0 of the semantic conventions. Use {@link NetworkConnectionTypeValues} instead.
577+
*/
578+
@Deprecated
579+
public static final class NetHostConnectionTypeValues {
580+
/** wifi. */
581+
public static final String WIFI = "wifi";
582+
583+
/** wired. */
584+
public static final String WIRED = "wired";
585+
586+
/** cell. */
587+
public static final String CELL = "cell";
588+
589+
/** unavailable. */
590+
public static final String UNAVAILABLE = "unavailable";
591+
592+
/** unknown. */
593+
public static final String UNKNOWN = "unknown";
594+
595+
private NetHostConnectionTypeValues() {}
596+
}
597+
598+
/**
599+
* Enum values for {@link #NET_HOST_CONNECTION_SUBTYPE}.
600+
* @deprecated This item has been removed as of 1.21.0 of the semantic conventions. Use {@link NetworkConnectionSubtypeValues} instead.
601+
*/
602+
@Deprecated
603+
public static final class NetHostConnectionSubtypeValues {
604+
/** GPRS. */
605+
public static final String GPRS = "gprs";
606+
607+
/** EDGE. */
608+
public static final String EDGE = "edge";
609+
610+
/** UMTS. */
611+
public static final String UMTS = "umts";
612+
613+
/** CDMA. */
614+
public static final String CDMA = "cdma";
615+
616+
/** EVDO Rel. 0. */
617+
public static final String EVDO_0 = "evdo_0";
618+
619+
/** EVDO Rev. A. */
620+
public static final String EVDO_A = "evdo_a";
621+
622+
/** CDMA2000 1XRTT. */
623+
public static final String CDMA2000_1XRTT = "cdma2000_1xrtt";
624+
625+
/** HSDPA. */
626+
public static final String HSDPA = "hsdpa";
627+
628+
/** HSUPA. */
629+
public static final String HSUPA = "hsupa";
630+
631+
/** HSPA. */
632+
public static final String HSPA = "hspa";
633+
634+
/** IDEN. */
635+
public static final String IDEN = "iden";
636+
637+
/** EVDO Rev. B. */
638+
public static final String EVDO_B = "evdo_b";
639+
640+
/** LTE. */
641+
public static final String LTE = "lte";
642+
643+
/** EHRPD. */
644+
public static final String EHRPD = "ehrpd";
645+
646+
/** HSPAP. */
647+
public static final String HSPAP = "hspap";
648+
649+
/** GSM. */
650+
public static final String GSM = "gsm";
651+
652+
/** TD-SCDMA. */
653+
public static final String TD_SCDMA = "td_scdma";
654+
655+
/** IWLAN. */
656+
public static final String IWLAN = "iwlan";
657+
658+
/** 5G NR (New Radio). */
659+
public static final String NR = "nr";
660+
661+
/** 5G NRNSA (New Radio Non-Standalone). */
662+
public static final String NRNSA = "nrnsa";
663+
664+
/** LTE CA. */
665+
public static final String LTE_CA = "lte_ca";
666+
667+
private NetHostConnectionSubtypeValues() {}
668+
}
669+
427670
{% endif %}
428671

429672
{%- if class == "ResourceAttributes" %}

0 commit comments

Comments
 (0)