Skip to content

Commit

Permalink
feat: add back OTEL
Browse files Browse the repository at this point in the history
  • Loading branch information
TylorS committed May 16, 2024
1 parent 8cf4f36 commit eca4b72
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/realworld/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import * as NodeSdk from "@effect/opentelemetry/NodeSdk"
import * as Http from "@effect/platform/HttpServer"
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base"
import type { Fx } from "@typed/core"
import * as Node from "@typed/core/Node"
import { toServerRouter } from "@typed/core/Platform"
import * as Api from "@typed/realworld/api"
Expand Down Expand Up @@ -29,5 +33,14 @@ toServerRouter(Ui.router, { layout: Ui.document }).pipe(
Node.listen({ port: 3000, serverDirectory: import.meta.dirname, logLevel: LogLevel.Debug }),
// Provide all static resources which do not change per-request
Effect.provide(Live),
// OpenTelemetry tracing
Effect.provide(NodeSdk.layer(() => ({
resource: { serviceName: "realworld" },
spanProcessor: new BatchSpanProcessor(
new OTLPTraceExporter({
url: "http://localhost:4318/v1/traces"
})
)
}))),
Node.run
)

0 comments on commit eca4b72

Please sign in to comment.