-
Notifications
You must be signed in to change notification settings - Fork 516
feat(opentelemetry-sdk): add a constructor for SpanEvents and SpanLinks #2934
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?
feat(opentelemetry-sdk): add a constructor for SpanEvents and SpanLinks #2934
Conversation
# Changes Add public constructors on SpanEvents and SpanLinks structs. # Motivation Even though all fields are public, because of the `#[non_exhaustive]` annotation on `SpanEvents`and `SpanLinks`, it's not possible to construct instances of these outside of the `opentelemetry-sdk` crate. Since they are used in `export::SpanData`, it is problematic because it means there is no way to create span data containing any events or span links. So there is no way to write tests on how to these fields are processed in external crate that implement the SpanExporter or SpanProcessor traits.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2934 +/- ##
=======================================
- Coverage 81.3% 81.3% -0.1%
=======================================
Files 126 126
Lines 24254 24266 +12
=======================================
Hits 19736 19736
- Misses 4518 4530 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@@ -31,6 +31,14 @@ impl IntoIterator for SpanLinks { | |||
} | |||
|
|||
impl SpanLinks { | |||
/// Create a new `SpanLinks` from a list of events and a dropped count |
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.
is it only required for tests?
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.
No, I need it for tests, but there are definitely wider use cases.
For instance you could imagine span processors or span exporters trying to create "synthetic spans" and put span links and span events on these synthetic spans.
This currently doesn't work, and I can't think of a good rational as to why creating SpanData without span events should not be possible, and not with them.
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.
This currently doesn't work, and I can't think of a good rational as to why creating SpanData without span events should not be possible, and not with them.
It feels like there is one too many negations here. I assume you're saying that if it's possible to create SpanData
without SpanLinks
and SpanEvents
, then it should be possible to create SpanData
with them.
Even though all fields are public, because of the
#[non_exhaustive]
annotation onSpanEvents
andSpanLinks
, it's not possible to construct instances of these outside of theopentelemetry-sdk
crate.Since they are used in
export::SpanData
, it is problematic because it means there is no way to create span data containing any events or span links. So there is no way to write tests on how to these fields are processed in external crate that implement the SpanExporter or SpanProcessor traits.Changes
Add public constructors on SpanEvents and SpanLinks structs.
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes