1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-06-27 00:21:15 +02:00

SDK: span processor interface and simple span processor. (#117)

* SDK: SpanProcessor Interface.

* add simple span processor.

* rename span processor.

* fix logic to export or process span data.
This commit is contained in:
rghetia
2019-09-16 13:58:15 -07:00
committed by GitHub
parent 5df3c071e8
commit cb0d352ec6
6 changed files with 333 additions and 7 deletions

View File

@ -123,23 +123,26 @@ func (s *span) Finish(options ...apitrace.FinishOption) {
}
s.endOnce.Do(func() {
exp, _ := exporters.Load().(exportersMap)
mustExport := s.spanContext.IsSampled() && len(exp) > 0
//if s.spanStore != nil || mustExport {
if mustExport {
sps, _ := spanProcessors.Load().(spanProcessorMap)
mustExportOrProcess := len(sps) > 0 || (s.spanContext.IsSampled() && len(exp) > 0)
// TODO(rghetia): when exporter is migrated to use processors simply check for the number
// of processors. Exporter will export based on sampling.
if mustExportOrProcess {
sd := s.makeSpanData()
if opts.FinishTime.IsZero() {
sd.EndTime = internal.MonotonicEndTime(sd.StartTime)
} else {
sd.EndTime = opts.FinishTime
}
//if s.spanStore != nil {
// s.spanStore.finished(s, sd)
//}
if mustExport {
// Sampling check would be in the processor if the processor is used for exporting.
if s.spanContext.IsSampled() {
for e := range exp {
e.ExportSpan(sd)
}
}
for sp := range sps {
sp.OnEnd(sd)
}
}
})
}