build-tools
build-tools copied to clipboard
Semconv code generator example does not work for opentelemetry-specifications 1.14.0
Repo opentelemetry-cpp successfully used the semconv code generator already on 1.13.0 specs. See the generate script used:
Now trying to upgrade to 1.14.0 opentelemetry-specification:
SEMCONV_VERSION=1.14.0
The build fails with this error message:
opentelemetry.semconv.model.exceptions.ValidationError: Semantic Convention trace-exception reference `exception.type` but it cannot be found! - @2:5
In the 1.14.0 specs, indeed, file
semantic_conventions/trace/trace-exception.yaml
uses the exception defined in
semantic_conventions/exception.yaml
Because the docker mount point used is semantic_conventions/trace/
,
the docker image does not see file exceptions.yaml
docker run --rm \
-v ${SCRIPT_DIR}/opentelemetry-specification/semantic_conventions/trace:/source \
...
I hope this helps to narrow down the root cause. No idea about a fix however.
Please fix and adjust the example to work with the latest semantic conventions from the specs, as this is needed for each language SIG in general.
[resolved] Blocking for open-telemetry/opentelemetry-cpp#1671
Have you tried just running it over everything, i.e. -v ${SCRIPT_DIR}/opentelemetry-specification/semantic_conventions
without /trace
?
If you only want span conventions, I think you can use the --only span
cmdline option (https://github.com/open-telemetry/build-tools/blob/main/semantic-conventions/src/opentelemetry/semconv/main.py#L211-L215)
Thanks @Oberon00
Adjusted the generation script to:
docker run --rm \
-v ${SCRIPT_DIR}/opentelemetry-specification/semantic_conventions:/source \
-v ${SCRIPT_DIR}/templates:/templates \
-v ${ROOT_DIR}/api/include/opentelemetry/trace/:/output \
otel/semconvgen:$GENERATOR_VERSION \
--only span \
-f /source code \
--template /templates/SemanticAttributes.h.j2 \
--output /output/semantic_conventions.h \
-Dsemconv=trace \
-Dclass=SemanticConventions \
-DschemaUrl=$SCHEMA_URL \
-Dnamespace_open="namespace trace {" \
-Dnamespace_close="}"
and this now works for opentelemetry-cpp with 1.14.0 specs.
--only span
ends up removing attributes that are marked as type: event. Is there a way to get event and span types, without pulling in resource attributes?
--only span
ends up removing attributes that are marked as type: event. Is there a way to get event and span types, without pulling in resource attributes?
See https://github.com/open-telemetry/opentelemetry-java/pull/4938 for an example of what isn't working right.
This is also happening in opentelemetry-dotnet when trying to update from semconv 1.13 to 1.17 when using generator versions 0.14.0, 0.15.0, and 0.15.1. Adding --only span
didn't seem to work (I was still getting unexpected event.*
attributes in the trace constants) but adding a mount for exception.yaml made the error go away.
docker run --rm `
-v ${SCRIPT_DIR}/opentelemetry-specification/semantic_conventions/trace:/source `
+ -v ${SCRIPT_DIR}/opentelemetry-specification/semantic_conventions/exception.yaml:/source/exception.yaml `
-v ${SCRIPT_DIR}/templates:/templates `
-v ${ROOT_DIR}/Trace:/output `
otel/semconvgen:$GENERATOR_VERSION
The result included some unexpected (to me) changes though.
See https://github.com/open-telemetry/opentelemetry-dotnet/pull/4102
Is this still a concern?
@Oberon00
Hi Christian,
As indicated on Oct 18, 2022, I was able to fix the opentelemetry-cpp generation scripts to make this work.
The documentation, however, was never updated, so yes, the instructions from the documentation do not work, which was the problem originally reported, and is still a concern.
Given that semantic conventions have migrated to their own repository, I would suggest to wait on the first release there, and then update the documentation with working instructions.
This will help every language repositories to adjust code generation scripts to the new code layout.
Related:
- https://github.com/open-telemetry/semantic-conventions/issues/136
- https://github.com/open-telemetry/semantic-conventions/issues/37
obsolete