feat: Update span interface to add a new function which will return span id#245
feat: Update span interface to add a new function which will return span id#245thugrock7 merged 4 commits intohypertrace:mainfrom
Conversation
| } | ||
|
|
||
| func (s *Span) GetSpanId() string { | ||
| return s.Span.SpanContext().SpanID().String() |
There was a problem hiding this comment.
do we expect this value to be not null everytime or do need to something like
if (s.Span.SpanContext().SpanID().HasSpanID()) {
s.Span.SpanContext().SpanID().String()
}
return ""
There was a problem hiding this comment.
idts, if a span doest exist, you should always be able to call this method
There was a problem hiding this comment.
this should be fine. String's null value is empty string in golang. As long as it returns a string, we dont have to check here explicitly
| func TestGetSpanID(t *testing.T) { | ||
| _, s, _ := StartSpan(context.Background(), "test_span", &sdk.SpanOptions{}) | ||
| spanId := s.GetSpanId() | ||
| if len(spanId) == 0 { |
There was a problem hiding this comment.
use assertions instead. ex: assert.Equal(t, 8, SpanIDNoOfBytes)
|
Do we really need this change here in goagent? We can simply do this in TPA if this is the route you want to go Adding it here is not really required imo |
|
Yes, functionally we can get this done using |
Fair enough, but I'm not sure which is better |
|
your inputs here @ryanericson ? |
Ah I see what @varkey98 found which is kind of equivalent. But I agree with @thugrock7, just exposing it in our SDK is cleaner and I don't see any harm. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #245 +/- ##
=======================================
Coverage ? 61.16%
=======================================
Files ? 59
Lines ? 2688
Branches ? 0
=======================================
Hits ? 1644
Misses ? 964
Partials ? 80 ☔ View full report in Codecov by Sentry. |
|
Merging this, as @stellarhuman needs to use these changes on TPA side PR and want this PR to be included in this month release. |
Description
Added a way to directly get the spanId, from the span that is created.