小编vla*_*run的帖子

从 IBM Cloud Functions 调用时,PHP SDK 不会向 Sentry 发送错误

我正在使用无服务器框架将 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 …

php sentry serverless-framework openwhisk ibm-cloud

1
推荐指数
1
解决办法
2219
查看次数

标签 统计

ibm-cloud ×1

openwhisk ×1

php ×1

sentry ×1

serverless-framework ×1