Modification of enum semantic attributes (#3128)

* rebasing

* removed class generating enums and modified return type

* reverted return type and removed the if check

* one script fix, and run the generator to re-gen the classes.

* undo unrelated change

Co-authored-by: jkwatson <jwatson@splunk.com>
This commit is contained in:
Harshita Srinivas 2021-04-13 20:34:54 +05:30 committed by GitHub
parent 2f3cdb926c
commit 877dc7f4a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 141 deletions

View File

@ -76,7 +76,6 @@ public final class {{class}} {
{%- if attribute.is_enum %} {%- if attribute.is_enum %}
{%- set class_name = attribute.fqn | to_camelcase(True) ~ "Values" %} {%- set class_name = attribute.fqn | to_camelcase(True) ~ "Values" %}
{%- set type = to_java_return_type(attribute.attr_type.enum_type) %} {%- set type = to_java_return_type(attribute.attr_type.enum_type) %}
{%- if attribute.attr_type.custom_values %}
public static final class {{class_name}} { public static final class {{class_name}} {
{%- for member in attribute.attr_type.members %} {%- for member in attribute.attr_type.members %}
/** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */ /** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */
@ -84,24 +83,7 @@ public final class {{class}} {
{%- endfor %} {%- endfor %}
private {{ class_name }}() {} private {{ class_name }}() {}
} }
{%- else -%}
public enum {{class_name}} {
{%- for member in attribute.attr_type.members %}
/** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */
{{ member.member_id | to_const_name }}({{ print_value(type, member.value) }}),
{%- endfor %}
;
private final {{ type }} value;
{{class_name}}({{ type }} value) {
this.value = value;
}
public {{ type }} getValue() {
return value;
}
}
{% endif %}
{% endif %} {% endif %}
{%- endfor %} {%- endfor %}

View File

@ -428,22 +428,13 @@ public final class ResourceAttributes {
private CloudInfrastructureServiceValues() {} private CloudInfrastructureServiceValues() {}
} }
public enum AwsEcsLaunchtypeValues { public static final class AwsEcsLaunchtypeValues {
/** ec2. */ /** ec2. */
EC2("ec2"), public static final String EC2 = "ec2";
/** fargate. */ /** fargate. */
FARGATE("fargate"), public static final String FARGATE = "fargate";
;
private final String value; private AwsEcsLaunchtypeValues() {}
AwsEcsLaunchtypeValues(String value) {
this.value = value;
}
public String getValue() {
return value;
}
} }
public static final class HostArchValues { public static final class HostArchValues {

View File

@ -641,92 +641,65 @@ public final class SemanticAttributes {
private DbSystemValues() {} private DbSystemValues() {}
} }
public enum NetTransportValues { public static final class NetTransportValues {
/** IP.TCP. */ /** IP.TCP. */
IP_TCP("IP.TCP"), public static final String IP_TCP = "IP.TCP";
/** IP.UDP. */ /** IP.UDP. */
IP_UDP("IP.UDP"), public static final String IP_UDP = "IP.UDP";
/** Another IP-based protocol. */ /** Another IP-based protocol. */
IP("IP"), public static final String IP = "IP";
/** Unix Domain socket. See below. */ /** Unix Domain socket. See below. */
UNIX("Unix"), public static final String UNIX = "Unix";
/** Named or anonymous pipe. See note below. */ /** Named or anonymous pipe. See note below. */
PIPE("pipe"), public static final String PIPE = "pipe";
/** In-process communication. */ /** In-process communication. */
INPROC("inproc"), public static final String INPROC = "inproc";
/** Something else (non IP-based). */ /** Something else (non IP-based). */
OTHER("other"), public static final String OTHER = "other";
;
private final String value; private NetTransportValues() {}
NetTransportValues(String value) {
this.value = value;
} }
public String getValue() { public static final class DbCassandraConsistencyLevelValues {
return value;
}
}
public enum DbCassandraConsistencyLevelValues {
/** ALL. */ /** ALL. */
ALL("ALL"), public static final String ALL = "ALL";
/** EACH_QUORUM. */ /** EACH_QUORUM. */
EACH_QUORUM("EACH_QUORUM"), public static final String EACH_QUORUM = "EACH_QUORUM";
/** QUORUM. */ /** QUORUM. */
QUORUM("QUORUM"), public static final String QUORUM = "QUORUM";
/** LOCAL_QUORUM. */ /** LOCAL_QUORUM. */
LOCAL_QUORUM("LOCAL_QUORUM"), public static final String LOCAL_QUORUM = "LOCAL_QUORUM";
/** ONE. */ /** ONE. */
ONE("ONE"), public static final String ONE = "ONE";
/** TWO. */ /** TWO. */
TWO("TWO"), public static final String TWO = "TWO";
/** THREE. */ /** THREE. */
THREE("THREE"), public static final String THREE = "THREE";
/** LOCAL_ONE. */ /** LOCAL_ONE. */
LOCAL_ONE("LOCAL_ONE"), public static final String LOCAL_ONE = "LOCAL_ONE";
/** ANY. */ /** ANY. */
ANY("ANY"), public static final String ANY = "ANY";
/** SERIAL. */ /** SERIAL. */
SERIAL("SERIAL"), public static final String SERIAL = "SERIAL";
/** LOCAL_SERIAL. */ /** LOCAL_SERIAL. */
LOCAL_SERIAL("LOCAL_SERIAL"), public static final String LOCAL_SERIAL = "LOCAL_SERIAL";
;
private final String value; private DbCassandraConsistencyLevelValues() {}
DbCassandraConsistencyLevelValues(String value) {
this.value = value;
} }
public String getValue() { public static final class FaasTriggerValues {
return value;
}
}
public enum FaasTriggerValues {
/** A response to some data source operation such as a database or filesystem read/write. */ /** A response to some data source operation such as a database or filesystem read/write. */
DATASOURCE("datasource"), public static final String DATASOURCE = "datasource";
/** To provide an answer to an inbound HTTP request. */ /** To provide an answer to an inbound HTTP request. */
HTTP("http"), public static final String HTTP = "http";
/** A function is set to be executed when messages are sent to a messaging system. */ /** A function is set to be executed when messages are sent to a messaging system. */
PUBSUB("pubsub"), public static final String PUBSUB = "pubsub";
/** A function is scheduled to be executed regularly. */ /** A function is scheduled to be executed regularly. */
TIMER("timer"), public static final String TIMER = "timer";
/** If none of the others apply. */ /** If none of the others apply. */
OTHER("other"), public static final String OTHER = "other";
;
private final String value; private FaasTriggerValues() {}
FaasTriggerValues(String value) {
this.value = value;
}
public String getValue() {
return value;
}
} }
public static final class FaasDocumentOperationValues { public static final class FaasDocumentOperationValues {
@ -755,22 +728,13 @@ public final class SemanticAttributes {
private HttpFlavorValues() {} private HttpFlavorValues() {}
} }
public enum MessagingDestinationKindValues { public static final class MessagingDestinationKindValues {
/** A message sent to a queue. */ /** A message sent to a queue. */
QUEUE("queue"), public static final String QUEUE = "queue";
/** A message sent to a topic. */ /** A message sent to a topic. */
TOPIC("topic"), public static final String TOPIC = "topic";
;
private final String value; private MessagingDestinationKindValues() {}
MessagingDestinationKindValues(String value) {
this.value = value;
}
public String getValue() {
return value;
}
} }
public static final class FaasInvokedProviderValues { public static final class FaasInvokedProviderValues {
@ -784,70 +748,52 @@ public final class SemanticAttributes {
private FaasInvokedProviderValues() {} private FaasInvokedProviderValues() {}
} }
public enum MessagingOperationValues { public static final class MessagingOperationValues {
/** receive. */ /** receive. */
RECEIVE("receive"), public static final String RECEIVE = "receive";
/** process. */ /** process. */
PROCESS("process"), public static final String PROCESS = "process";
;
private final String value; private MessagingOperationValues() {}
MessagingOperationValues(String value) {
this.value = value;
} }
public String getValue() { public static final class RpcGrpcStatusCodeValues {
return value;
}
}
public enum RpcGrpcStatusCodeValues {
/** OK. */ /** OK. */
OK(0), public static final long OK = 0;
/** CANCELLED. */ /** CANCELLED. */
CANCELLED(1), public static final long CANCELLED = 1;
/** UNKNOWN. */ /** UNKNOWN. */
UNKNOWN(2), public static final long UNKNOWN = 2;
/** INVALID_ARGUMENT. */ /** INVALID_ARGUMENT. */
INVALID_ARGUMENT(3), public static final long INVALID_ARGUMENT = 3;
/** DEADLINE_EXCEEDED. */ /** DEADLINE_EXCEEDED. */
DEADLINE_EXCEEDED(4), public static final long DEADLINE_EXCEEDED = 4;
/** NOT_FOUND. */ /** NOT_FOUND. */
NOT_FOUND(5), public static final long NOT_FOUND = 5;
/** ALREADY_EXISTS. */ /** ALREADY_EXISTS. */
ALREADY_EXISTS(6), public static final long ALREADY_EXISTS = 6;
/** PERMISSION_DENIED. */ /** PERMISSION_DENIED. */
PERMISSION_DENIED(7), public static final long PERMISSION_DENIED = 7;
/** RESOURCE_EXHAUSTED. */ /** RESOURCE_EXHAUSTED. */
RESOURCE_EXHAUSTED(8), public static final long RESOURCE_EXHAUSTED = 8;
/** FAILED_PRECONDITION. */ /** FAILED_PRECONDITION. */
FAILED_PRECONDITION(9), public static final long FAILED_PRECONDITION = 9;
/** ABORTED. */ /** ABORTED. */
ABORTED(10), public static final long ABORTED = 10;
/** OUT_OF_RANGE. */ /** OUT_OF_RANGE. */
OUT_OF_RANGE(11), public static final long OUT_OF_RANGE = 11;
/** UNIMPLEMENTED. */ /** UNIMPLEMENTED. */
UNIMPLEMENTED(12), public static final long UNIMPLEMENTED = 12;
/** INTERNAL. */ /** INTERNAL. */
INTERNAL(13), public static final long INTERNAL = 13;
/** UNAVAILABLE. */ /** UNAVAILABLE. */
UNAVAILABLE(14), public static final long UNAVAILABLE = 14;
/** DATA_LOSS. */ /** DATA_LOSS. */
DATA_LOSS(15), public static final long DATA_LOSS = 15;
/** UNAUTHENTICATED. */ /** UNAUTHENTICATED. */
UNAUTHENTICATED(16), public static final long UNAUTHENTICATED = 16;
;
private final long value; private RpcGrpcStatusCodeValues() {}
RpcGrpcStatusCodeValues(long value) {
this.value = value;
}
public long getValue() {
return value;
}
} }
// Manually defined and not YET in the YAML // Manually defined and not YET in the YAML