-
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
Export package #162
Export package #162
Conversation
sdk/exporter/exporter.go
Outdated
|
||
// SyncExporter is a synchronous exporter | ||
type SyncExporter interface { | ||
ExportSpan(context.Context, interface{}) |
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've added a context here, as was suggested in the examples on #77. There is never a context available when we call this method however.
This might come later, but it still seems a bit weird.
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.
keep the context for now.
sdk/exporter/exporter.go
Outdated
// | ||
// The SpanData should not be modified. | ||
type BatchExporter interface { | ||
ExportSpans(context.Context, []interface{}) |
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 both ExportSpan(s) methods, I've currently set an interface, so the exporter can take multiple span structs (depending whether we're exporting to metrics or traces). This is causing a lot of weird things when having to turn SpanData back and forth to interfaces.
Maybe the SpanData struct should be moved to this package?
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.
Thinking this through, the interface definitely seems wrong, and a metrics exporter won't be sending SpanData anyway. So I believe the struct can be moved into this package.
I'll be doing that very soon.
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 agree on moving SpanData to this package and removing interface.
sdk/exporter/exporter.go
Outdated
} | ||
|
||
// Load loads all the registered exporters matching a specific type | ||
func Load(t Type) []interface{} { |
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.
Note sure Load is the best name here. Get
might be better?
sdk/exporter/exporter.go
Outdated
// | ||
// The SpanData should not be modified. | ||
type BatchExporter interface { | ||
ExportSpans(context.Context, []interface{}) |
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 agree on moving SpanData to this package and removing interface.
sdk/exporter/exporter.go
Outdated
|
||
// SyncExporter is a synchronous exporter | ||
type SyncExporter interface { | ||
ExportSpan(context.Context, interface{}) |
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.
keep the context for now.
sdk/exporter/exporter.go
Outdated
|
||
// Register adds to the list of Exporters that will receive sampled trace | ||
// spans. | ||
func Register(t Type, e interface{}) { |
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.
You can remove Register/Unregister/Load. As exporter will be used via SpanProcessor (Batched or Simple or something else)
sdk/exporter/exporter.go
Outdated
) | ||
|
||
// SyncExporter is a synchronous exporter | ||
type SyncExporter interface { |
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.
Prefer Syncer
or Sync
. Otherwise when used outside of this package it's exporter.SyncExporter
, which stuttering, which should generally be avoided as it's just annoying to read and write (at least iMO).
sdk/exporter/exporter.go
Outdated
|
||
// All the exporter types | ||
const ( | ||
ExporterTypeSync = iota |
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.
Prefer TypeSync
and TypeBatch
because stuttering when used outside of the package (exporter.ExpoterTypeSync
).
sdk/exporter/exporter.go
Outdated
// not take forever to process the spans. | ||
// | ||
// The SpanData should not be modified. | ||
type BatchExporter interface { |
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.
Prefer Batcher
over BatchExporter
because stutter.
sdk/exporter/exporter.go
Outdated
exporters.Store(nm) | ||
} | ||
|
||
// Load loads all the registered exporters matching a specific type |
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.
If you keep it please consider removing the additional "loads", godoc comments should read cleanly.
sdk/exporter/exporter.go
Outdated
ExportSpan(context.Context, *SpanData) | ||
} | ||
|
||
// Batcher is a type for functions that receive sampled trace spans. |
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.
nit; s/sampled/batch of sampled/
also change
s/a single trace/a single sampled trace/
sdk/trace/span.go
Outdated
sps, _ := spanProcessors.Load().(spanProcessorMap) | ||
mustExportOrProcess := len(sps) > 0 || (s.spanContext.IsSampled() && len(exp) > 0) | ||
mustExportOrProcess := len(sps) > 0 | ||
// TODO(rghetia): when exporter is migrated to use processors simply check for the number | ||
// of processors. Exporter will export based on sampling. |
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.
nit: please remove the TODO.
for e := range exp { | ||
e.ExportSpan(sd) | ||
} | ||
} |
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 check should be added to SimpleSpanProcessor and BatchedSpanProcessor.
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.
Sorry, I missed this comment. Wouldn't that change the behavior though? OnEnd
is currently being executed without that check.
Also, spanContext
isn't available from within the processor.
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 believe you are referring to change in behavior of SSP and BSP as neither of them have the check right now. The current behavior is incorrect as it exports everything instead of just the sampled spans. SpanData has SpanContext so it should be able to do the check.
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.
All right, I've added the check. I've been looking for ways to setup an unsampled SpanContext to no luck though. So I'm happy to get any pointers to a way to test it.
sdk/exporter/exporter.go
Outdated
|
||
// Syncer is a type for functions that receive a single trace span. | ||
// | ||
// The ExportSpan method is called synchronously. |
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.
Might be worth adding a note that ExportSpan implementations should not block indefinitely
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.
Sure, though that was implied by the fact that the method is called synchronously.
sdk/exporter/exporter.go
Outdated
// The ExportSpan method is called synchronously. | ||
// | ||
// The SpanData should not be modified. | ||
type Syncer interface { |
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'd like a longer name, exporter.Synchronous
sounds good.
I'm conflicted over the naming in general, though. You're moving trace-specific exporter into a general-purpose package named "exporter". Now if we want to export different kinds of data, these names are claimed for trace-specific purposes.
I agree with moving this stuff out of the SDK proper, though.
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.
How about SpanSyncer
and SpanBatcher
? Then the possible naming conflict shouldn't happen.
I don't mind SpanSynchronous
, though that seems unnecessarily longer now.
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.
IMO, exporter package should be renamed to export. export.SpanSyncer sounds better than exporter.SpanSyncer.
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 100% convinced about that, since the package for exporters themselves is named exporter
. I've done it nevertheless.
// | ||
// The SpanData should not be modified. | ||
type SpanSyncer interface { | ||
ExportSpan(context.Context, *SpanData) |
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 is probably a bigger questions, but how do we plan on propagating errors back from these interfaces?
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.
An exporter getting an error shouldn't impact other exporters in the stack. So I believe they should log their errors, but there's no point in them sending it upstream.
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.
Exporter should allow registering optional callback function OnError()
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.
That looks like it's outside the scope of this PR though? I've opened #174.
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.
Agree, that's out of scope. Thanks for #174.
// | ||
// The SpanData should not be modified. | ||
type SpanSyncer interface { | ||
ExportSpan(context.Context, *SpanData) |
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.
Agree, that's out of scope. Thanks for #174.
So it's explicit they are for spans, and we reduce the risk of name conflict
…aws (#162) * Bump github.com/aws/aws-sdk-go from 1.33.14 to 1.33.15 in /detectors/aws Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.33.14 to 1.33.15. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Changelog](https://github.com/aws/aws-sdk-go/blob/master/CHANGELOG.md) - [Commits](aws/aws-sdk-go@v1.33.14...v1.33.15) Signed-off-by: dependabot[bot] <support@github.com> * Auto-fix go.sum changes in dependent modules Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <dependabot[bot]@users.noreply.github.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This is an attempt at implementing #77.
There are still unresolved questions for which I'm going to leave inline comments.