Skip to content
Open
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
10 changes: 7 additions & 3 deletions Scripts/semantic-convention/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ROOT_DIR="${SCRIPT_DIR}/../.."
SEMCONV_VERSION=1.38.0
SPEC_VERSION=v$SEMCONV_VERSION

# repository: https://github.com/open-telemetry/build-tools
GENERATOR_VERSION=0.17.1
# repository: https://github.com/open-telemetry/weaver
GENERATOR_VERSION=0.28.0

cd ${SCRIPT_DIR}

Expand Down Expand Up @@ -42,4 +42,8 @@ cd "$ROOT_DIR"


# update spec version reported by library
sed -E -i '' 's/public static var version = ".+"/public static var version = "'$SPEC_VERSION\"/ ${ROOT_DIR}/Sources/OpenTelemetryApi/OpenTelemetry.swift
VERSION_FILE="${ROOT_DIR}/Sources/OpenTelemetryApi/OpenTelemetry.swift"
VERSION_PATTERN='public static (var|let) version = ".+"'
grep -Eq "$VERSION_PATTERN" "$VERSION_FILE" || { echo "error: no version declaration found in ${VERSION_FILE}" >&2; exit 1; }
sed -E -i.bak "s/${VERSION_PATTERN}/public static \1 version = \"${SPEC_VERSION}\"/" "$VERSION_FILE"
rm "${VERSION_FILE}.bak"
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Double
{{ template.set_file_name(filename) }}

{%- macro print_example(attribute, example) -%}
{%- set attribute_name = "SemanticConventions." + ctx.root_namespace|pascal_case + "." + attribute.name | replace(ctx.root_namespace, "") | camel_case ~ ".rawValue" -%}
{%- set attribute_name = "SemanticConventions." + ctx.root_namespace|pascal_case + "." + attribute.name | replace(ctx.root_namespace, "") | trim(".") | camel_case ~ ".rawValue" -%}
{% if attribute.type|lower == "string" or attribute.type|lower == "template[string]" -%}
attributes[{{attribute_name}}] = "{{example | replace("\"", "\\\"")}}"
{% elif attribute is enum %}
Expand Down Expand Up @@ -104,7 +104,7 @@ extension SemanticConventions {
{% if attribute.deprecated %}
@available(*, deprecated)
{% endif %}
case {{reserved_words_filter(attribute.name | replace(ctx.root_namespace, "") | camel_case)}} = "{{attribute.name}}"
case {{reserved_words_filter(attribute.name | replace(ctx.root_namespace, "") | trim(".") | camel_case)}} = "{{attribute.name}}"
{% endfor %}
{% for attribute in attributes | unique(attribute="name") %}
{% set class_name = attribute.name | replace(ctx.root_namespace, "") | pascal_case ~ "Values" %}
Expand Down
Loading