-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Clarify package demarcation between sdk/trace and sdk/export/trace #1380
Comments
This makes sense to me. I wondered for a bit whether the |
I would propose we just get rid of the The only benefit that I can see for having this in a separate package is that it makes it clear to the user who is going to build a SpanExporter where to find the interface. However, this does not seem like a good justification to keep this package, and it is something we can address with good documentation. This approach would imply that we would also do this for the This approach would also have the benefit of addressing #1014 @Aneurysm9 @jmacd and all other @open-telemetry/go-approvers I'm interested in your opinions on this. |
I had the same thoughts about merging the packages, but I'm bit uneasy about doing the same for |
Agreed. Looking closer at the
The metric SDK itself depends on the:
The
The
The
This all points to the fact that the metrics export package is likely in just as much of a need to be integrated with the sdk metrics package as the trace package. I think it would be worth going into detail about what would be the best way to integrate the package in a separate issue. I can create one if there is agreement that this integration is a direction we want to go in. |
This looks like a good simplification to me. I wouldn't export the SpanSnapshot and instead return a ReadOnlySpan interface from the Snapshot method, but we can talk more about that if that evolves into a full PR. |
I've pushed another commit to my WIP branch in which I've started to work in this direction. This isn't done though as we've relied heavily on the old Here are the changes I've started implementing:
We should check if we still need to maintain "readability" before we snapshot a span. If we don't, maybe |
👍
I think we need to maintain this if it is going to be passed to SpanProcessors as a ReadWriteSpan (which embeds the ReadOnlySpan interface), right? |
Latest status on my WIP: A lot of tests are currently failing and have to be refactored following the changes to One tricky bit to figure out is how to deal with auto-generated things like span IDs when running deep comparisons in tests: Until now we've used
Things left to do (possibly not exhaustive):
|
Need to resolve #1799 prior to moving to new This also makes me think we need to take a second look at if we want the |
It doesn't look like the question came up for review in #1360. Was it an attempt to share storage, where the interface is just one view or lens over a struct ( |
General
In the discussion here we consider doing a few refactoring tasks around
sdk/trace
andsdk/export/trace
(for brevity I'll refer to them astrace
andexport
, respectively):Event
fromexport
totrace
.SpanSnapshot
(currently namedSpanData
inmaster
) fromexport
totrace
.ExportSpans
method of theSpanExporter
interface to accept aReadOnlySpan
(introduced in Add RO/RW span interfaces #1360).These suggestions make a lot of sense to me. However, while looking into them I realized we need to better clarify the demarcation and relationship of
trace
andexport
, and possibly clarify the purpose ofexport
(not to be confused withexporters
) better.The problem
trace
currently depends onexport
in multiple places:opentelemetry-go/sdk/trace/batch_span_processor.go
Line 25 in 55ff277
opentelemetry-go/sdk/trace/provider.go
Line 25 in 55ff277
opentelemetry-go/sdk/trace/simple_span_processor.go
Line 21 in 55ff277
opentelemetry-go/sdk/trace/span.go
Line 29 in 55ff277
opentelemetry-go/sdk/trace/span_processor.go
Line 21 in 55ff277
We can't do the refactoring tasks above as doing so creates import cycles. After moving
Event
andSpanSnapshot
totrace
and changingExportSpans
to accept aReadOnlySpan
, we end up with the following import cycle:export
depends ontrace
becauseExportSpans
accepts aReadOnlySpan
.trace
depends onexport
in multiple places as shown above.Possible solutions
AFAICT we can do one of the following to address the problem:
export
doesn't depend ontrace
.trace
doesn't depend onexport
.Looks like option 1 isn't feasible if we want to have
ExportSpans
accept aReadOnlySpan
, assuming we want to keep theSpanExporter
interface underexport
. This seems to leave us with option 1.Option 2 seems feasible. Roughly speaking, here is what we would have to do to implement this approach:
SpanProcessor
implementations underexport
, while keeping the interface undertrace
.WithSyncer
andWithBatcher
convenience functions fromtrace
since they accept anexport.SpanExporter
and we don't wanttrace
to depend onexport
. Instead, callers useWithSpanProcessor
directly.Things to consider
Having
export
depend ontrace
follows the dependency inversion principle. Following this principle, a "high level" package doesn't depend on a "low level" package and the wiring between the packages is done using interfaces rather than concrete types. I think we already follow this approach with regards to the API/SDK relationship: The SDK (low level) depends on the API (high level) but not the other way around. Following this, perhaps it makes sense to keep using this pattern inside the SDK:trace
is arguably a higher level package thanexport
, which meansexport
depends ontrace
and theSpanProcessor
interface is defined intrace
and implemented inexport
and serves as the "contract" between the two packages.Other libraries (Java, Python) seem to be following option 2 more or less: The equivalent of
export
depends on the equivalent oftrace
but not vice versa. In the Java library,export
is even a child package oftrace
.We might want to remain consistent with the metrics-related packages in the Go library and use a similar pattern/hierarchy for both metrics and tracing. Unfortunately, right now
sdk/metric
depends onsdk/export/metric
😢Lastly, we might want to think about whether #536 is related to the problem discussed here.
TODO
Once we've settled on an approach, we should open follow up issues for the following:
Event
fromexport
totrace
.SpanSnapshot
(currently namedSpanData
inmaster
) fromexport
totrace
.ExportSpans
method of theSpanExporter
interface to accept aReadOnlySpan
(introduced in Add RO/RW span interfaces #1360).The text was updated successfully, but these errors were encountered: