Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cloudflare): Add cloudflare sdk scaffolding #12953

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Jul 17, 2024

ref #12620

This PR adds basic scaffolding for the cloudflare workers SDK. Most of this is based on @sentry/vercel-edge.

This adds:

  1. A basic cloudflare workers client
  2. A set of default integrations for the cloudflare sdk (including a fetch based one)
  3. A cloudflare transport that uses the vercel-edge transport
  4. An async context strategy powered by AsyncLocalStorage

You'll notice that there is no init method defined or exported from the SDK. This is on purpose! init for cloudflare workers will work a bit differently than the other SDKs, so I wanted to address it differently on purpose. You'll see what that looks like in the next PR!

@AbhiPrasad AbhiPrasad requested a review from a team July 17, 2024 13:39
@AbhiPrasad AbhiPrasad self-assigned this Jul 17, 2024
@AbhiPrasad AbhiPrasad requested review from mydea and chargome and removed request for a team July 17, 2024 13:39
@AbhiPrasad AbhiPrasad force-pushed the abhi-cloudflare-errors branch from 16eed29 to 8241555 Compare July 17, 2024 13:53
Comment on lines +53 to +56
const cachedDecision = _headersUrlMap.get(url);
if (cachedDecision !== undefined) {
return cachedDecision;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: could extract the cache decision logic into a helper function and reuse it in _shouldCreateSpan

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do this in a follow-up PR

const shouldCreateSpanForRequest = options.shouldCreateSpanForRequest;

const _createSpanUrlMap = new LRUMap<string, boolean>(100);
const _headersUrlMap = new LRUMap<string, boolean>(100);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to understand it better, how did you come up with cache size 100?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was arbitrary, it matches the implementation for vercel-edge fetch integration. We can always adjust this in the future.

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@AbhiPrasad AbhiPrasad merged commit a17c8c4 into develop Jul 18, 2024
121 checks passed
@AbhiPrasad AbhiPrasad deleted the abhi-cloudflare-errors branch July 18, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants