We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 457cb30 commit 9fe67f4Copy full SHA for 9fe67f4
1 file changed
packages/otel/src/Span/index.ts
@@ -24,13 +24,20 @@ export interface Span extends SpanImpl {}
24
25
export const Span = tag<Span>()
26
27
-export function withSpan(name: string, options?: OTApi.SpanOptions) {
+export function withSpan(
28
+ name: string,
29
+ options?: OTApi.SpanOptions,
30
+ ctx?: OTApi.Context
31
+) {
32
return <R, E, A>(
33
effect: T.Effect<R & Has<Span>, E, A>
34
): T.Effect<R & Has<Tracer>, E, A> => {
35
const createSpan = withTracer((tracer) =>
36
T.access((r: unknown) => {
37
const maybeSpan = Span.readOption(r)
38
+ if (ctx) {
39
+ return tracer.startSpan(name, options, ctx)
40
+ }
41
if (options?.root !== true && O.isSome(maybeSpan)) {
42
const ctx = trace.setSpan(context.active(), maybeSpan.value.span)
43
return tracer.startSpan(name, options, ctx)
0 commit comments