Effect CommunityEC
Effect Community•2y ago•
42 replies
nickrttn

Trouble Integrating OTel with `@effect/rpc` in Browser RPC Client

Hi 👋 I've got some trouble getting otel in
@effect/rpc
to work. I've got the following RPC client for the browser:

import * as Http from '@effect/platform/HttpClient';
import { Resolver } from '@effect/rpc';
import { HttpResolver } from '@effect/rpc-http';

import type { RpcRouter } from '@/app/api/internal/rpc/route';

import { getAppOrigin } from '../utils.nodeps';

export const rpc = HttpResolver.make<RpcRouter>(
  Http.client.fetchOk.pipe(
    Http.client.mapRequest(
      Http.request.prependUrl(`${getAppOrigin()}/api/internal/rpc`),
    ),
  ),
).pipe(Resolver.toClient);


and besides at calls to rpc(...) I'm not sure where to provide my OTel service so that the internal (to the @effect/rpc(-http)) spans are being traced. I would prefer to provide the service here, not at every call to rpc . Any way that I could do that?
Was this page helpful?