Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup enum generation #52

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions buildscripts/templates/SemanticAttributes.java.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
{{type | to_camelcase(False)}}Key
{%- endif -%}
{%- endmacro %}
{%- macro stable_class_ref(const_name) -%}
{{stablePkg}}.{{ root_namespace | to_camelcase(True) }}Attributes#{{const_name}}
{%- macro stable_class_ref(const_name, separator) -%}
{{stablePkg}}.{{ root_namespace | to_camelcase(True) }}Attributes{{separator}}{{const_name}}
{%- endmacro %}
{%- if filter != 'any' %}
{%- set filtered_attributes = attributes_and_templates | select(filter) | list %}
{%- else %}
{%- set filtered_attributes = attributes_and_templates | list %}
{%- endif %}
{%- set filtered_enums = filtered_attributes | selectattr('is_enum', 'equalto', true) | list %}
{%- if filtered_attributes | count > 0 %}
/*
* Copyright The OpenTelemetry Authors
Expand Down Expand Up @@ -73,11 +74,11 @@ public final class {{ root_namespace | to_camelcase(True) }}{{ classPrefix }}Att
<ul> {{attribute.note | replace("> ", "") | render_markdown(code="{{@code {0}}}", paragraph="<li>{0}</li>", list="{0}")}} </ul>

{%- endif %}
{%- if attribute | is_deprecated %}
*
{%- if attribute | is_deprecated %}
* @deprecated {{attribute.brief | to_doc_brief}}.
{%- elif attribute | is_stable and stablePkg != "" %}
* @deprecated deprecated in favor of stable {@link {{stable_class_ref(attribute_const_name)}}} attribute.
* @deprecated deprecated in favor of stable {@link {{stable_class_ref(attribute_const_name, '#')}}} attribute.
{%- endif %}
*/
{%- if attribute | is_deprecated or attribute | is_stable and stablePkg != "" %}
Expand All @@ -90,14 +91,28 @@ public final class {{ root_namespace | to_camelcase(True) }}{{ classPrefix }}Att
{%- endif %}
{%- endfor %}

{%- if filtered_enums | count > 0 %}
// Enum definitions
{%- for attribute in filtered_attributes if attribute.is_enum %}
{%- set class_name = attribute.fqn | to_camelcase(True) ~ "Values" %}
{%- set type = to_java_return_type(attribute.attr_type.enum_type) %}
{%- endif %}
{%- for enum_attribute in filtered_enums %}
{%- set class_name = enum_attribute.fqn | to_camelcase(True) ~ "Values" %}
{%- set type = to_java_return_type(enum_attribute.attr_type.enum_type) %}
/**
* Values for {@link #{{ enum_attribute.fqn | to_const_name }}}.
*
{%- if enum_attribute | is_deprecated %}
* @deprecated {{enum_attribute.brief | to_doc_brief}}.
{%- elif enum_attribute | is_stable and stablePkg != "" %}
* @deprecated deprecated in favor of stable {@link {{stable_class_ref(class_name, '.')}}} attribute.
{%- endif %}
*/
{%- if enum_attribute | is_deprecated or enum_attribute | is_stable and stablePkg != "" %}
@Deprecated
{%- endif %}
public static final class {{class_name}} {
{%- for member in attribute.attr_type.members %}
{%- for member in enum_attribute.attr_type.members %}
/** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */
public static final {{ type }} {{ member.member_id | to_const_name }} = {{ attribute | print_member_value(member) }};
public static final {{ type }} {{ member.member_id | to_const_name }} = {{ enum_attribute | print_member_value(member) }};

{%- endfor %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public final class AndroidIncubatingAttributes {
public static final AttributeKey<String> ANDROID_STATE = stringKey("android.state");

// Enum definitions
/** Values for {@link #ANDROID_STATE}. */
public static final class AndroidStateValues {
/**
* Any time before Activity.onResume() or, if the app has no Activity, Context.startService()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ public final class AwsIncubatingAttributes {
public static final AttributeKey<String> AWS_S3_UPLOAD_ID = stringKey("aws.s3.upload_id");

// Enum definitions
/** Values for {@link #AWS_ECS_LAUNCHTYPE}. */
public static final class AwsEcsLaunchtypeValues {
/** ec2. */
public static final String EC2 = "ec2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,5 @@ public final class BrowserIncubatingAttributes {
*/
public static final AttributeKey<String> BROWSER_PLATFORM = stringKey("browser.platform");

// Enum definitions

private BrowserIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,5 @@ public final class ClientIncubatingAttributes {
*/
@Deprecated public static final AttributeKey<Long> CLIENT_PORT = longKey("client.port");

// Enum definitions

private ClientIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public final class CloudIncubatingAttributes {
public static final AttributeKey<String> CLOUD_RESOURCE_ID = stringKey("cloud.resource_id");

// Enum definitions
/** Values for {@link #CLOUD_PLATFORM}. */
public static final class CloudPlatformValues {
/** Alibaba Cloud Elastic Compute Service. */
public static final String ALIBABA_CLOUD_ECS = "alibaba_cloud_ecs";
Expand Down Expand Up @@ -181,6 +182,7 @@ public static final class CloudPlatformValues {
private CloudPlatformValues() {}
}

/** Values for {@link #CLOUD_PROVIDER}. */
public static final class CloudProviderValues {
/** Alibaba Cloud. */
public static final String ALIBABA_CLOUD = "alibaba_cloud";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,5 @@ public final class CloudeventsIncubatingAttributes {
public static final AttributeKey<String> CLOUDEVENTS_EVENT_TYPE =
stringKey("cloudevents.event_type");

// Enum definitions

private CloudeventsIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,5 @@ public final class CodeIncubatingAttributes {
*/
public static final AttributeKey<String> CODE_NAMESPACE = stringKey("code.namespace");

// Enum definitions

private CodeIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,5 @@ public final class ContainerIncubatingAttributes {
/** The container runtime managing this container. */
public static final AttributeKey<String> CONTAINER_RUNTIME = stringKey("container.runtime");

// Enum definitions

private ContainerIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public final class DbIncubatingAttributes {
public static final AttributeKey<String> DB_USER = stringKey("db.user");

// Enum definitions
/** Values for {@link #DB_CASSANDRA_CONSISTENCY_LEVEL}. */
public static final class DbCassandraConsistencyLevelValues {
/** all. */
public static final String ALL = "all";
Expand Down Expand Up @@ -259,6 +260,7 @@ public static final class DbCassandraConsistencyLevelValues {
private DbCassandraConsistencyLevelValues() {}
}

/** Values for {@link #DB_COSMOSDB_CONNECTION_MODE}. */
public static final class DbCosmosdbConnectionModeValues {
/** Gateway (HTTP) connections mode. */
public static final String GATEWAY = "gateway";
Expand All @@ -269,6 +271,7 @@ public static final class DbCosmosdbConnectionModeValues {
private DbCosmosdbConnectionModeValues() {}
}

/** Values for {@link #DB_COSMOSDB_OPERATION_TYPE}. */
public static final class DbCosmosdbOperationTypeValues {
/** invalid. */
public static final String INVALID = "Invalid";
Expand Down Expand Up @@ -318,6 +321,7 @@ public static final class DbCosmosdbOperationTypeValues {
private DbCosmosdbOperationTypeValues() {}
}

/** Values for {@link #DB_SYSTEM}. */
public static final class DbSystemValues {
/** Some other SQL database. Fallback only. See notes. */
public static final String OTHER_SQL = "other_sql";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@ public final class DeploymentIncubatingAttributes {
public static final AttributeKey<String> DEPLOYMENT_ENVIRONMENT =
stringKey("deployment.environment");

// Enum definitions

private DeploymentIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,5 @@ public final class DestinationIncubatingAttributes {
/** Destination port number */
public static final AttributeKey<Long> DESTINATION_PORT = longKey("destination.port");

// Enum definitions

private DestinationIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,5 @@ public final class DeviceIncubatingAttributes {
*/
public static final AttributeKey<String> DEVICE_MODEL_NAME = stringKey("device.model.name");

// Enum definitions

private DeviceIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ public final class EnduserIncubatingAttributes {
*/
public static final AttributeKey<String> ENDUSER_SCOPE = stringKey("enduser.scope");

// Enum definitions

private EnduserIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public final class ErrorIncubatingAttributes {
@Deprecated public static final AttributeKey<String> ERROR_TYPE = stringKey("error.type");

// Enum definitions
/**
* Values for {@link #ERROR_TYPE}.
*
* @deprecated deprecated in favor of stable {@link
* io.opentelemetry.semconv.ErrorAttributes.ErrorTypeValues} attribute.
*/
@Deprecated
public static final class ErrorTypeValues {
/**
* A fallback error value to be used when the instrumentation doesn&#39;t define a custom value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public final class EventIncubatingAttributes {
public static final AttributeKey<String> EVENT_NAME = stringKey("event.name");

// Enum definitions
/** Values for {@link #EVENT_DOMAIN}. */
public static final class EventDomainValues {
/** Events from browser apps. */
public static final String BROWSER = "browser";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,5 @@ public final class ExceptionIncubatingAttributes {
*/
public static final AttributeKey<String> EXCEPTION_TYPE = stringKey("exception.type");

// Enum definitions

private ExceptionIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public final class FaasIncubatingAttributes {
public static final AttributeKey<String> FAAS_VERSION = stringKey("faas.version");

// Enum definitions
/** Values for {@link #FAAS_DOCUMENT_OPERATION}. */
public static final class FaasDocumentOperationValues {
/** When a new object is created. */
public static final String INSERT = "insert";
Expand All @@ -183,6 +184,7 @@ public static final class FaasDocumentOperationValues {
private FaasDocumentOperationValues() {}
}

/** Values for {@link #FAAS_INVOKED_PROVIDER}. */
public static final class FaasInvokedProviderValues {
/** Alibaba Cloud. */
public static final String ALIBABA_CLOUD = "alibaba_cloud";
Expand All @@ -202,6 +204,7 @@ public static final class FaasInvokedProviderValues {
private FaasInvokedProviderValues() {}
}

/** Values for {@link #FAAS_TRIGGER}. */
public static final class FaasTriggerValues {
/** A response to some data source operation such as a database or filesystem read/write. */
public static final String DATASOURCE = "datasource";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,5 @@ public final class FeatureFlagIncubatingAttributes {
*/
public static final AttributeKey<String> FEATURE_FLAG_VARIANT = stringKey("feature_flag.variant");

// Enum definitions

private FeatureFlagIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,5 @@ public final class GcpIncubatingAttributes {
public static final AttributeKey<String> GCP_GCE_INSTANCE_NAME =
stringKey("gcp.gce.instance.name");

// Enum definitions

private GcpIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public final class GraphqlIncubatingAttributes {
stringKey("graphql.operation.type");

// Enum definitions
/** Values for {@link #GRAPHQL_OPERATION_TYPE}. */
public static final class GraphqlOperationTypeValues {
/** GraphQL query. */
public static final String QUERY = "query";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@ public final class HerokuIncubatingAttributes {
public static final AttributeKey<String> HEROKU_RELEASE_CREATION_TIMESTAMP =
stringKey("heroku.release.creation_timestamp");

// Enum definitions

private HerokuIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public final class HostIncubatingAttributes {
public static final AttributeKey<String> HOST_TYPE = stringKey("host.type");

// Enum definitions
/** Values for {@link #HOST_ARCH}. */
public static final class HostArchValues {
/** AMD64. */
public static final String AMD64 = "amd64";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ public final class HttpIncubatingAttributes {
public static final AttributeKey<String> HTTP_URL = stringKey("http.url");

// Enum definitions
/**
* Values for {@link #HTTP_REQUEST_METHOD}.
*
* @deprecated deprecated in favor of stable {@link
* io.opentelemetry.semconv.HttpAttributes.HttpRequestMethodValues} attribute.
*/
@Deprecated
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good example of the deprecated annotation. Javadoc links back to the stable equivalent.

public static final class HttpRequestMethodValues {
/** CONNECT method. */
public static final String CONNECT = "CONNECT";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public final class IosIncubatingAttributes {
public static final AttributeKey<String> IOS_STATE = stringKey("ios.state");

// Enum definitions
/** Values for {@link #IOS_STATE}. */
public static final class IosStateValues {
/**
* The app has become `active`. Associated with UIKit notification `applicationDidBecomeActive`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public final class JvmIncubatingAttributes {
public static final AttributeKey<String> JVM_THREAD_STATE = stringKey("jvm.thread.state");

// Enum definitions
/** Values for {@link #JVM_MEMORY_TYPE}. */
public static final class JvmMemoryTypeValues {
/** Heap memory. */
public static final String HEAP = "heap";
Expand All @@ -83,6 +84,7 @@ public static final class JvmMemoryTypeValues {
private JvmMemoryTypeValues() {}
}

/** Values for {@link #JVM_THREAD_STATE}. */
public static final class JvmThreadStateValues {
/** A thread that has not yet started is in this state. */
public static final String NEW = "new";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,5 @@ public final class K8sIncubatingAttributes {
/** The UID of the StatefulSet. */
public static final AttributeKey<String> K8S_STATEFULSET_UID = stringKey("k8s.statefulset.uid");

// Enum definitions

private K8sIncubatingAttributes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public final class LogIncubatingAttributes {
public static final AttributeKey<String> LOG_RECORD_UID = stringKey("log.record.uid");

// Enum definitions
/** Values for {@link #LOG_IOSTREAM}. */
public static final class LogIostreamValues {
/** Logs from stdout stream. */
public static final String STDOUT = "stdout";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public final class MessageIncubatingAttributes {
longKey("message.uncompressed_size");

// Enum definitions
/** Values for {@link #MESSAGE_TYPE}. */
public static final class MessageTypeValues {
/** sent. */
public static final String SENT = "SENT";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public final class MessagingIncubatingAttributes {
public static final AttributeKey<String> MESSAGING_SYSTEM = stringKey("messaging.system");

// Enum definitions
/** Values for {@link #MESSAGING_OPERATION}. */
public static final class MessagingOperationValues {
/**
* One or more messages are provided for publishing to an intermediary. If a single message is
Expand Down Expand Up @@ -265,6 +266,7 @@ public static final class MessagingOperationValues {
private MessagingOperationValues() {}
}

/** Values for {@link #MESSAGING_ROCKETMQ_CONSUMPTION_MODEL}. */
public static final class MessagingRocketmqConsumptionModelValues {
/** Clustering consumption model. */
public static final String CLUSTERING = "clustering";
Expand All @@ -275,6 +277,7 @@ public static final class MessagingRocketmqConsumptionModelValues {
private MessagingRocketmqConsumptionModelValues() {}
}

/** Values for {@link #MESSAGING_ROCKETMQ_MESSAGE_TYPE}. */
public static final class MessagingRocketmqMessageTypeValues {
/** Normal message. */
public static final String NORMAL = "normal";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public final class NetIncubatingAttributes {
public static final AttributeKey<String> NET_TRANSPORT = stringKey("net.transport");

// Enum definitions
/** Values for {@link #NET_SOCK_FAMILY}. */
public static final class NetSockFamilyValues {
/** IPv4 address. */
public static final String INET = "inet";
Expand All @@ -73,6 +74,7 @@ public static final class NetSockFamilyValues {
private NetSockFamilyValues() {}
}

/** Values for {@link #NET_TRANSPORT}. */
public static final class NetTransportValues {
/** ip_tcp. */
public static final String IP_TCP = "ip_tcp";
Expand Down
Loading
Loading