-
-
Notifications
You must be signed in to change notification settings - Fork 1
debug statements #45
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
base: main
Are you sure you want to change the base?
debug statements #45
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,19 +41,22 @@ pub const HttpTransport = struct { | |
| } | ||
|
|
||
| pub fn send(self: *HttpTransport, envelope: SentryEnvelope) !TransportResult { | ||
| std.debug.print("sending envelope", .{}); | ||
| const payload = try self.envelopeToPayload(envelope); | ||
| defer self.allocator.free(payload); | ||
|
|
||
| // Check if DSN is configured | ||
| const dsn = self.options.dsn orelse { | ||
| return TransportResult{ .response_code = 0 }; | ||
| }; | ||
| std.debug.print("dsn: {s}", .{dsn}); | ||
|
|
||
| // Construct the Sentry envelope endpoint URL | ||
| const netloc = dsn.getNetloc(self.allocator) catch { | ||
| return TransportResult{ .response_code = 0 }; | ||
| }; | ||
| defer self.allocator.free(netloc); | ||
| std.debug.print("netloc: {s}", .{netloc}); | ||
|
|
||
| const endpoint_url = std.fmt.allocPrint(self.allocator, "{s}://{s}/api/{s}/envelope/", .{ | ||
| dsn.scheme, | ||
|
|
@@ -63,11 +66,13 @@ pub const HttpTransport = struct { | |
| return TransportResult{ .response_code = 0 }; | ||
| }; | ||
| defer self.allocator.free(endpoint_url); | ||
| std.debug.print("endpoint_url: {s}", .{endpoint_url}); | ||
|
|
||
| // Parse the URL and make the HTTP request | ||
| const uri = std.Uri.parse(endpoint_url) catch { | ||
| return TransportResult{ .response_code = 0 }; | ||
| }; | ||
| std.debug.print("uri: {s}", .{uri}); | ||
|
|
||
| // Construct the auth header | ||
| const auth_header = std.fmt.allocPrint(self.allocator, "Sentry sentry_version=7,sentry_key={s},sentry_client=sentry-zig/0.1.0", .{ | ||
|
|
@@ -76,19 +81,23 @@ pub const HttpTransport = struct { | |
| return TransportResult{ .response_code = 0 }; | ||
| }; | ||
| defer self.allocator.free(auth_header); | ||
| std.debug.print("auth_header: {s}", .{auth_header}); | ||
|
|
||
| // Create Content-Length header value | ||
| const content_length = std.fmt.allocPrint(self.allocator, "{d}", .{payload.len}) catch { | ||
| return TransportResult{ .response_code = 0 }; | ||
| }; | ||
| defer self.allocator.free(content_length); | ||
| std.debug.print("content_length: {s}", .{content_length}); | ||
|
|
||
| const headers = [_]std.http.Header{ | ||
| .{ .name = "Content-Type", .value = "application/x-sentry-envelope" }, | ||
| .{ .name = "Content-Length", .value = content_length }, | ||
| .{ .name = "X-Sentry-Auth", .value = auth_header }, | ||
| }; | ||
|
|
||
| std.debug.print("headers: {any}", .{headers}); | ||
|
|
||
| var response_body = std.ArrayList(u8).init(self.allocator); | ||
| defer response_body.deinit(); | ||
|
|
||
|
|
@@ -135,9 +144,12 @@ pub const HttpTransport = struct { | |
| var list = std.ArrayList(u8).init(self.allocator); | ||
| errdefer list.deinit(); | ||
|
|
||
| std.debug.print("stringifying event"); | ||
|
|
||
| try std.json.stringify(event, .{}, list.writer()); | ||
|
|
||
| const data = try list.toOwnedSlice(); | ||
| std.debug.print("Creating envelope item"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential bug: Two `std.debug.print` calls are missing the required empty tuple argument `.{}` which will cause a compilation error.
Did we get this right? 👍 / 👎 to inform future reviews. |
||
| return SentryEnvelopeItem{ | ||
| .header = .{ | ||
| .type = .event, | ||
|
|
||
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.
Potential bug: `std.debug.print` calls use the `{s}` specifier for `Dsn` and `Uri` structs, which will cause a compilation error as `{s}` requires a string.
Description: The
std.debug.printcalls atsrc/transport.zig:52andsrc/transport.zig:75attempt to print thedsnanduristructs using the{s}format specifier. In Zig,{s}is strictly for string types ([]const u8). Since neither theDsnnorstd.Uristructs implement a customformatmethod to handle this, the compiler will raise a type mismatch error. This bug will prevent the project from compiling, blocking any testing or deployment of the new transport functionality.Suggested fix: Replace the
{s}format specifier with{}to use the default struct formatting forstd.debug.print. For example, changestd.debug.print("dsn: {s}", .{dsn});tostd.debug.print("dsn: {}", .{dsn});.severity: 0.9, confidence: 0.95
Did we get this right? 👍 / 👎 to inform future reviews.