From da6ef1c6ce45f289778b41367fca360ae1dddc52 Mon Sep 17 00:00:00 2001 From: Jose Felix Date: Tue, 13 Aug 2024 19:31:48 -0400 Subject: [PATCH] feat: streamline service name propagation --- packages/trpc/src/api.ts | 6 ++++++ packages/web/utils/trpc.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/packages/trpc/src/api.ts b/packages/trpc/src/api.ts index 1f791ffb4e..3f5e8fee81 100644 --- a/packages/trpc/src/api.ts +++ b/packages/trpc/src/api.ts @@ -81,6 +81,9 @@ export const createTRPCRouter = t.router; * are logged in. */ export const publicProcedure = t.procedure + /** + * Opentelemetry tRPC middleware that names the handling transaction after the called procedure. + */ .use(async ({ path, rawInput, type, next, ctx }) => { const serviceName = ctx.opentelemetryServiceName ?? "fallback-osmosis-frontend-service-name"; @@ -138,10 +141,12 @@ export function localLink({ router, assetLists, chainList, + opentelemetryServiceName, }: { router: TRouter; assetLists: AssetList[]; chainList: Chain[]; + opentelemetryServiceName: string | undefined; }): TRPCLink { return () => ({ op }) => @@ -152,6 +157,7 @@ export function localLink({ const caller = createCaller({ assetLists, chainList, + opentelemetryServiceName, }); try { // Attempt to execute the operation using the router's caller. diff --git a/packages/web/utils/trpc.ts b/packages/web/utils/trpc.ts index d78b95b903..fad931a1bd 100644 --- a/packages/web/utils/trpc.ts +++ b/packages/web/utils/trpc.ts @@ -16,6 +16,7 @@ import type { import { AssetLists } from "~/config/generated/asset-lists"; import { ChainList } from "~/config/generated/chain-list"; import { type AppRouter, appRouter } from "~/server/api/root-router"; +import { getOpentelemetryServiceName } from "~/utils/service-name"; import { constructEdgeRouterKey, constructEdgeUrlPathname, @@ -122,6 +123,7 @@ export const api = createTRPCNext({ router: appRouter, assetLists: AssetLists, chainList: ChainList, + opentelemetryServiceName: getOpentelemetryServiceName(), })(runtime), /**