Effect CommunityEC
Effect Community•3y ago•
9 replies
phischer

Using `Config` instead of `process.env` in `NodeSdk` setup

Just finished setting up telemetry with grafana cloud. Sooo cool! 🚀 Struggled a little with what the actual endpoint needs to be (Spoiler Alert: https://otlp-gateway-prod-<zone>.grafana.net/otlp/v1/traces), but it's working now! What I didn't find out, is how to use Config in the NodeSdk setup. I know how to use it in function that returns an Effect but I need to return a Layer. How would I use Config here instead of process.env?

export const NodeSdkLive = NodeSdk.layer(() => ({
  resource: {
    serviceName: 'nextjs',
  },
  spanProcessor: new BatchSpanProcessor(
    new OTLPTraceExporter({
      url: process.env.OTLP_URL,
      headers: {
        Authorization: process.env.OTLP_AUTH,
      },
    })
  ),
}))
Was this page helpful?