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

Update file semconv/template.j2, replace required by requirementlevel #6

Closed
wants to merge 7 commits into from

Conversation

Petrie
Copy link
Owner

@Petrie Petrie commented Aug 21, 2022

what happened

When I exec below cmd for regenerate semconv/v1.12.0

$ export TAG="v1.12.0"
$ export OTEL_SPEC_REPO="/path/to/opentelemetry-specification/"
$ git -C "$OTEL_SPEC_REPO" checkout "tags/$TAG"
$ make semconv-generate

There will be a jinja2.exceptions.UndefinedError error as follow:

Traceback (most recent call last):
  File "$HOME/cncf/opentelemetry/build-tools/semantic-conventions/src/opentelemetry/semconv/main.py", line 241, in <module>
    main()
  File "$HOME/cncf/opentelemetry/build-tools/semantic-conventions/src/opentelemetry/semconv/main.py", line 75, in main
    renderer.render(semconv, args.template, args.output, args.pattern)
  File "$HOME/cncf/opentelemetry/build-tools/semantic-conventions/src/opentelemetry/semconv/templating/code.py", line 251, in render
    template.stream(data).dump(output_file)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1618, in dump
    fp.writelines(iterable)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1613, in <genexpr>
    iterable = (x.encode(encoding, errors) for x in self)  # type: ignore
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1662, in __next__
    return self._next()  # type: ignore
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1354, in generate
    yield self.environment.handle_exception()
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "$HOME/cncf/opentelemetry/opentelemetry-go/semconv/template.j2", line 62, in top-level template code
    // {{ godoc(attr) | wordwrap | indent(3) | replace("   ", "\t// ") | replace("// //", "//") }}
  File "/usr/local/lib/python3.9/site-packages/jinja2/runtime.py", line 777, in _invoke
    rv = self._func(*arguments)
  File "$HOME/cncf/opentelemetry/opentelemetry-go/semconv/template.j2", line 19, in template
    {%- if attr.required == Required.ALWAYS %}
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 485, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'Required' is undefined

And why

This error caused by the update in PR #https://github.com/open-telemetry/build-tools/pull/92/files , Class Required is replaced by RequirementLevel .
More details https://github.com/open-telemetry/build-tools/pull/92/files#diff-f62a4dc611090cd2aee181fcd6522c010708dd98d5cf262c4f06ef61a519a25aL31

What we should do

As the attribute required was totally replaced by requirementlevel in open-telemetry/opentelemetry-specification#2594. we should update our semconv/template.j2 to adopt it.

MrAlias and others added 7 commits August 2, 2022 08:02
* Bump versions in versions.yaml

* Prepare stable-v1 for version v1.9.0

* Prepare experimental-schema for version v0.0.3

* Update changelog for release
* Add support for Go 1.19

* Update CHANGELOG.md

Co-authored-by: Sam Xie <sam@samxie.me>

Co-authored-by: Sam Xie <sam@samxie.me>
Remove 3 month timeline for backwards support of old versions of Go.
…-telemetry#3096)

* Fix opentracing.Bridge where it was not identifying the spanKinf correctly

* fix test

* changelog

* Keeping backward comppatibillity

* Update CHANGELOG.md

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>

* Update CHANGELOG.md

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
@Petrie Petrie closed this Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants