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

Collisions: manual conflict resolution #76

Closed
wants to merge 8 commits into from
Closed
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
14 changes: 10 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,32 @@ fun generateTask(taskName: String, incubating: Boolean) {
val outputDir = if (incubating) "semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/" else "semconv/src/main/java/io/opentelemetry/semconv/"
val packageNameArg = if (incubating) "io.opentelemetry.semconv.incubating" else "io.opentelemetry.semconv"
val stablePackageNameArg = if (incubating) "io.opentelemetry.semconv" else ""
val excludedNamespaces = """[\"ios\",\"aspnetcore\",\"signalr\"]"""
val nameMapping = """{\"http.request.method\":\"http.request.method_new\"}"""
val excludedAttributes = """[\"http.flavor\"]"""
Comment on lines +90 to +91
Copy link
Member

Choose a reason for hiding this comment

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

👍


setArgs(listOf(
"run",
"--rm",
"-v", "$buildDir/semantic-conventions-${semanticConventionsVersion}/model:/source",
"-v", "$projectDir/buildscripts/templates:/templates",
"-v", "$projectDir/$outputDir:/output",
"otel/semconvgen:$generatorVersion",
"semconvgen7",
"--yaml-root", "/source",
"--continue-on-validation-errors", "compatibility",
"--continue-on-validation-errors",
"code",
"--template", "/templates/SemanticAttributes.java.j2",
"--output", "/output/{{pascal_prefix}}${classPrefix}Attributes.java",
"--file-per-group", "root_namespace",
// Space delimited list of root namespaces to excluded (i.e. "foo bar")
"-Dexcluded_namespaces=\"ios aspnetcore signalr\"",
"-Dexcluded_namespaces=${excludedNamespaces}",
"-Dfilter=${filter}",
"-DclassPrefix=${classPrefix}",
"-Dpkg=$packageNameArg",
"-DstablePkg=$stablePackageNameArg"))
"-DstablePkg=$stablePackageNameArg",
"-Dname_map=${nameMapping}",
"-Dexcluded_attributes=${excludedAttributes}"
))
}
}

Expand Down
23 changes: 13 additions & 10 deletions buildscripts/templates/SemanticAttributes.java.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@
{%- macro stable_class_ref(const_name, separator) -%}
{{stablePkg}}.{{ root_namespace | to_camelcase(True) }}Attributes{{separator}}{{const_name}}
{%- endmacro %}
{%- macro map_name(fqn) -%}
{%- if filter == 'any' and (fqn in name_map) -%}{{ name_map[fqn]}}{%- else -%}{{fqn}}{%- endif -%}
{%- endmacro -%}
{%- if filter != 'any' %}
{%- set filtered_attributes = attributes_and_templates | select(filter) | list %}
{%- set filtered_attributes = attributes_and_templates | rejectattr("fqn", "in", excluded_attributes) | select(filter) | list %}
{%- else %}
{%- set filtered_attributes = attributes_and_templates | list %}
{%- set filtered_attributes = attributes_and_templates | rejectattr("fqn", "in", excluded_attributes) | list %}
{%- endif %}
{%- set filtered_enums = filtered_attributes | selectattr('is_enum', 'equalto', true) | list %}
{%- set excluded_namespaces_list = excluded_namespaces.replace("\"", "").split(' ') %}
{%- if root_namespace not in excluded_namespaces_list and filtered_attributes | count > 0 %}
{%- if root_namespace not in excluded_namespaces and filtered_attributes | count > 0 %}
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
Expand All @@ -64,7 +66,7 @@ import java.util.List;
public final class {{ root_namespace | to_camelcase(True) }}{{ classPrefix }}Attributes {
{%- for attribute in filtered_attributes %}

{% set attribute_const_name = attribute.fqn | to_const_name -%}
{% set attribute_const_name = map_name(attribute.fqn) | to_const_name -%}
/**
* {{attribute.brief | render_markdown(code="{{@code {0}}}", paragraph="{0}")}}
{%- if attribute.note %}
Expand All @@ -79,7 +81,7 @@ public final class {{ root_namespace | to_camelcase(True) }}{{ classPrefix }}Att
{%- 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.fqn | to_const_name, '#')}}} attribute.
{%- endif %}
*/
{%- if attribute | is_deprecated or attribute | is_stable and stablePkg != "" %}
Expand All @@ -96,15 +98,16 @@ public final class {{ root_namespace | to_camelcase(True) }}{{ classPrefix }}Att
// Enum definitions
{%- endif %}
{%- for enum_attribute in filtered_enums %}
{%- set class_name = enum_attribute.fqn | to_camelcase(True) ~ "Values" %}
{%- set attribute_const_name = map_name(enum_attribute.fqn) | to_const_name -%}
{%- set class_name = (map_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 }}}.
* Values for {@link #{{ attribute_const_name | 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.
* @deprecated deprecated in favor of stable {@link {{stable_class_ref(enum_attribute.fqn | to_camelcase(True) ~ "Values", '.')}}} attribute.
{%- endif %}
*/
{%- if enum_attribute | is_deprecated or enum_attribute | is_stable and stablePkg != "" %}
Expand All @@ -113,7 +116,7 @@ public final class {{ root_namespace | to_camelcase(True) }}{{ classPrefix }}Att
public static final class {{class_name}} {
{%- 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 }} = {{ enum_attribute | print_member_value(member) }};
public static final {{ type }} {{ map_name(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 @@ -22,13 +22,6 @@ public final class HttpIncubatingAttributes {
public static final AttributeKey<String> HTTP_CONNECTION_STATE =
stringKey("http.connection.state");

/**
* Deprecated, use {@code network.protocol.name} instead.
*
* @deprecated Deprecated, use `network.protocol.name` instead.
*/
@Deprecated public static final AttributeKey<String> HTTP_FLAVOR = stringKey("http.flavor");

/**
* Deprecated, use {@code http.request.method} instead.
*
Expand Down Expand Up @@ -97,7 +90,8 @@ public final class HttpIncubatingAttributes {
* io.opentelemetry.semconv.HttpAttributes#HTTP_REQUEST_METHOD} attribute.
*/
@Deprecated
public static final AttributeKey<String> HTTP_REQUEST_METHOD = stringKey("http.request.method");
public static final AttributeKey<String> HTTP_REQUEST_METHOD_NEW =
stringKey("http.request.method");

/**
* Original HTTP method sent by the client in the request line.
Expand Down Expand Up @@ -268,41 +262,13 @@ private HttpConnectionStateValues() {}
}

/**
* Values for {@link #HTTP_FLAVOR}.
*
* @deprecated Deprecated, use `network.protocol.name` instead.
*/
@Deprecated
public static final class HttpFlavorValues {
/** HTTP/1.0. */
public static final String HTTP_1_0 = "1.0";

/** HTTP/1.1. */
public static final String HTTP_1_1 = "1.1";

/** HTTP/2. */
public static final String HTTP_2_0 = "2.0";

/** HTTP/3. */
public static final String HTTP_3_0 = "3.0";

/** SPDY protocol. */
public static final String SPDY = "SPDY";

/** QUIC protocol. */
public static final String QUIC = "QUIC";

private HttpFlavorValues() {}
}

/**
* Values for {@link #HTTP_REQUEST_METHOD}.
* Values for {@link #HTTP_REQUEST_METHOD_NEW}.
*
* @deprecated deprecated in favor of stable {@link
* io.opentelemetry.semconv.HttpAttributes.HttpRequestMethodValues} attribute.
*/
@Deprecated
public static final class HttpRequestMethodValues {
public static final class HttpRequestMethodNewValues {
/** CONNECT method. */
public static final String CONNECT = "CONNECT";

Expand Down Expand Up @@ -333,7 +299,7 @@ public static final class HttpRequestMethodValues {
/** Any HTTP method that the instrumentation has no prior knowledge of. */
public static final String OTHER = "_OTHER";

private HttpRequestMethodValues() {}
private HttpRequestMethodNewValues() {}
}

private HttpIncubatingAttributes() {}
Expand Down
Loading