Skip to content
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

fix: make trace_id visible only if in use #359

Merged
merged 2 commits into from
Oct 18, 2022
Merged

Conversation

Arqu
Copy link
Collaborator

@Arqu Arqu commented Oct 17, 2022

No description provided.

@Arqu Arqu added this to the v0.1.0 milestone Oct 17, 2022
@Arqu Arqu requested review from dignifiedquire and b5 October 17, 2022 20:35
@Arqu Arqu self-assigned this Oct 17, 2022
rklaehn
rklaehn previously approved these changes Oct 18, 2022
Copy link
Contributor

@rklaehn rklaehn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine. Just added some questions.

HeaderValue::from_str(&self.trace_id).unwrap(),
);
let has_trace_id =
!self.trace_id.is_empty() && self.trace_id != "00000000000000000000000000000000";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why is this a string? We don't want to expose the TraceId type from OpenTelemetry?

It seems that TraceId has a public API to convert it to and from [u8; 16]. Maybe use that for traceid? Then we don't have to do string comparisons here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only reason was not to pull opentelemetry directly into iroh-gateway cause at some point we wanted to have metrics be a compile time toggle. I guess no hard reason right now. And the dep can be bound to the feature anyways.

I'll fix it up before merge.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we still have the dependency anyways so duh...
Nice catch ty.

"message": self.message,
"trace_id": self.trace_id,
}));
let body = match has_trace_id {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a match instead of a if? Does clippy allow that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I look at it it is a bit odd for a boolean flag (was something else before though) and idk I just got used to the match magic :)

But yeah clippy is happy with it. 📎

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not wrong, and also not difficult to read, just unusual. So 🤷‍♂️

@Arqu Arqu merged commit c29bf85 into main Oct 18, 2022
@Arqu Arqu deleted the arqu/optional_trace_id branch October 18, 2022 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants