Effect CommunityEC
Effect Community3mo ago
1 reply
bste

Tidying Up Tracing with AWS Client in Effect-AWS Library

hey all. I'm looking to use the effect-aws/client-dynamodb lib, but I want the underlying aws client to be traced using power tools tracer.
What I've got so far is pretty messy so if anyone knows how I can tidy this up that would be great
Layer.effect(DynamoDBDocumentService, makeDynamoDBDocumentService).pipe(
  Layer.provide(
    Layer.effect(
      DynamoDBDocumentClientInstance.DynamoDBDocumentClientInstance,
      Effect.gen(function* () {
        const xrayTracer = yield* Tracer.XrayTracer
        const config = yield* DynamoDBServiceConfig.toDynamoDBClientConfig
        const awsClient = xrayTracer.captureAWSv3Client(new DynamoDBClient(config))

        if (awsClient === undefined)
          return yield* Effect.die(new Error("Failed to initialise traced dynamo client"))

        return DynamoDBDocumentClient.from(awsClient)
      }),
    ),
  ),
)
Was this page helpful?