const getParentSpan = () => {
const span = trace.getActiveSpan()
return span && Tracer.makeExternalSpan(span.spanContext())
}
export const effectWithActiveSpan = (name: string, attributes?: Record<string, unknown>) => {
const parent = getParentSpan()
return parent
? flow(
Effect.withSpan(name, { attributes }),
Effect.withParentSpan(parent)
)
: flow(
Effect.withSpan(name, { attributes })
)
}
const getParentSpan = () => {
const span = trace.getActiveSpan()
return span && Tracer.makeExternalSpan(span.spanContext())
}
export const effectWithActiveSpan = (name: string, attributes?: Record<string, unknown>) => {
const parent = getParentSpan()
return parent
? flow(
Effect.withSpan(name, { attributes }),
Effect.withParentSpan(parent)
)
: flow(
Effect.withSpan(name, { attributes })
)
}