-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cloudflare): instrument scheduled handler (#13114)
This PR adds instrumentation for the [`scheduled` handler](https://developers.cloudflare.com/workers/runtime-apis/handlers/scheduled/) in cloudflare workers. This is used for cron triggers. I elected to not do automatic cron instrumentation for now. Instead I added manual instrumentation docs to the README, this will get copied to the sentry docs eventually.
- Loading branch information
1 parent
a7fbe01
commit b4a9970
Showing
8 changed files
with
364 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { IncomingRequestCfProperties } from '@cloudflare/workers-types'; | ||
|
||
import type { Scope } from '@sentry/types'; | ||
import { winterCGRequestToRequestData } from '@sentry/utils'; | ||
|
||
/** | ||
* Set cloud resource context on scope. | ||
*/ | ||
export function addCloudResourceContext(scope: Scope): void { | ||
scope.setContext('cloud_resource', { | ||
'cloud.provider': 'cloudflare', | ||
}); | ||
} | ||
|
||
/** | ||
* Set culture context on scope | ||
*/ | ||
export function addCultureContext(scope: Scope, cf: IncomingRequestCfProperties): void { | ||
scope.setContext('culture', { | ||
timezone: cf.timezone, | ||
}); | ||
} | ||
|
||
/** | ||
* Set request data on scope | ||
*/ | ||
export function addRequest(scope: Scope, request: Request): void { | ||
scope.setSDKProcessingMetadata({ request: winterCGRequestToRequestData(request) }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.