Skip to content
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

Merged
merged 11 commits into from
Oct 8, 2019
Merged

Export package #162

merged 11 commits into from
Oct 8, 2019

Conversation

dmathieu
Copy link
Member

@dmathieu dmathieu commented Oct 3, 2019

This is an attempt at implementing #77.
There are still unresolved questions for which I'm going to leave inline comments.


// SyncExporter is a synchronous exporter
type SyncExporter interface {
ExportSpan(context.Context, interface{})
Copy link
Member Author

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.

Copy link
Contributor

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.

//
// The SpanData should not be modified.
type BatchExporter interface {
ExportSpans(context.Context, []interface{})
Copy link
Member Author

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

}

// Load loads all the registered exporters matching a specific type
func Load(t Type) []interface{} {
Copy link
Member Author

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?

//
// The SpanData should not be modified.
type BatchExporter interface {
ExportSpans(context.Context, []interface{})
Copy link
Contributor

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.


// SyncExporter is a synchronous exporter
type SyncExporter interface {
ExportSpan(context.Context, interface{})
Copy link
Contributor

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.


// Register adds to the list of Exporters that will receive sampled trace
// spans.
func Register(t Type, e interface{}) {
Copy link
Contributor

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)

)

// SyncExporter is a synchronous exporter
type SyncExporter interface {
Copy link
Contributor

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).


// All the exporter types
const (
ExporterTypeSync = iota
Copy link
Contributor

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).

// not take forever to process the spans.
//
// The SpanData should not be modified.
type BatchExporter interface {
Copy link
Contributor

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.

exporters.Store(nm)
}

// Load loads all the registered exporters matching a specific type
Copy link
Contributor

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.

@dmathieu dmathieu requested a review from rghetia October 4, 2019 08:31
ExportSpan(context.Context, *SpanData)
}

// Batcher is a type for functions that receive sampled trace spans.
Copy link
Contributor

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/

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.
Copy link
Contributor

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)
}
}
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.


// Syncer is a type for functions that receive a single trace span.
//
// The ExportSpan method is called synchronously.
Copy link
Contributor

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

Copy link
Member Author

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.

// The ExportSpan method is called synchronously.
//
// The SpanData should not be modified.
type Syncer interface {
Copy link
Contributor

@jmacd jmacd Oct 4, 2019

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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)
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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()

Copy link
Member Author

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.

Copy link
Contributor

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)
Copy link
Contributor

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.

@rghetia
Copy link
Contributor

rghetia commented Oct 8, 2019

@dmathieu are you going to resolve this comment in this PR or in a separate PR?

@rghetia rghetia merged commit c2d5c66 into open-telemetry:master Oct 8, 2019
@dmathieu dmathieu deleted the export-package branch October 15, 2019 10:07
hstan referenced this pull request in hstan/opentelemetry-go Oct 15, 2020
…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>
@pellared pellared added this to the untracked milestone Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants