我正在使用无服务器框架将 PHP 代码部署为 IBM Cloud Function。
以下是操作 PHP 文件中的代码:
function main($args): array {
Sentry\init(['dsn' => 'SENTRY_DSN' ]);
try {
throw new \Exception('Some error')
} catch (\Throwable $exception) {
Sentry\captureException($exception);
}
}
Run Code Online (Sandbox Code Playgroud)
这是 serverless.yml 文件:
service: cloudfunc
provider:
name: openwhisk
runtime: php
package:
individually: true
exclude:
- "**"
include:
- "vendor/**"
functions:
test-sentry:
handler: actions/test-sentry.main
annotations:
raw-http: true
events:
- http:
path: /test-sentry
method: post
resp: http
package:
include:
- actions/test-sentry.php
plugins:
- serverless-openwhisk
Run Code Online (Sandbox Code Playgroud)
当我从本地环境(NGINX/PHP Docker 容器)测试操作处理程序时,错误将被发送到 Sentry。
但是,当我尝试从 IBM Cloud …