From ecab639c1c88f913426373f49349efe4bc119d5f Mon Sep 17 00:00:00 2001 From: Travis Vachon Date: Mon, 25 Nov 2024 18:58:02 +0100 Subject: [PATCH] fix: disable tracing across the board (#445) We currently can't use Sentry's tracing functionality because we overrun our tracing data quota within hours. I'm disabling all tracing and plan on re-enabling it across the board once I've worked out how to use it for the debugging tasks I have on my plate right now. Note that this **does not** disable error reporting - that's a separate configuration option and this just disables tracing: https://docs.sentry.io/platforms/javascript/tracing/ My end goal for this is to have tracing configured at a reasonable percentage for each lambda - most will probably end up around 0.1 but some higher volume functions may need even lower settings. --- billing/functions/billing-cron.js | 2 +- billing/functions/customer-billing-queue.js | 2 +- billing/functions/space-billing-queue.js | 2 +- billing/functions/stripe.js | 2 +- billing/functions/ucan-stream.js | 2 +- billing/functions/usage-table.js | 2 +- carpark/event-bus/eipfs-indexer.js | 2 +- carpark/functions/carpark-bucket-event.js | 2 +- filecoin/functions/handle-cron-tick.js | 2 +- .../functions/handle-filecoin-submit-message.js | 2 +- .../handle-piece-insert-to-content-claim.js | 2 +- .../handle-piece-insert-to-filecoin-submit.js | 2 +- filecoin/functions/handle-piece-offer-message.js | 2 +- filecoin/functions/handle-piece-status-update.js | 2 +- .../metrics-aggregate-offer-and-accept-total.js | 2 +- filecoin/functions/piece-cid-compute.js | 2 +- .../handle-block-advert-publish-message.js | 2 +- .../functions/handle-block-index-writer-message.js | 2 +- replicator/functions/replicator.js | 2 +- roundabout/functions/redirect.js | 2 +- upload-api/functions/admin-metrics.js | 2 +- upload-api/functions/bridge.js | 2 +- upload-api/functions/get.js | 2 +- upload-api/functions/metrics.js | 2 +- upload-api/functions/receipt.js | 2 +- upload-api/functions/space-metrics.js | 2 +- upload-api/functions/storefront-cron.js | 2 +- upload-api/functions/ucan-invocation-router.js | 2 +- upload-api/functions/ucan.js | 2 +- upload-api/functions/validate-email.jsx | 13 ++++++++++++- upload-api/service.js | 2 +- 31 files changed, 42 insertions(+), 31 deletions(-) diff --git a/billing/functions/billing-cron.js b/billing/functions/billing-cron.js index 0195c78a..ce65aeb4 100644 --- a/billing/functions/billing-cron.js +++ b/billing/functions/billing-cron.js @@ -9,7 +9,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0 + tracesSampleRate: 0 }) /** diff --git a/billing/functions/customer-billing-queue.js b/billing/functions/customer-billing-queue.js index 51ea74cb..63b16993 100644 --- a/billing/functions/customer-billing-queue.js +++ b/billing/functions/customer-billing-queue.js @@ -10,7 +10,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0 + tracesSampleRate: 0 }) /** diff --git a/billing/functions/space-billing-queue.js b/billing/functions/space-billing-queue.js index dcd5c874..a398d430 100644 --- a/billing/functions/space-billing-queue.js +++ b/billing/functions/space-billing-queue.js @@ -10,7 +10,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0 + tracesSampleRate: 0 }) /** diff --git a/billing/functions/stripe.js b/billing/functions/stripe.js index 585040ce..6538d70a 100644 --- a/billing/functions/stripe.js +++ b/billing/functions/stripe.js @@ -13,7 +13,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) export const webhook = Sentry.AWSLambda.wrapHandler( diff --git a/billing/functions/ucan-stream.js b/billing/functions/ucan-stream.js index 2c3eb0b9..342f507d 100644 --- a/billing/functions/ucan-stream.js +++ b/billing/functions/ucan-stream.js @@ -11,7 +11,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0 + tracesSampleRate: 0 }) /** diff --git a/billing/functions/usage-table.js b/billing/functions/usage-table.js index 286eddca..81aebe0a 100644 --- a/billing/functions/usage-table.js +++ b/billing/functions/usage-table.js @@ -9,7 +9,7 @@ import { expect } from './lib.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0 + tracesSampleRate: 0 }) /** diff --git a/carpark/event-bus/eipfs-indexer.js b/carpark/event-bus/eipfs-indexer.js index 278958aa..3488db4c 100644 --- a/carpark/event-bus/eipfs-indexer.js +++ b/carpark/event-bus/eipfs-indexer.js @@ -9,7 +9,7 @@ const SQS_INDEXER_QUEUE_REGION = 'us-west-2' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** diff --git a/carpark/functions/carpark-bucket-event.js b/carpark/functions/carpark-bucket-event.js index 9164b6b3..43ba16aa 100644 --- a/carpark/functions/carpark-bucket-event.js +++ b/carpark/functions/carpark-bucket-event.js @@ -6,7 +6,7 @@ import { notifyBus } from '../event-bus/source.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) const EVENT_BUS_ARN = process.env.EVENT_BUS_ARN || '' diff --git a/filecoin/functions/handle-cron-tick.js b/filecoin/functions/handle-cron-tick.js index 42ba538b..827f3e37 100644 --- a/filecoin/functions/handle-cron-tick.js +++ b/filecoin/functions/handle-cron-tick.js @@ -14,7 +14,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) const AWS_REGION = process.env.AWS_REGION || 'us-west-2' diff --git a/filecoin/functions/handle-filecoin-submit-message.js b/filecoin/functions/handle-filecoin-submit-message.js index a61aa7c9..db8b401b 100644 --- a/filecoin/functions/handle-filecoin-submit-message.js +++ b/filecoin/functions/handle-filecoin-submit-message.js @@ -10,7 +10,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) const AWS_REGION = process.env.AWS_REGION || 'us-west-2' diff --git a/filecoin/functions/handle-piece-insert-to-content-claim.js b/filecoin/functions/handle-piece-insert-to-content-claim.js index 20f2cd5e..f9ce8ab9 100644 --- a/filecoin/functions/handle-piece-insert-to-content-claim.js +++ b/filecoin/functions/handle-piece-insert-to-content-claim.js @@ -14,7 +14,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** diff --git a/filecoin/functions/handle-piece-insert-to-filecoin-submit.js b/filecoin/functions/handle-piece-insert-to-filecoin-submit.js index 3c3bb89d..0bc0fb71 100644 --- a/filecoin/functions/handle-piece-insert-to-filecoin-submit.js +++ b/filecoin/functions/handle-piece-insert-to-filecoin-submit.js @@ -14,7 +14,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** diff --git a/filecoin/functions/handle-piece-offer-message.js b/filecoin/functions/handle-piece-offer-message.js index 14ed8c2d..7cef52ac 100644 --- a/filecoin/functions/handle-piece-offer-message.js +++ b/filecoin/functions/handle-piece-offer-message.js @@ -13,7 +13,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** diff --git a/filecoin/functions/handle-piece-status-update.js b/filecoin/functions/handle-piece-status-update.js index 766183d9..6b308dc9 100644 --- a/filecoin/functions/handle-piece-status-update.js +++ b/filecoin/functions/handle-piece-status-update.js @@ -14,7 +14,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** diff --git a/filecoin/functions/metrics-aggregate-offer-and-accept-total.js b/filecoin/functions/metrics-aggregate-offer-and-accept-total.js index d13efcf4..df4b65d4 100644 --- a/filecoin/functions/metrics-aggregate-offer-and-accept-total.js +++ b/filecoin/functions/metrics-aggregate-offer-and-accept-total.js @@ -11,7 +11,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) const AWS_REGION = process.env.AWS_REGION || 'us-west-2' diff --git a/filecoin/functions/piece-cid-compute.js b/filecoin/functions/piece-cid-compute.js index 89bf74c2..9d42f1c0 100644 --- a/filecoin/functions/piece-cid-compute.js +++ b/filecoin/functions/piece-cid-compute.js @@ -13,7 +13,7 @@ import { getS3Client } from '../../lib/aws/s3.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** diff --git a/indexer/functions/handle-block-advert-publish-message.js b/indexer/functions/handle-block-advert-publish-message.js index bb506019..5bdc2393 100644 --- a/indexer/functions/handle-block-advert-publish-message.js +++ b/indexer/functions/handle-block-advert-publish-message.js @@ -9,7 +9,7 @@ import { getSQSClient } from '../../lib/aws/sqs.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** diff --git a/indexer/functions/handle-block-index-writer-message.js b/indexer/functions/handle-block-index-writer-message.js index caa0a868..3134cba9 100644 --- a/indexer/functions/handle-block-index-writer-message.js +++ b/indexer/functions/handle-block-index-writer-message.js @@ -9,7 +9,7 @@ import { getDynamoClient } from '../../lib/aws/dynamo.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** diff --git a/replicator/functions/replicator.js b/replicator/functions/replicator.js index d149ea2c..ab0048cd 100644 --- a/replicator/functions/replicator.js +++ b/replicator/functions/replicator.js @@ -8,7 +8,7 @@ import { getS3Client } from '../../lib/aws/s3.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** diff --git a/roundabout/functions/redirect.js b/roundabout/functions/redirect.js index 6550e3b8..68a3a026 100644 --- a/roundabout/functions/redirect.js +++ b/roundabout/functions/redirect.js @@ -9,7 +9,7 @@ import { getS3Client } from '../../lib/aws/s3.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** diff --git a/upload-api/functions/admin-metrics.js b/upload-api/functions/admin-metrics.js index 9db2a788..afbc5227 100644 --- a/upload-api/functions/admin-metrics.js +++ b/upload-api/functions/admin-metrics.js @@ -12,7 +12,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) const AWS_REGION = process.env.AWS_REGION || 'us-west-2' diff --git a/upload-api/functions/bridge.js b/upload-api/functions/bridge.js index 1bcf524f..47a8f5e4 100644 --- a/upload-api/functions/bridge.js +++ b/upload-api/functions/bridge.js @@ -13,7 +13,7 @@ import { streamToArrayBuffer, stringToStream } from '../bridge/streams.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** diff --git a/upload-api/functions/get.js b/upload-api/functions/get.js index dffd63c5..0f503664 100644 --- a/upload-api/functions/get.js +++ b/upload-api/functions/get.js @@ -6,7 +6,7 @@ import { getServiceSigner } from '../config.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) const repo = 'https://github.com/web3-storage/w3infra' diff --git a/upload-api/functions/metrics.js b/upload-api/functions/metrics.js index 94049aef..b199edcc 100644 --- a/upload-api/functions/metrics.js +++ b/upload-api/functions/metrics.js @@ -22,7 +22,7 @@ import { createMetricsTable } from '../tables/metrics.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) const AWS_REGION = process.env.AWS_REGION || 'us-west-2' diff --git a/upload-api/functions/receipt.js b/upload-api/functions/receipt.js index 91121e59..4dfb44f0 100644 --- a/upload-api/functions/receipt.js +++ b/upload-api/functions/receipt.js @@ -7,7 +7,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) diff --git a/upload-api/functions/space-metrics.js b/upload-api/functions/space-metrics.js index 55afdb88..ed8f6b22 100644 --- a/upload-api/functions/space-metrics.js +++ b/upload-api/functions/space-metrics.js @@ -12,7 +12,7 @@ import { mustGetEnv } from '../../lib/env.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) const AWS_REGION = process.env.AWS_REGION || 'us-west-2' diff --git a/upload-api/functions/storefront-cron.js b/upload-api/functions/storefront-cron.js index 4a2f0ad1..8788652e 100644 --- a/upload-api/functions/storefront-cron.js +++ b/upload-api/functions/storefront-cron.js @@ -4,7 +4,7 @@ import { handleCronTick } from '../../filecoin/functions/handle-cron-tick.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) export const handler = Sentry.AWSLambda.wrapHandler(handleCronTick) diff --git a/upload-api/functions/ucan-invocation-router.js b/upload-api/functions/ucan-invocation-router.js index a758b440..d9c468e7 100644 --- a/upload-api/functions/ucan-invocation-router.js +++ b/upload-api/functions/ucan-invocation-router.js @@ -47,7 +47,7 @@ import * as UCantoValidator from '@ucanto/validator' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) export { API } diff --git a/upload-api/functions/ucan.js b/upload-api/functions/ucan.js index 8cf00e63..9b7d51f3 100644 --- a/upload-api/functions/ucan.js +++ b/upload-api/functions/ucan.js @@ -6,7 +6,7 @@ import * as AgentStore from '../stores/agent.js' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) const AWS_REGION = process.env.AWS_REGION || 'us-west-2' diff --git a/upload-api/functions/validate-email.jsx b/upload-api/functions/validate-email.jsx index 4fd0525b..5b6f5e17 100644 --- a/upload-api/functions/validate-email.jsx +++ b/upload-api/functions/validate-email.jsx @@ -26,7 +26,7 @@ const html = process.env.HOSTED_ZONE === 'up.web3.storage' ? htmlW3s : htmlStora Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) /** @@ -183,6 +183,7 @@ function createAuthorizeContext() { * @param {import('aws-lambda').APIGatewayProxyEventV2} request */ export async function validateEmailPost(request) { + console.log("VALIDATING EMAIL") const encodedUcan = request.queryStringParameters?.ucan if (!encodedUcan) { return toLambdaResponse( @@ -191,8 +192,14 @@ export async function validateEmailPost(request) { ) ) } + console.log("CREATING CONTEXT") + const context = createAuthorizeContext() + console.log("AUTHORIZING") + const authorizeResult = await authorize(encodedUcan, context) + console.log("AUTHORIZED", JSON.stringify(authorizeResult)) + if (authorizeResult.error) { console.error(authorizeResult.error) return toLambdaResponse( @@ -208,17 +215,21 @@ export async function validateEmailPost(request) { } const { email, audience, ucan } = authorizeResult.ok + console.log("CHECKING PLAN") const planCheckResult = await context.customerStore.get({ customer: DidMailto.fromEmail(email), }) let stripePricingTableId let stripePublishableKey + console.log("CHECKED PLAN", JSON.stringify(planCheckResult)) + if (!planCheckResult.ok?.product) { stripePricingTableId = context.stripePricingTableId stripePublishableKey = context.stripePublishableKey } + return toLambdaResponse( new html.HtmlResponse( ( diff --git a/upload-api/service.js b/upload-api/service.js index 20e15d39..f42d2cb6 100644 --- a/upload-api/service.js +++ b/upload-api/service.js @@ -4,7 +4,7 @@ import * as UploadAPI from '@web3-storage/upload-api' Sentry.AWSLambda.init({ environment: process.env.SST_STAGE, dsn: process.env.SENTRY_DSN, - tracesSampleRate: 1.0, + tracesSampleRate: 0, }) export const createServiceRouter = UploadAPI.createService