1
0
mirror of https://github.com/owenthereal/jqplay.git synced 2025-04-19 06:02:17 +03:00

Fix sentry not working

This commit is contained in:
Owen Ou 2024-01-11 21:27:22 -08:00
parent d855bbc4f8
commit c8887ab01d
No known key found for this signature in database
GPG Key ID: 6CDA9490BEB1E446
3 changed files with 23 additions and 7 deletions

View File

@ -12,7 +12,9 @@ RUN apt-get update && \
build-essential \
autoconf \
libtool \
git
git \
; \
apt-get clean
RUN git clone --recurse-submodules https://github.com/jqlang/jq.git && \
cd jq && \
@ -60,6 +62,17 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
FROM ubuntu
ENV DEBIAN_FRONTEND=noninteractive \
DEBCONF_NONINTERACTIVE_SEEN=true \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8
RUN apt-get update && \
apt-get install -y \
ca-certificates \
&& \
apt-get clean
RUN useradd -m jqplay
USER jqplay

View File

@ -38,6 +38,7 @@ func Load() (*Config, error) {
if dsn := conf.SentryDSN; dsn != "" {
if err := sentry.Init(sentry.ClientOptions{
Dsn: dsn,
Debug: !conf.IsProd(),
EnableTracing: true,
TracesSampleRate: 0.2,
AttachStacktrace: true,

View File

@ -3,9 +3,7 @@ package server
import (
"context"
"html/template"
"log/slog"
"net/http"
"os"
"syscall"
"time"
@ -73,16 +71,20 @@ func newHTTPServer(cfg *config.Config, db *DB) (*http.Server, error) {
router := gin.New()
router.Use(
sentrygin.New(sentrygin.Options{
Repanic: true,
}),
middleware.Timeout(requestTimeout),
middleware.LimitContentLength(10),
middleware.Secure(cfg.IsProd()),
middleware.RequestID(),
middleware.Logger(slog.New(slog.NewJSONHandler(os.Stderr, nil))),
middleware.Logger(cfg.Logger),
gin.Recovery(),
)
if cfg.SentryDSN != "" {
router.Use(
sentrygin.New(sentrygin.Options{
Repanic: true,
}),
)
}
router.SetHTMLTemplate(tmpl)
h := &JQHandler{JQExec: jq.NewJQExec(), Config: cfg, DB: db}