-
Notifications
You must be signed in to change notification settings - Fork 250
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
Improvements to Span, SpanContext and introduction of SpanId, TraceId #23
Conversation
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.
I’m not sure I understand the value of the TraceId and SpanId classes. They simply wrap integers, increasing the cost of allocating a SpanContext in the default case. Does the abstraction offer significant benefits? Does it impose unnecessary restrictions on vendor implementations?
|
||
protected | ||
|
||
attr_reader :id |
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.
Why does this need to be protected?
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.
In java implementation they implement the id as an integer but expose only the conversion methods (e.g. toLowerBase16): https://github.com/open-telemetry/opentelemetry-java/blob/master/api/src/main/java/io/opentelemetry/trace/SpanId.java . I currently did the same thing here. I used protected to be still able to compare two Ids in #==
. If we expose the integer representation of the id then it probably could use a better name (e.g. to_i)
|
||
protected | ||
|
||
attr_reader :id |
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.
Why does this need to be protected?
It allows easily to change Id internals. e.g. we could represent trace id with two integers high & low like https://github.com/open-telemetry/opentelemetry-java/blob/master/api/src/main/java/io/opentelemetry/trace/TraceId.java#L57 and still pass along one object. I think the main idea is that different actors expect different representations of the Ids. Vendors usually expect ints, but users expect base16. I as a end-user would expect to easily be able to get the base16 representation (e.g. to use it in my logs). So far it looks like java and dotnet implementations are doing the wrapping. Dotnet has I do see you're point though that this will cause an extra object allocation. I'm open to ideas. |
Research from other OTel ProjectsI took at look at opentelemetry-js and opentelemetry-python to see how they handle ID generation. Here's what I found: opentelemetry-js generates IDs using a function called /**
* Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex
* characters corresponding to 128 bits.
*/
export function randomTraceId(): string {
return randomSpanId() + randomSpanId();
}
/**
* Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex
* characters corresponding to 64 bits.
*/
export function randomSpanId(): string {
return crypto.randomBytes(SPAN_ID_BYTES).toString('hex');
} For Python, I searched through the repo and open PRs, but surprisingly couldn't find id generation code. I don't think I missed anything; I think that code has yet to be written. I can keep an eye out for when it appears for another data point though. Actual FeedbackAt the expense of an object allocation per Span, I think arguments can be made for or against the I don't have a super strong opinion on this, but in general, I would try to limit per span allocations as much as possible. In terms of introducing the |
Heavily inspired by the java api.
Heavily inspired by the java api.
Previous generate_trace_id and generate_span_id were not defined. I did not go into trace_options and tracestate yet.
Closing this as it is not relevant atm. Can be reopen in future if needed. |
No description provided.