-
Notifications
You must be signed in to change notification settings - Fork 54
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
Semantic convention generator #5
Semantic convention generator #5
Conversation
@open-telemetry/python-approvers I would like if one of you can review this since I am not that experienced with Python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't look too deeply into all of the code, it would be great if someone else could also take a look.
I left the same comment on the spec PR (open-telemetry/opentelemetry-specification#571 (comment)), but I am wondering how this will be extended to metric and resource semantic conventions.
A lot of the code/types will be very similar (like attributes to metric labels), but its not clear to me how easy it will be to generalize this to other semantic conventions. Specifically SemanticConvention
has class properties that are very specific to spans, and the code generation and markdown table generation don't look reusable yet.
semantic-conventions/src/dynatrace/semconv/templating/markdown.py
Outdated
Show resolved
Hide resolved
semantic-conventions/src/dynatrace/semconv/templating/markdown.py
Outdated
Show resolved
Hide resolved
self.enums.append(attr) | ||
|
||
|
||
class MarkdownRenderer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of complex string building in here. Would it be cleaner in a Jinja template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are using a markdown linter in the spec repository, I preferred building the string via code to have better control over newlines and spaces. I agree that this could be done using Jinja templates. However, I believe it will just push the complexity from the code to the template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed we had that discussion internally, but usually the more complicated the string building, the less it profits from a Jinja template, which is fine for building large but more or less simple strings. Just imagine how many nesting levels or macros you would have.
semantic-conventions/src/dynatrace/semconv/model/semantic_attribute.py
Outdated
Show resolved
Hide resolved
semantic-conventions/src/dynatrace/semconv/model/semantic_convention.py
Outdated
Show resolved
Hide resolved
@aabmass thank you for your review :) I have addressed your comments beside the one that I left it unresolved.
As was already said in the spec issue, at Dynatrace we are using the current model for both, resource and span semantic conventions. We did not yet look into metrics, so the model might require some changes to support this part of OTel.
It is not clear to me what do you consider not reusable yet. The markdown part is tailored for out linter and style used in the specification repository. The code generator uses Jinja templates so any language could use its implementation. This part was already used in the java-instrumentation to generate Typed Spans: open-telemetry/opentelemetry-java-instrumentation#502 |
I see now the CLI args are flexible, understood :)
Awesome, I was thinking it would be mostly compatible. Some things I noticed (which I could definitely be wrong about):
Maybe it would be useful to add a
|
Thank you for noticing the error. I will update the other PR fixing it. This field is optional and will not print any warning. It is already relaxed to support resources :) Regarding metrics and the split into groups, I agree with your comment and thank you for the feedback :) I would provide a follow-up PR to support Resources and Metrics as first-class citizens. |
@aabmass if python looks good please approve :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There's lot of code, so it would be great if someone else could also review the python, maybe @open-telemetry/python-approvers
Will merge this to unblock the specs |
Ported the code from open-telemetry/opentelemetry-specification#571 into a docker image that is published to docker-hub with the name
otel/semconvgen
. This image will be later used to automatically generate tables for OpenTelemetry-specifications and code for the different languages.