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

Semconv code generator example does not work for opentelemetry-specifications 1.14.0 #122

Open
marcalff opened this issue Oct 12, 2022 · 7 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation semconv Related to the semantic convention generator.

Comments

@marcalff
Copy link
Member

marcalff commented Oct 12, 2022

Repo opentelemetry-cpp successfully used the semconv code generator already on 1.13.0 specs.
See the generate script used:

generate.sh

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

@Oberon00
Copy link
Member

Oberon00 commented Oct 18, 2022

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)

@marcalff
Copy link
Member Author

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.

@Oberon00 Oberon00 added bug Something isn't working documentation Improvements or additions to documentation semconv Related to the semantic convention generator. labels Oct 19, 2022
@jkwatson
Copy link

--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?

@jkwatson
Copy link

--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 open-telemetry/opentelemetry-java#4938 for an example of what isn't working right.

@ttd2089
Copy link

ttd2089 commented Jan 25, 2023

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 open-telemetry/opentelemetry-dotnet#4102

@Oberon00
Copy link
Member

Is this still a concern?

@marcalff
Copy link
Member Author

@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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation semconv Related to the semantic convention generator.
Projects
Development

No branches or pull requests

4 participants