Skip to content

Commit

Permalink
amend metrics examples
Browse files Browse the repository at this point in the history
Signed-off-by: inge4pres <[email protected]>
  • Loading branch information
inge4pres committed Feb 13, 2025
1 parent 1ea29b4 commit 5146049
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
5 changes: 2 additions & 3 deletions examples/metrics/basic.zig
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ pub fn main() !void {
var in_mem = try sdk.InMemoryExporter.init(fba.allocator());

// Create an exporter and a a metric reader to aggregate the metrics
const exporter = try sdk.MetricExporter.new(fba.allocator(), &in_mem.exporter);
const mr = try sdk.MetricReader.init(fba.allocator(), exporter);
const mr = try sdk.MetricReader.init(fba.allocator(), &in_mem.exporter);
defer mr.shutdown();

// Register the metric reader to the meter provider
Expand All @@ -40,7 +39,7 @@ pub fn main() !void {

// Print the metrics
const stored_metrics = try in_mem.fetch();
defer stored_metrics.deinit();
defer fba.allocator().free(stored_metrics);

std.debug.print("metric: {any}\n", .{stored_metrics});
}
5 changes: 1 addition & 4 deletions examples/metrics/http_server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ fn setupTelemetry(allocator: std.mem.Allocator) !OTel {
var in_mem = try sdk.InMemoryExporter.init(allocator);
errdefer in_mem.deinit();

const exporter = try sdk.MetricExporter.new(allocator, &in_mem.exporter);
errdefer exporter.shutdown();

const mr = try sdk.MetricReader.init(allocator, exporter);
const mr = try sdk.MetricReader.init(allocator, &in_mem.exporter);

try mp.addReader(mr);

Expand Down
2 changes: 1 addition & 1 deletion src/sdk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test {
pub const MeterProvider = @import("api/metrics/meter.zig").MeterProvider;
pub const MetricReader = @import("sdk/metrics/reader.zig").MetricReader;
pub const MetricExporter = @import("sdk/metrics/exporter.zig").MetricExporter;
pub const InMemoryExporter = @import("sdk/metrics/exporter.zig").ImMemoryExporter;
pub const InMemoryExporter = @import("sdk/metrics/exporter.zig").InMemoryExporter;

pub const Counter = @import("api/metrics/instrument.zig").Counter;
pub const UpDownCounter = @import("api/metrics/instrument.zig").Counter;
Expand Down

0 comments on commit 5146049

Please sign in to comment.