| 175 | |
| 176 | return Tracer.make({ |
| 177 | span(name, parent, context, links, startTime, kind, options) { |
| 178 | const span = currentTracer.span(name, parent, context, links, startTime, kind, options) |
| 179 | client.unsafeAddSpan(span) |
| 180 | const oldEvent = span.event |
| 181 | span.event = function(this: any, name, startTime, attributes) { |
| 182 | client.unsafeAddSpan({ |
| 183 | _tag: "SpanEvent", |
| 184 | traceId: span.traceId, |
| 185 | spanId: span.spanId, |
| 186 | name, |
| 187 | startTime, |
| 188 | attributes: attributes || {} |
| 189 | }) |
| 190 | return oldEvent.call(this, name, startTime, attributes) |
| 191 | } |
| 192 | const oldEnd = span.end |
| 193 | span.end = function(this: any) { |
| 194 | client.unsafeAddSpan(span) |
| 195 | return oldEnd.apply(this, arguments as any) |
| 196 | } |
| 197 | return span |
| 198 | }, |
| 199 | context: currentTracer.context |
| 200 | }) |
| 201 | }).pipe( |