Skip to content

Commit 2a316d5

Browse files
committed
generating resource and semantic attributes again
1 parent d540285 commit 2a316d5

File tree

6 files changed

+9736
-4783
lines changed

6 files changed

+9736
-4783
lines changed

Scripts/semantic-convention/generate.sh

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#!/bin/bash
2-
set -e
2+
set -e -x
33

44
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
55
ROOT_DIR="${SCRIPT_DIR}/../../"
66

77
# freeze the spec & generator tools versions to make SemanticAttributes generation reproducible
88

99
# repository: https://github.com/open-telemetry/semantic-conventions
10-
SEMCONV_VERSION=1.21.0
10+
SEMCONV_VERSION=1.37.0
1111
SPEC_VERSION=v$SEMCONV_VERSION
1212

1313
# repository: https://github.com/open-telemetry/build-tools
14-
GENERATOR_VERSION=0.21.0
14+
GENERATOR_VERSION=0.17.1
1515

1616
cd ${SCRIPT_DIR}
1717

@@ -25,28 +25,35 @@ git fetch origin "$SPEC_VERSION"
2525
git reset --hard FETCH_HEAD
2626
cd ${SCRIPT_DIR}
2727

28+
rm ${ROOT_DIR}/Sources/OpenTelemetryApi/Trace/SemanticAttributes.swift || true
29+
2830
docker run --rm \
2931
-v ${SCRIPT_DIR}/semantic-conventions/model:/source \
3032
-v ${SCRIPT_DIR}/templates:/templates \
31-
-v ${ROOT_DIR}/Sources/OpenTelemetryApi/Trace/:/output \
32-
otel/semconvgen:$GENERATOR_VERSION \
33-
--only span,event,attribute_group,scope \
34-
-f /source code \
35-
--template /templates/SemanticAttributes.swift.j2 \
36-
--output /output/SemanticAttributes.swift \
37-
-Dsemconv=trace \
33+
-v ${ROOT_DIR}/Sources/OpenTelemetryApi/Trace:/output \
34+
otel/weaver:v$GENERATOR_VERSION \
35+
registry \
36+
generate \
37+
--registry=/source \
38+
--templates=/templates \
39+
./ \
40+
/output \
3841
-Denum=SemanticAttributes
3942

43+
44+
rm ${ROOT_DIR}/Sources/OpenTelemetrySdk/Resources/ResourceAttributes.swift || true
45+
4046
docker run --rm \
4147
-v ${SCRIPT_DIR}/semantic-conventions/model:/source \
4248
-v ${SCRIPT_DIR}/templates:/templates \
43-
-v ${ROOT_DIR}/Sources/OpenTelemetrySdk/Resources/:/output \
44-
otel/semconvgen:$GENERATOR_VERSION \
45-
--only resource \
46-
-f /source code \
47-
--template /templates/SemanticAttributes.swift.j2 \
48-
--output /output/ResourceAttributes.swift \
49-
-Dsemconv=resource \
49+
-v ${ROOT_DIR}/Sources/OpenTelemetrySdk/Resources:/output \
50+
otel/weaver \
51+
registry \
52+
generate \
53+
--registry=/source \
54+
--templates=/templates \
55+
./ \
56+
/output \
5057
-Denum=ResourceAttributes
5158

5259
cd "$ROOT_DIR"

Scripts/templates/registry/SemanticAttributes.swift.j2 renamed to Scripts/semantic-convention/templates/registry/SemanticAttributes.swift.j2

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
{{ "\"" if type == "String"}}{{value}}{{ "\"" if type == "String"}}
2525
{%- endmacro %}
2626

27-
import Foundation
28-
{% set enum = params.enum %}
29-
public enum {{ enum }}: String {
27+
{%- set enum = params.enum -%}
3028

29+
import Foundation
3130

31+
public enum {{ enum }}: String {
3232
{% set attributes = ctx | list | map(attribute="attributes") | flatten %}
3333
{% for attribute in attributes | unique(attribute="name") %}
3434
{%- set class_name = attribute.name | pascal_case ~ "Values" %}
@@ -73,15 +73,16 @@ public enum {{ enum }}: String {
7373
*/
7474
case exception = "exception";
7575
{%- endif %}
76-
{% for attribute in attributes | unique(attribute="name") %}
76+
77+
{%- for attribute in attributes | unique(attribute="name") %}
7778
{%- set class_name = attribute.name | pascal_case ~ "Values" %}
7879
{%- set type = to_swift_return_type(attribute.type) %}
7980
{%- if attribute.is_enum %}
8081
/**
8182
{{attribute.brief | comment}}.
8283
*/
8384
/// - Tag: otel{{class_name}}
84-
{%- if attribute.attr_type.custom_values %}
85+
{%- if attribute.attr_type.custom_values %}
8586
public struct {{class_name}}: CustomStringConvertible {
8687
{%- for member in attribute.attr_type.members %}
8788
/**

Scripts/templates/registry/weaver.yaml renamed to Scripts/semantic-convention/templates/registry/weaver.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
params:
2-
excluded_namespaces: [aws, artifact, azure, cassandra, cloudevents, gen_ai, cloudfoundry, db, aspnetcore, cicd, signalr, gcp, android, dotnet, jvm, kestrel, browser, cloud, container, deployment, faas, feature_flag]
2+
excluded_namespaces: [aws, artifact, azure, rpc, cloudevents, gen_ai, cloudfoundry, aspnetcore, cicd, signalr, gcp, android, dotnet, jvm, kestrel, browser, cloud, container, deployment, faas, feature_flag]
33
comment_formats:
44
default:
55
format: markdown
@@ -16,4 +16,5 @@ templates:
1616
root_namespace: .root_namespace,
1717
attributes: .attributes,
1818
})
19+
file_name: "{{ params.enum }}.swift"
1920
application_mode: single

Sources/OpenTelemetryApi/OpenTelemetry.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Foundation
1313
/// and BaggageManager.
1414
/// The telemetry objects are lazy-loaded singletons resolved via ServiceLoader mechanism.
1515
public struct OpenTelemetry {
16-
public static var version = "v1.21.0"
16+
public static var version = "v1.37.0"
1717

1818
public static var instance = OpenTelemetry()
1919

0 commit comments

Comments
 (0)