-
Notifications
You must be signed in to change notification settings - Fork 858
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
Automatically generate Semantic Convention attributes #1846
Automatically generate Semantic Convention attributes #1846
Conversation
This comment has been minimized.
This comment has been minimized.
There is no event in YAML right now. The only event is defined by Exception SemConv and it is just a text line. If it would have been defined in the YAML defs it would appear in the generated class! EDIT: event attributes are defined as span attributes though |
|
||
import io.opentelemetry.common.AttributeKey; | ||
|
||
// DO NOT EDIT, this is an Auto-generated file from /templates/SemanticAttributesV2.java.j2 |
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 think it should be relatively straightforward to generate this in gradle using e.g. https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Exec.html. Then we would not have to check in this file.
On the minus side, we would then require contributors to have a recent Python 3 installed (actually Docker currently which makes it un-buildable on Windows 🤔).
If we don't auto-generate the file, we should check during build that the file matches the generated output (does the tool support that for any generator currently or only markdown?)
semantic_convention/generate.sh
Outdated
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
rm -rf opentelemetry-specification || true | ||
git clone https://github.com/open-telemetry/opentelemetry-specification.git --depth 1 |
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.
We should pin this to a certain commit, or check out a release branch to have a latest 0.x version at least.
This comment has been minimized.
This comment has been minimized.
Codecov Report
@@ Coverage Diff @@
## master #1846 +/- ##
============================================
- Coverage 85.69% 85.64% -0.05%
- Complexity 1434 1532 +98
============================================
Files 174 175 +1
Lines 5556 6066 +510
Branches 579 678 +99
============================================
+ Hits 4761 5195 +434
- Misses 597 658 +61
- Partials 198 213 +15
Continue to review full report at Codecov.
|
I think this is outside the scope of this PR. I have opened open-telemetry/build-tools#17 for tracking this. |
Of course this is outside the scope of this PR 😃 But since you mentioned that you will work around this in the description, I brought it up. |
|
Thanks @thisthat! Do you think enum is useful for "db.system" values (over string constants), since we can't enforce enum usage since it's a non-exhaustive list? |
@trask I opted for an enum for simplicity of the template. The strings can be retrieved via @jkwatson I tend to agree with you. I'll refactor the code and remove the V2 as part of this PR then :) |
Ya, the enum makes it look like an exhaustive list, so I'd probably opt not to use enum in this case 👍 |
{%- elif type == "boolean" -%} | ||
boolean | ||
{%- elif type == "number" -%} | ||
long |
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.
double?
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.
Please see open-telemetry/build-tools#13
BTW, regarding EXCEPTION_EVENT_NAME: We could write that literally in the template for now. |
yeah, adding a couple of custom pre-specced items to the template itself seems like a fine approach to me. |
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.
Thanks!
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.
This is great, thanks
Fixes #1841. I am suffixing this class with
V2
becauseEXCEPTION_EVENT_NAME
is not part of the YAML definitions. I will follow up by refactoring the code and moving that constant somewhere.Does this solve your issue @trask? Or do you prefer having a new class for just the enum values?
For your example, the enum is available here: https://github.com/open-telemetry/opentelemetry-java/pull/1846/files#diff-50fb78fbdb13d122ada839fd124b2beffec95fe51107c23cffc9a5e48ca3e4ceR714
As future work, I am leaving the definition of the proper workflow to follow. ATM, I have the following in mind:
generate.sh
script provided within this PRmaster
in otel-spec updates a YAML file