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

Migrate collector semconv codegen to weaver #11064

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Update docs.
  • Loading branch information
jsuereth committed Sep 6, 2024
commit 336900929336f5785bcb1d992aac9a6ec4942c6b
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ WEAVER_CONTAINER=otel/weaver:v0.9.1
# Generate semantic convention constants. Requires a clone of the opentelemetry-specification repo
gensemconv: $(SEMCONVKIT)
@[ "${SPECTAG}" ] || ( echo ">> env var SPECTAG is not set"; exit 1 )
@echo "Generating semantic convention constants from specification version ${SPECTAG} at ${SPECPATH}"
@echo "Generating semantic convention constants from specification version ${SPECTAG} at https://github.com/open-telemetry/semantic-conventions.git@${SPECTAG}"
# Ensure the target directory for source code is available.
mkdir -p $(PWD)/semconv/${SPECTAG}
# Note: We mount a home directory for downloading/storing the semconv repository.
Expand Down
31 changes: 24 additions & 7 deletions semconv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,31 @@ from definitions in the specification.

## Generation

To generate the constants you can use the `gensemconv` make target. You must provide the path to the root of a clone of
the `semantic-conventions` repository in the `SPECPATH` variable and the version of the conventions to generate
To generate the constants you can use the `gensemconv` make target. You must provide the version of the conventions to generate
in the `SPECTAG` variable.

```console
$ make gensemconv SPECPATH=/tmp/semantic-conventions SPECTAG=v1.22.0
Generating semantic convention constants from specification version v1.22.0 at /tmp/semantic-conventions
.tools/semconvgen -o semconv/v1.22.0 -t semconv/template.j2 -s v1.22.0 -i /tmp/semantic-conventions/model/. --only=resource -p conventionType=resource -f generated_resource.go
.tools/semconvgen -o semconv/v1.22.0 -t semconv/template.j2 -s v1.22.0 -i /tmp/semantic-conventions/model/. --only=event -p conventionType=event -f generated_event.go
.tools/semconvgen -o semconv/v1.22.0 -t semconv/template.j2 -s v1.22.0 -i /tmp/semantic-conventions/model/. --only=span -p conventionType=trace -f generated_trace.go
$ make gensemconv SPECTAG=v1.22.0
Generating semantic convention constants from specification version v1.27.0 at https://github.com/open-telemetry/semantic-conventions.git@v1.27.0
mkdir -p /home/joshuasuereth/src/open-telemetry/opentelemetry-collector/semconv/v1.27.0
mkdir -p ~/.weaver
docker run --rm \
-u 110055:89939 \
--env HOME=/tmp/weaver \
--mount 'type=bind,source=/home/joshuasuereth/src/open-telemetry/opentelemetry-collector/semconv/weaver,target=/home/weaver/templates,readonly' \
--mount 'type=bind,source=/home/joshuasuereth/.weaver,target=/tmp/weaver/.weaver' \
--mount 'type=bind,source=/home/joshuasuereth/src/open-telemetry/opentelemetry-collector/semconv/v1.27.0,target=/home/weaver/target' \
otel/weaver:v0.9.1 registry generate \
--registry=https://github.com/open-telemetry/semantic-conventions.git@v1.27.0#model \
--templates=/home/weaver/templates \
collector \
/home/weaver/target
✔ `main` semconv registry `https://github.com/open-telemetry/semantic-conventions.git@v1.27.0#model[model]` loaded (160 files)
✔ No `before_resolution` policy violation
✔ `default` semconv registry resolved
✔ Generated file "/home/weaver/target/generated_resource.go"
✔ Generated file "/home/weaver/target/generated_event.go"
✔ Generated file "/home/weaver/target/generated_trace.go"
✔ Generated file "/home/weaver/target/generated_attribute_group.go"
✔ Artifacts generated successfully
```
Loading