Skip to content

build: refactor, allow importing the package as a dependency #59

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

Merged
merged 6 commits into from
May 28, 2025

Conversation

inge4pres
Copy link
Collaborator

Reason for this PR

We intend to expose the package as a usable artifact for other Zig projects.

Closes #49

Details

There is a broader build.zig refactor that was needed to use proper build features.
Unrelated commit fixing a problem in the Histogram allowed value types.

Additional context

To test this out, you can zig init a new project, then

zig fetch --save https://github.com/zig-o11y/opentelemetry-sdk/archive/d285fc88d7b8cb5ca5469057d61c6e73a6fcf2b7.tar.gz

In the src/main.zig file just created, you can add calls to the OTel SDK that we now provide as a module, e.g.

...
    const mp = try otel.MeterProvider.default();
    defer mp.shutdown();

    const meter = try mp.getMeter(.{ .name = "test-meter" });
    const counter = try meter.createUpDownCounter(i64, .{
        .name = "test_counter",
        .description = "A counter for testing purposes",
    });
    const val: []const u8 = "Hello, OpenTelemetry!";
    try counter.add(1, .{ "test_key", val });

    const histogram = try meter.createHistogram(i64, .{
        .name = "test_histogram",
        .description = "A histogram for testing purposes",
    });
    try histogram.record(42, .{ "test_key", val });
...

and then run `zig build --verbose` to see it in action.

inge4pres added 6 commits May 27, 2025 10:23
Closes #49.
Other projects are now allowed to import
the SDK module via `zig fetch`.

Signed-off-by: inge4pres <[email protected]>
This commit fixes an error in the build when the package
is imported as a dependency.

Signed-off-by: inge4pres <[email protected]>
@inge4pres inge4pres merged commit 558dce9 into main May 28, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build: zig fetch fails to get the SDK module
2 participants