forked from open-telemetry/opentelemetry-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.sh
56 lines (44 loc) · 1.71 KB
/
generate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR="${SCRIPT_DIR}/../../"
# freeze the spec & generator tools versions to make SemanticAttributes generation reproducible
# repository: https://github.com/open-telemetry/semantic-conventions
SEMCONV_VERSION=1.21.0
SPEC_VERSION=v$SEMCONV_VERSION
# repository: https://github.com/open-telemetry/build-tools
GENERATOR_VERSION=0.21.0
cd ${SCRIPT_DIR}
rm -rf semantic-conventions || true
mkdir semantic-conventions
cd semantic-conventions
git init
git remote add origin https://github.com/open-telemetry/semantic-conventions.git
git fetch origin "$SPEC_VERSION"
git reset --hard FETCH_HEAD
cd ${SCRIPT_DIR}
docker run --rm \
-v ${SCRIPT_DIR}/semantic-conventions/model:/source \
-v ${SCRIPT_DIR}/templates:/templates \
-v ${ROOT_DIR}/Sources/OpenTelemetryApi/Trace/:/output \
otel/semconvgen:$GENERATOR_VERSION \
--only span,event,attribute_group,scope \
-f /source code \
--template /templates/SemanticAttributes.swift.j2 \
--output /output/SemanticAttributes.swift \
-Dsemconv=trace \
-Denum=SemanticAttributes
docker run --rm \
-v ${SCRIPT_DIR}/semantic-conventions/model:/source \
-v ${SCRIPT_DIR}/templates:/templates \
-v ${ROOT_DIR}/Sources/OpenTelemetrySdk/Resources/:/output \
otel/semconvgen:$GENERATOR_VERSION \
--only resource \
-f /source code \
--template /templates/SemanticAttributes.swift.j2 \
--output /output/ResourceAttributes.swift \
-Dsemconv=resource \
-Denum=ResourceAttributes
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