feat #19: integrate sentry for event reporting

This commit is contained in:
debugtalk
2021-11-18 18:01:24 +08:00
parent 52afe41a66
commit d306452b19
8 changed files with 165 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package cmd
import (
"time"
"github.com/getsentry/sentry-go"
"github.com/spf13/cobra"
"github.com/httprunner/hrp"
@@ -18,6 +19,7 @@ var boomCmd = &cobra.Command{
$ hrp boom examples/ # run testcases in specified folder`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
sentry.CaptureMessage("start to run load test")
var paths []hrp.ITestCase
for _, arg := range args {
paths = append(paths, &hrp.TestCasePath{Path: arg})

View File

@@ -1,6 +1,7 @@
package cmd
import (
"github.com/getsentry/sentry-go"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
@@ -14,6 +15,7 @@ var har2caseCmd = &cobra.Command{
Long: `Convert HAR to json/yaml testcase files`,
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
sentry.CaptureMessage("start to convert HAR to testcases")
var outputFiles []string
for _, arg := range args {
var outputPath string

View File

@@ -1,6 +1,7 @@
package cmd
import (
"github.com/getsentry/sentry-go"
"github.com/spf13/cobra"
"github.com/httprunner/hrp"
@@ -16,6 +17,7 @@ var runCmd = &cobra.Command{
$ hrp run examples/ # run testcases in specified folder`,
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
sentry.CaptureMessage("start to run API tests")
var paths []hrp.ITestCase
for _, arg := range args {
paths = append(paths, &hrp.TestCasePath{Path: arg})

View File

@@ -1,7 +1,15 @@
package main
import "github.com/httprunner/hrp/hrp/cmd"
import (
"time"
"github.com/getsentry/sentry-go"
"github.com/httprunner/hrp/hrp/cmd"
)
func main() {
// Flush buffered events before the program terminates.
defer sentry.Flush(2 * time.Second)
cmd.Execute()
}