Skip to content

Conversation

@hendriknielaender
Copy link
Contributor

@hendriknielaender hendriknielaender commented Sep 16, 2025

This PR introduces comprehensive Zig language support for OpenTelemetry semantic conventions, utilizing weaver template registry. The implementation includes:

• Complete template system for generating Zig source files from semantic convention specifications
• All four semantic convention modules: attributes, metrics, resources and traces

@hendriknielaender
Copy link
Contributor Author

@inge4pres what do you think about this approach? Mostly transfered as well from the Rust OTel approach. I saw that you also merged another approach to generated these.

@inge4pres
Copy link
Contributor

@inge4pres what do you think about this approach? Mostly transfered as well from the Rust OTel approach. I saw that you also merged another approach to generated these.

@hendriknielaender apologies for not seeing this earlier, just figured out now you did this PR beacuse I don't have yet filters on this repo 😅

Let me have a look, my approach is completely different but it's limited to regitry and much more complex to reason about because it gnerates code with print statement, while you are suggesting to adoopt templating which seems much nicer.

I'll try it out and see the results and let you know 👍🏼

@inge4pres
Copy link
Contributor

@hendriknielaender I've had time to review the project structure, how it works and the motivations.
btw thanks so much for the contribution, much appreciated as always 🙏🏼

Here's a summary of differences with the approach I developed in the past weeks, and pros and cons that I found:

Code generation

The approach in this PR based on Weaver definitely reconnects better with the OTel ecosystem than a custom generator I wrote.
The YAML parser we currently have is also unable to parse all the flavors of comments, leaving some folders not generated.

Maintaining less code is better in this case.

Architecture

With this PR we lose the namespacing, all the attributes/entities are in a single file for all different folders.
On top of that, the attributes are treated as simple [] const u8 with their name, so we lose all the metadata such as stability level and examples that instead we get when attached to real types.

I see that all of these metadata are splatted in comments, and while this is addressing the DX in the IDE, it's not allowing for usage based on those metadata.

Summary

The proposed usage of Weaver is a good thing for the evolution of the semconv development in Zig.
I think it would be nice to steer into the direction you propose, as long as:

  • we can maintain a richer type structure that allows to get all the metadata of attributes/entities via struct fields
  • we can keep separate namespaces for each "module"
  • we can code in build.zig a step to render all (or parts of) the content from the official semconv repo

Questions:

  1. is it possible to instruct the weaver tool to generate only a subset of the convention? this would allow namespacing
  2. how difficult is it to create richer templates that can populate structs based on which input we are given?

@inge4pres
Copy link
Contributor

@hendriknielaender just so you know, I am trying to iterate on your PR to add the characteristics that i mentioned in my previous comment

hendriknielaender and others added 6 commits September 29, 2025 17:00
Signed-off-by: inge4pres <fgualazzi@gmail.com>
Signed-off-by: inge4pres <fgualazzi@gmail.com>
Signed-off-by: inge4pres <fgualazzi@gmail.com>
Signed-off-by: inge4pres <fgualazzi@gmail.com>
@inge4pres
Copy link
Contributor

I rebased and updated with the type-system goodness that we have in main branch.
take a look @hendriknielaender and let me know what you think. 🙏🏼

@hendriknielaender
Copy link
Contributor Author

I rebased and updated with the type-system goodness that we have in main branch.
take a look @hendriknielaender and let me know what you think. 🙏🏼

That looks great. 🙏 Thanks for taking care of it.

@inge4pres inge4pres changed the title feat: add OpenTelemetry semantic conventions support feat: semantic conventions via Weaver Oct 6, 2025
@inge4pres inge4pres merged commit 463406b into zig-o11y:main Oct 6, 2025
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.

2 participants