Skip to content

Commit

Permalink
Update semantic convention constants generator script and template (#…
Browse files Browse the repository at this point in the history
…3047)

* Update semantic convention constants generator script, template and spec reference

The template was updated to reflect the changes introduced in otel/semconvgen v0.3.0 and v0.3.1.
The script was updated to pin the version of the otel/semconvgen image, otherwise incompatible updates would break it.

Fixes #3042.

* ./generate.sh

* Update template according to open-telemetry/build-tools#41

* ./generate.sh

The template was updated to use the correct base definitions, so the Javadoc for some attributes changed (the ones for `rpc.*`, for example).
This also changed the ordering but it is still reproducible.
  • Loading branch information
arminru authored Apr 19, 2021
1 parent b3860d4 commit c28d17a
Show file tree
Hide file tree
Showing 4 changed files with 270 additions and 163 deletions.
4 changes: 2 additions & 2 deletions buildscripts/semantic-convention/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR="${SCRIPT_DIR}/../../"

# freeze the spec & generator tools versions to make SemanticAttributes generation reproducible
SPEC_VERSION=v1.1.0
GENERATOR_VERSION=0.2.1
SPEC_VERSION=v1.2.0
GENERATOR_VERSION=0.3.1

cd ${SCRIPT_DIR}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
List<String>
{%- elif type == "boolean" -%}
boolean
{%- elif type == "number" -%}
{%- elif type == "int" -%}
long
{%- elif type == "double" -%}
double
{%- else -%}
{{type}}
{%- endif -%}
Expand All @@ -24,8 +26,10 @@
stringArrayKey
{%- elif type == "boolean" -%}
booleanKey
{%- elif type == "number" -%}
{%- elif type == "int" -%}
longKey
{%- elif type == "double" -%}
doubleKey
{%- else -%}
{{lowerFirst(type)}}Key
{%- endif -%}
Expand All @@ -43,6 +47,7 @@
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;
Expand All @@ -52,7 +57,7 @@ import java.util.List;

// DO NOT EDIT, this is an Auto-generated file from buildscripts/semantic-convention{{template}}
public final class {{class}} {
{%- for attribute in attributes | unique(attribute="fqn") %}
{%- for attribute in attributes if attribute.is_local and not attribute.ref %}

/**
* {% filter escape %}{{attribute.brief | to_doc_brief}}.{% endfilter %}
Expand All @@ -72,7 +77,7 @@ public final class {{class}} {
{%- endfor %}

// Enum definitions
{%- for attribute in attributes | unique(attribute="fqn") %}
{%- 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) %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ public final class ResourceAttributes {
stringKey("cloud.availability_zone");

/**
* The cloud infrastructure resource in use.
* The cloud platform in use.
*
* <p>Note: The prefix of the service SHOULD match the one specified in `cloud.provider`.
*/
public static final AttributeKey<String> CLOUD_INFRASTRUCTURE_SERVICE =
stringKey("cloud.infrastructure_service");
public static final AttributeKey<String> CLOUD_PLATFORM = stringKey("cloud.platform");

/**
* The Amazon Resource Name (ARN) of an [ECS container
Expand Down Expand Up @@ -77,6 +76,10 @@ public final class ResourceAttributes {
/** The task definition family this task definition is a member of. */
public static final AttributeKey<String> AWS_ECS_TASK_FAMILY = stringKey("aws.ecs.task.family");

/** The revision for this task definition. */
public static final AttributeKey<String> AWS_ECS_TASK_REVISION =
stringKey("aws.ecs.task.revision");

/** The ARN of an EKS cluster. */
public static final AttributeKey<String> AWS_EKS_CLUSTER_ARN = stringKey("aws.eks.cluster.arn");

Expand Down Expand Up @@ -381,6 +384,16 @@ public final class ResourceAttributes {
public static final AttributeKey<String> TELEMETRY_AUTO_VERSION =
stringKey("telemetry.auto.version");

/** The name of the web engine. */
public static final AttributeKey<String> WEBENGINE_NAME = stringKey("webengine.name");

/** The version of the web engine. */
public static final AttributeKey<String> WEBENGINE_VERSION = stringKey("webengine.version");

/** Additional description of the web engine (e.g. detailed version and edition information). */
public static final AttributeKey<String> WEBENGINE_DESCRIPTION =
stringKey("webengine.description");

// Enum definitions
public static final class CloudProviderValues {
/** Amazon Web Services. */
Expand All @@ -393,7 +406,7 @@ public static final class CloudProviderValues {
private CloudProviderValues() {}
}

public static final class CloudInfrastructureServiceValues {
public static final class CloudPlatformValues {
/** AWS Elastic Compute Cloud. */
public static final String AWS_EC2 = "aws_ec2";
/** AWS Elastic Container Service. */
Expand Down Expand Up @@ -425,7 +438,7 @@ public static final class CloudInfrastructureServiceValues {
/** Google Cloud App Engine (GAE). */
public static final String GCP_APPENGINE = "gcp_app_engine";

private CloudInfrastructureServiceValues() {}
private CloudPlatformValues() {}
}

public static final class AwsEcsLaunchtypeValues {
Expand Down
Loading

0 comments on commit c28d17a

Please sign in to comment.