Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/opentelemetry/src/internal/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
options?: EffectTracer.SpanOptions
) {
this[OtelSpanTypeId] = OtelSpanTypeId
console.log({ options })

Check failure on line 66 in packages/opentelemetry/src/internal/tracer.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
const active = contextApi.active()
this.parent = effectParent._tag === "Some"
? effectParent
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions scratchpad/bs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { DevTools } from "@effect/experimental"
import { NodeSdk } from "@effect/opentelemetry"
import { NodeRuntime } from "@effect/platform-node"
import { InMemorySpanExporter, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node"
import { Console, Effect, FiberSet, Layer, Option, pipe, Schedule } from "effect"

export const TracingLive = NodeSdk.layer(Effect.sync(() => ({
resource: {
serviceName: "test"
},
spanProcessor: new SimpleSpanProcessor(new InMemorySpanExporter())
})))

const program = Effect.gen(function*() {
const fs = yield* FiberSet.make()

yield* FiberSet.run(fs)(
Effect.gen(function*() {
// const currentSpan = yield* Effect.currentSpan.pipe(Effect.option)
// console.dir({ _tag: "start", currentSpan }, { depth: 20 })

yield* Effect.gen(function*() {
// const currentSpan = yield* Effect.currentSpan.pipe(Effect.option)

// // we actually have a parent span because of auto inherit via OTel Context
// if (Option.isSome(currentSpan) && Option.isSome(currentSpan.value.parent)) {
// return yield* Effect.die("ya fucked up!")
// }
}).pipe(
Effect.withSpan("Iter", { root: true }),
Effect.repeat(Schedule.spaced("1 seconds")),
Effect.onExit(Console.dir)
)
})
)
}).pipe(Effect.withSpan("main"))

const DevToolsLive = DevTools.layer()

Layer.mergeAll(program.pipe(Layer.scopedDiscard)).pipe(
// doesn't reach Otel
// Layer.provide([DevToolsLive, TracingLive]),
// reaches Otel, but no options passed!
Layer.provide(pipe(DevToolsLive, Layer.provideMerge(TracingLive))),
// this works
// Layer.provide(TracingLive),
Layer.launch,
NodeRuntime.runMain
)
1 change: 1 addition & 0 deletions scratchpad/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@effect/typeclass": "workspace:*",
"@effect/vitest": "workspace:*",
"@effect/workflow": "workspace:*",
"@opentelemetry/sdk-trace-node": "^2.0.1",
"effect": "workspace:*"
}
}
Loading