Effect CommunityEC
Effect Community2y ago
17 replies
Patrick Roza

Handling Parent-less Spans in Batch Request Resolvers

One source of parent-less spans, aka transactions, remain, which is batch request resolvers, it appears to generate the highest count of transaction and therefore usage e.g at Sentry.
Now I could disable sampling for them. But I wonder if anyone else has a different strategy in mind for that.

The main conundrum is the nature of batch resolvers with cache; nobody really owns these operations.
Though on some level, I think it would be fine if they get attributed to the span who caused a miss.

export const ShopFromId: Schema<Shop, string, ShopFromId> = S.transformOrFail(
  ShopId,
  S.typeSchema(Shop),
  {
    decode: (id) => Shop.resolver.andThen((_) => _(id)),
    // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
    encode: (u) => ParseResult.try({ try: () => u.id, catch: (e) => new ParseResult.Type(null as any, u, `${e}`) })
  }
)
export class ConfiguratorShop extends S.Extended<ConfiguratorShop>()({
  ...ConfiguratorShopBase.omit("shopId"),
  shop: S.propertySignature(ShopFromId).pipe(S.fromKey("shopId"))
}) {}

// shop resolver
ShopRepo.use((repo) =>
      getShopByIdResolver
        .pipe(
          Effect.provideService(ShopRepo, repo),
          Effect.map(
            (resolver) => (id: ShopId) =>
              Effect
                .request(GetShopById({ id }), resolver)
                .orDie()
          )
        )
    )
Was this page helpful?