Coder Social home page Coder Social logo

getsentry / sentry-clj Goto Github PK

View Code? Open in Web Editor NEW
101.0 32.0 29.0 262 KB

Sentry SDK for Clojure

Home Page: https://cljdoc.org/d/io.sentry/sentry-clj

License: Eclipse Public License 1.0

Clojure 98.79% Shell 1.21%
clojure sentry crash-reporting tag-production

sentry-clj's People

Contributors

bago2k4 avatar bcobb avatar bretthoerner avatar bruno-garcia avatar codahale avatar danieltdt avatar deepxg avatar dependabot[bot] avatar dergutemoritz avatar dharrigan avatar dmednis avatar gpind avatar karuta0825 avatar mattjohnsonpint avatar mping-exo avatar mslupny avatar rboyd avatar ricardosllm avatar wickedshell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sentry-clj's Issues

Network_error

Environment

Sentry.java version 6.13.0 Leiningen 2.10.0 on Java 11.0.18 OpenJDK 64-Bit Server VM

Steps to Reproduce

I installed sentry on a clojure (backend) project and deployed on a pod. It works fine for a while but i notice that sentry stopped to getting alerts. I tested locally running a docker container and connect me to the repl i made a simple test using the send-event function.

(sentry/send-event (Exception. "test") "Test")
"944ce0722a334bf9b2888ed51f477717"

And when I check the docker logs, it appears that the expected result is the event ID, indicating that it is functioning properly. But notings shows on my project sentry

Here are my docker logs:

2023-04-26 16:03:16 DEBUG: Capturing event: 944ce0722a334bf9b2888ed51f477717
2023-04-26 16:03:16 INFO: sentry-external-modules.txt file was not found.
2023-04-26 16:03:16 INFO: Session is null on scope.withSession
2023-04-26 16:03:16 DEBUG: Serializing object: {
2023-04-26 16:03:16     "timestamp": "2023-04-26T21:03:16.515Z",
2023-04-26 16:03:16     "message": {
2023-04-26 16:03:16             "message": "Test test"
2023-04-26 16:03:16     },
2023-04-26 16:03:16     "exception": {
2023-04-26 16:03:16             "values": [
2023-04-26 16:03:16                     {
2023-04-26 16:03:16                             "type": "Exception",
2023-04-26 16:03:16                             "value": "test",
2023-04-26 16:03:16                             "module": "java.lang",
2023-04-26 16:03:16                             "thread_id": 61,
2023-04-26 16:03:16                             "stacktrace": {
2023-04-26 16:03:16                                     "frames": [
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "Thread.java",
2023-04-26 16:03:16                                                     "function": "run",
2023-04-26 16:03:16                                                     "module": "java.lang.Thread",
2023-04-26 16:03:16                                                     "lineno": 833,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "AFn.java",
2023-04-26 16:03:16                                                     "function": "run",
2023-04-26 16:03:16                                                     "module": "clojure.lang.AFn",
2023-04-26 16:03:16                                                     "lineno": 22,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "session.clj",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "nrepl.middleware.session$session_exec$main_loop__32319",
2023-04-26 16:03:16                                                     "lineno": 217,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "session.clj",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "nrepl.middleware.session$session_exec$main_loop__32319$fn__32323",
2023-04-26 16:03:16                                                     "lineno": 218,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "AFn.java",
2023-04-26 16:03:16                                                     "function": "run",
2023-04-26 16:03:16                                                     "module": "clojure.lang.AFn",
2023-04-26 16:03:16                                                     "lineno": 22,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "interruptible_eval.clj",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "nrepl.middleware.interruptible_eval$interruptible_eval$fn__32249$fn__32253",
2023-04-26 16:03:16                                                     "lineno": 152,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "interruptible_eval.clj",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "nrepl.middleware.interruptible_eval$evaluate",
2023-04-26 16:03:16                                                     "lineno": 56,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "interruptible_eval.clj",
2023-04-26 16:03:16                                                     "function": "invokeStatic",
2023-04-26 16:03:16                                                     "module": "nrepl.middleware.interruptible_eval$evaluate",
2023-04-26 16:03:16                                                     "lineno": 84,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "RestFn.java",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "clojure.lang.RestFn",
2023-04-26 16:03:16                                                     "lineno": 1523,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "main.clj",
2023-04-26 16:03:16                                                     "function": "doInvoke",
2023-04-26 16:03:16                                                     "module": "clojure.main$repl",
2023-04-26 16:03:16                                                     "lineno": 368,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "main.clj",
2023-04-26 16:03:16                                                     "function": "invokeStatic",
2023-04-26 16:03:16                                                     "module": "clojure.main$repl",
2023-04-26 16:03:16                                                     "lineno": 458,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "main.clj",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "clojure.main$repl$fn__9215",
2023-04-26 16:03:16                                                     "lineno": 458,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "main.clj",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "clojure.main$repl$read_eval_print__9206",
2023-04-26 16:03:16                                                     "lineno": 437,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "main.clj",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "clojure.main$repl$read_eval_print__9206$fn__9209",
2023-04-26 16:03:16                                                     "lineno": 437,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "interruptible_eval.clj",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "nrepl.middleware.interruptible_eval$evaluate$fn__32216",
2023-04-26 16:03:16                                                     "lineno": 87,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "RestFn.java",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "clojure.lang.RestFn",
2023-04-26 16:03:16                                                     "lineno": 425,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "core.clj",
2023-04-26 16:03:16                                                     "function": "doInvoke",
2023-04-26 16:03:16                                                     "module": "clojure.core$with_bindings_STAR_",
2023-04-26 16:03:16                                                     "lineno": 1990,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "core.clj",
2023-04-26 16:03:16                                                     "function": "invokeStatic",
2023-04-26 16:03:16                                                     "module": "clojure.core$with_bindings_STAR_",
2023-04-26 16:03:16                                                     "lineno": 1990,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "core.clj",
2023-04-26 16:03:16                                                     "function": "invokeStatic",
2023-04-26 16:03:16                                                     "module": "clojure.core$apply",
2023-04-26 16:03:16                                                     "lineno": 667,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "AFn.java",
2023-04-26 16:03:16                                                     "function": "applyTo",
2023-04-26 16:03:16                                                     "module": "clojure.lang.AFn",
2023-04-26 16:03:16                                                     "lineno": 144,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "AFn.java",
2023-04-26 16:03:16                                                     "function": "applyToHelper",
2023-04-26 16:03:16                                                     "module": "clojure.lang.AFn",
2023-04-26 16:03:16                                                     "lineno": 152,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "interruptible_eval.clj",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "nrepl.middleware.interruptible_eval$evaluate$fn__32216$fn__32217",
2023-04-26 16:03:16                                                     "lineno": 87,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "core.clj",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "clojure.core$eval",
2023-04-26 16:03:16                                                     "lineno": 3211,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "core.clj",
2023-04-26 16:03:16                                                     "function": "invokeStatic",
2023-04-26 16:03:16                                                     "module": "clojure.core$eval",
2023-04-26 16:03:16                                                     "lineno": 3215,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "Compiler.java",
2023-04-26 16:03:16                                                     "function": "eval",
2023-04-26 16:03:16                                                     "module": "clojure.lang.Compiler",
2023-04-26 16:03:16                                                     "lineno": 7149,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "Compiler.java",
2023-04-26 16:03:16                                                     "function": "eval",
2023-04-26 16:03:16                                                     "module": "clojure.lang.Compiler",
2023-04-26 16:03:16                                                     "lineno": 7194,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "form-init1439623880664568493.clj",
2023-04-26 16:03:16                                                     "function": "invoke",
2023-04-26 16:03:16                                                     "module": "gofapi.core$eval41404",
2023-04-26 16:03:16                                                     "lineno": 27,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             },
2023-04-26 16:03:16                                             {
2023-04-26 16:03:16                                                     "filename": "form-init1439623880664568493.clj",
2023-04-26 16:03:16                                                     "function": "invokeStatic",
2023-04-26 16:03:16                                                     "module": "gofapi.core$eval41404",
2023-04-26 16:03:16                                                     "lineno": 27,
2023-04-26 16:03:16                                                     "in_app": false,
2023-04-26 16:03:16                                                     "native": false
2023-04-26 16:03:16                                             }
2023-04-26 16:03:16                                     ]
2023-04-26 16:03:16                             }
2023-04-26 16:03:16                     }
2023-04-26 16:03:16             ]
2023-04-26 16:03:16     },
2023-04-26 16:03:16     "fingerprint": [],
2023-04-26 16:03:16     "modules": {},
2023-04-26 16:03:16     "event_id": "944ce0722a334bf9b2888ed51f477717",
2023-04-26 16:03:16     "contexts": {
2023-04-26 16:03:16             "runtime": {
2023-04-26 16:03:16                     "name": "Eclipse Adoptium",
2023-04-26 16:03:16                     "version": "17.0.7"
2023-04-26 16:03:16             }
2023-04-26 16:03:16     },
2023-04-26 16:03:16     "sdk": {
2023-04-26 16:03:16             "name": "sentry.java",
2023-04-26 16:03:16             "version": "6.13.0",
2023-04-26 16:03:16             "packages": [
2023-04-26 16:03:16                     {
2023-04-26 16:03:16                             "name": "maven:io.sentry:sentry",
2023-04-26 16:03:16                             "version": "6.13.0"
2023-04-26 16:03:16                     }
2023-04-26 16:03:16             ]
2023-04-26 16:03:16     },
2023-04-26 16:03:16     "environment": "local-dev",
2023-04-26 16:03:16     "platform": "java",
2023-04-26 16:03:16     "server_name": "e73618e548b4"
2023-04-26 16:03:16 }
2023-04-26 16:03:16 DEBUG: Envelope sent successfully.
2023-04-26 16:03:16 DEBUG: Envelope flushed

I also tried running a similar command connecting the REPL to one POD that is running the same project with the same env vars and i get this:


`clj꞉myapp.core꞉> (sentry/send-event (Exception. "testing") "testing!!" )

-->> "dda4a47f31eb48bbb0992a1651c8edca"

Here is the pod's logs:

"fingerprint": [],
    "modules": {},
    "event_id": "dda4a47f31eb48bbb0992a1651c8edca",
    "contexts": {
        "runtime": {
            "name": "Eclipse Adoptium",
            "version": "17.0.6"
        }
    },
    "sdk": {
        "name": "sentry.java",
        "version": "6.13.0",

...

DEBUG: Serializing object: {
    "timestamp": "2023-04-26T19:11:02.289Z",
    "discarded_events": [
        {
            "reason": "queue_overflow",
            "category": "error",
            "quantity": 480
        },
        {
            "reason": "network_error",
            "category": "error",
            "quantity": 720
        }
    ]
}
DEBUG: Envelope sent successfully.
DEBUG: Envelope flushed

Expected Result

A new event should appear in my Sentry project.

Actual Result

No new events were collected by Sentry.

I already check the DSN.

send-event ignores DSN query string parameters

Because sentry-clj calls (Sentry/capture Event) [1] rather than (Sentry/capture EventBuilder) [2] on the underlying Java library, release and environment are always null.

We set the release in the sentry DSN as a query parameter. The clojure lib calls (map->Event), which sets all the unspecified params on the Event to nil, and this overrides the DSN parameters

[1] https://github.com/getsentry/sentry-java/blob/master/sentry/src/main/java/io/sentry/SentryClient.java#L126-L143
[2] https://github.com/getsentry/sentry-java/blob/master/sentry/src/main/java/io/sentry/SentryClient.java#L150-L156

class io.sentry.NoOpTransaction cannot be cast to class io.sentry.SentryTracer

Environment

How do you use Sentry? Sentry SaaS (sentry.io)

Which SDK and version? sentry-clj 5.7.172

Steps to Reproduce

  1. Write a ring handler that throws an exception.
  2. Enable wrap-report-exceptions and wrap-sentry-tracing
  3. Exception is thrown for any request.

Expected Result

500 error is returned, trace is sent.

Actual Result

java.lang.ClassCastException: class io.sentry.NoOpTransaction cannot be cast to class io.sentry.SentryTracer (io.sentry.NoOpTransaction and io.sentry.SentryTracer are in unnamed module of loader 'app')
at sentry_clj.tracing$finish_transaction_BANG_.invokeStatic(tracing.clj:66)
at sentry_clj.tracing$finish_transaction_BANG_.invoke(tracing.clj:66)
at sentry_clj.ring$wrap_sentry_tracing$fn__16357.invoke(ring.clj:167)
at sentry_clj.ring$wrap_report_exceptions$fn__16354.invoke(ring.clj:132)
at shared.web$wrap_request_id$fn__19685.invoke(web.clj:86)
at ring.adapter.jetty$proxy_handler$fn__19472.invoke(jetty.clj:27)
at ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$ff19274a.handle
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.Server.handle(Server.java:516)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:400)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:645)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:392)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
at java.lang.Thread.run(Thread.java:833)


I think the fix here is to pass the interface ITransaction instead of SentryTracer as the type hint at

[^SentryTracer transaction]
and probably
[^SentryTracer transaction status]
as well.

I have no idea what `message.formatted` means

:formatted - A String containing the fully formatted message. If missing, Sentry will try to interpolate the message.

so far, i can't find an example of this, other than incorrect documentation from sentry's docs that are linked to on this README.

https://develop.sentry.dev/sdk/event-payloads/message/

the incorrect part is the required label, which is completely contradicted in the description of that field.

is this supposed to be json with indenting?
can i only have this field and none of the other fields? message params?
should i use all of the fields?
what should the params fields contain?
i'm only asking because the documentation is unreliable.

example from the docs, which don't really help me understand how i should make my messages.

{
  "message": {
    "message": "My raw message with interpreted strings like %s",
    "params": ["this"]
  }
}

Before/after context source

The only way I've seen fit to add source context was to do a healthy bit of hackery. Could there be a better default way of providing this information?

Event not sent to Sentry if data in ExceptionInfo exception is not GSON serializable

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

Which SDK and version?
[io.sentry/sentry-clj "5.0.152"]

Steps to Reproduce

Run the following clojure code in a REPL:

(do
    (require '[clj-http.client :as http])             ;; requires [clj-http/clj-http "3.10.3"]
    (require '[sentry-clj.core :as sentry])

    (sentry/init! **DSN** ;; replace with DSN from Sentry account
                  {:debug true})
    (try
      (http/get "http://example.com/non-existent")
      (catch Exception e
        (sentry/send-event {:message (.getMessage e) :throwable e}))))

Expected Result

I hoped that the exception would be successfully sent to Sentry.

Actual Result

Logging output (Debug mode is turned on):

INFO: Initializing SDK with DSN: ******
INFO: No outbox dir path is defined in options.
INFO: GlobalHubMode: 'false'
DEBUG: UncaughtExceptionHandlerIntegration enabled: true
DEBUG: UncaughtExceptionHandlerIntegration installed.
DEBUG: ShutdownHookIntegration installed.
DEBUG: Capturing event: fdd3e89775334596ba7f56dc8ed159d1
INFO: Session is null on scope.withSession
=> "fdd3e89775334596ba7f56dc8ed159d1"
ERROR: Failed to create envelope item. Dropping it.
java.lang.IllegalArgumentException: class org.apache.http.impl.client.InternalHttpClient declares multiple JSON fields named log
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:172)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
	at com.google.gson.Gson.getAdapter(Gson.java:458)
	at com.google.gson.Gson.toJson(Gson.java:696)
	at com.google.gson.Gson.toJsonTree(Gson.java:597)
	at com.google.gson.Gson.toJsonTree(Gson.java:576)
	at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.serialize(TreeTypeAdapter.java:155)
	at io.sentry.adapters.MapAdapter.serialize(MapAdapter.java:28)
	at io.sentry.adapters.MapAdapter.serialize(MapAdapter.java:14)
	at com.google.gson.internal.bind.TreeTypeAdapter.write(TreeTypeAdapter.java:81)
	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:127)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:245)
	at io.sentry.UnknownPropertiesTypeAdapterFactory$UnknownPropertiesTypeAdapter.write(UnknownPropertiesTypeAdapterFactory.java:103)
	at io.sentry.UnknownPropertiesTypeAdapterFactory$UnknownPropertiesTypeAdapter.write(UnknownPropertiesTypeAdapterFactory.java:58)
	at com.google.gson.Gson.toJson(Gson.java:704)
	at com.google.gson.Gson.toJson(Gson.java:683)
	at com.google.gson.Gson.toJson(Gson.java:638)
	at com.google.gson.Gson.toJson(Gson.java:618)
	at io.sentry.GsonSerializer.serialize(GsonSerializer.java:143)
	at io.sentry.SentryEnvelopeItem.lambda$fromEvent$3(SentryEnvelopeItem.java:109)
	at io.sentry.SentryEnvelopeItem$CachedItem.getBytes(SentryEnvelopeItem.java:256)
	at io.sentry.SentryEnvelopeItem.lambda$fromEvent$5(SentryEnvelopeItem.java:122)
	at io.sentry.SentryEnvelopeItem.getData(SentryEnvelopeItem.java:56)
	at io.sentry.GsonSerializer.serialize(GsonSerializer.java:173)
	at io.sentry.transport.HttpConnection.send(HttpConnection.java:155)
	at io.sentry.transport.AsyncHttpTransport$EnvelopeSender.flush(AsyncHttpTransport.java:210)
	at io.sentry.transport.AsyncHttpTransport$EnvelopeSender.run(AsyncHttpTransport.java:183)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

ERROR: Request failed, API returned 400
ERROR: {"detail":"empty envelope"}
ERROR: The transport failed to send the envelope with response code 400
ERROR: Envelope submission failed 
 java.lang.IllegalStateException: The transport failed to send the envelope with response code 400
java.lang.IllegalStateException: The transport failed to send the envelope with response code 400
	at io.sentry.transport.AsyncHttpTransport$EnvelopeSender.flush(AsyncHttpTransport.java:220)
	at io.sentry.transport.AsyncHttpTransport$EnvelopeSender.run(AsyncHttpTransport.java:183)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

Additional Info

It seems that the problem is that the clj-http library includes the client object in the map of ex-info data when constructing an ex-info exception for an unsuccessful HTTP response. sentry-clj indiscriminately merges all of the data returned from ex-data into the context of the Sentry event, which causes the underlying Java library to fail if values in the data aren't serializable as JSON.

Streamline and align the "Getting Started" docs to fit in the new structure

Problem Statement

  • The "Getting Started" documentation for sentry-clj platforms may not conform to the newly defined format, which includes the steps "Install", "Configure", "Verify", and the optional "Next Steps".
    • The "Verify" step is not always available and it is a very important step that helps the user to verify that the installation and configuration were done correctly.
  • New users onboarding with Sentry may find the existing documentation extensive and unclear. The "Getting Started" guide should cover the basics, while more advanced configurations shall live on the sentry-docs website.
  • Some copies and code snippets in the documentation may be outdated.

Solution Brainstorm

The task goals are as follows:

  • Thoroughly review all sentry-clj platform documentation, and reorganize its content into structured headings: 'Install,' 'Configure,' 'Verify,' and the optional 'Next Steps.'
  • The onboarding documentation should strictly focus on the basics to help users get started. Advanced configurations should be available in the complete documentation on the sentry-docs website.
  • Essential information for new users should be included under the new 'Notes' section in the onboarding documentation.
  • Update code snippets and copies as necessary.
  • If a "Verify" step is missing, include it in the documentation.

Please refer to the "Frontendend Handbook" guide in our "Sentry" main repository for assistance in adding and updating the getting started docs: Frontendend Handbook.

Project: getsentry/team-sdks#23

Filtering events with beforeSend

Would be helpful if there will be any support to filter events (i.e based on Environment or some any other removal), this is supported in the Java SDK with beforeSend, and can be added to the sentry/init! method..

before-send-fn not being executed during tracing events

Environment

How do you use Sentry?
Sentry SaaS (sentry.io) or self-hosted/on-premise (which version?)
self-hosted

Which SDK and version?
e.g: JavaScript 5.11.1, .NET 1.2.0
[io.sentry/sentry-clj "5.7.180"]
[io.sentry/sentry "5.7.4"]

Steps to Reproduce

on the init function

:before-send-fn (fn [event _] (.setServerName event "fred") event)

tracing events still don't have the servername modified

Expected Result

When the before send function is set in the initialisation step it should be considered for all tracing and exception events, in this simple case setting the server name as "fred"

Actual Result

The event is not modified for tracing events

Event X make different event Y instead in Sentry

It is very werid bug and I have big problem how to report it, because I can't paste :throwable, because it contains data, which I can't public.

I send event X, but Sentry report on slack and show in panel only last event Y, which has totally different :throwable and is different event from the past. Event X doesn't exist in Sentry, at least I can't search it. So in magic way event X is transformed into event Y and I have no idea what is happening. In 100% times the same X always produce the same Y.

Code below is not really important, but I paste it anyway.

(sentry/send-event (merge sentry-base
                          {:level (get timbre->sentry-levels level)
                           :fingerprint (when (or error-message (force msg_))
                                          (->> (set [?ns-str error-message (force msg_)])
                                               (clojure.set/union causes)
                                               (remove #(= "" %))
                                               (remove nil?)))
                           :logger ?ns-str
                           :extra context
                           :message (not-empty (force msg_))
                           :throwable ?err}))

For debug reasons I save this map above to foo atom to be 100% sure what I am sending to Sentry.

(sentry/send-event @foo) return 3de6efe8c7564fbe86a489d3c8de7ae8.
Slack bot shows me a link to new event aae12a66f8e84edfac45a18958bfbfa8. It is also the only one event created in Sentry panel.

When I use 3de6efe8c7564fbe86a489d3c8de7ae8 (right event X) in Sentry search panel it shows me 1 position, when I click on it I see aae12a66f8e84edfac45a18958bfbfa8 (wrong event Y).
I am going to open "Events" and try to search here again by 3de6efe8c7564fbe86a489d3c8de7ae8 and I see "Sorry, no events match your search query.".

It blows my mind. I guess it could be Sentry bug in engine, but I report it here, because I use this library to send events. At least I don't know better place.

My username in Sentry is kwladyka.

Incorrect display of nested maps

Environment

How do you use Sentry?

  • Sentry SaaS (sentry.io)

Which SDK and version?

  • io.sentry/sentry-clj {:mvn/version "5.6.169"}

Steps to Reproduce

When sending event extra data, they are not displayed correctly in the issue detail.

(sentry/init! (:sentry/dsn "..."))
  
(sentry/send-event
 {:message "Test"
  :extra {:var1 "val1"
          :var2 {:a {:b [:c :d {:e :f} #{:g :h}]}}}})

(sentry/send-event
 {:throwable (ex-info "Sample exception"
                      {:var1 "val1"
                       :var2 {:a {:b [:c :d {:e :f} #{:g :h}]}}})}))

Expected Result

Correct display of nested data structures in issue detail.

Actual Result

Formatted view
Screenshot 2022-02-11 v 15 23 00

Raw view:

{"a":{"b":[{"hasheq":-1763192079,"sym":{"_hasheq":-122660552,"name":"c"}},{"hasheq":1972142424,"sym":{"_hasheq":-682293345,"name":"d"}},{"e":{"hasheq":-1597136552,"sym":"{\"_hasheq\":43394975,\"name\":\"f\"}"}},[{"hasheq":1738089905,"sym":"{\"_hasheq\":-916345864,\"name\":\"g\"}"},{"hasheq":1109658740,"sym":"{\"_hasheq\":-1544777029,\"name\":\"h\"}"}]]}}

Outdated dependency on the Java client

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

Which SDK and version?
Clojure v5.0.149

Steps to Reproduce

Report an exception as documented.

Expected Result

No "warning" about Sentry client update at the bottom of the https://sentry.io/organizations//issues//?project= page

Actual Result

I'm seeing a Sentry client update messge on the website:

We recommend you update your SDK from @v5.0.1 to @v5.1.0 (All sentry packages should be updated and their versions should match)

traces-sample-fn not being called

Environment

  • Clojure 1.11.1
  • sentry-clj 6.4.185

Steps to Reproduce

(defn traces-sampler
  [{:keys [custom-sample-context transaction-context]}]
  (println "-> custom-sample-context:" custom-sample-context)
  (println "-> transaction-context:" transaction-context)
  0.1)

(sentry/init! config/sentry-endpoint
              {:server-name              config/application-name
               :environment              config/environment
               :traces-sample-fn         traces-sampler
               :uncaught-handler-enabled true
               :before-send-fn           (fn [^SentryEvent event ^Hint _hint]
                                           (println (format "[%s] Reporting to Sentry: %s"
                                                            (str (.getLevel event))
                                                            (.getMessage (.getMessage event))))
                                           event)})

(sentry/send-event
      {:message     "This is a test"
       :server-name config/application-name
       :level       :error
       :throwable   (Exception. "Boom!")})

Expected Result

I should see the output of

  (println "-> custom-sample-context:" custom-sample-context)
  (println "-> transaction-context:" transaction-context)

Actual Result

I don't see that output. It looks like the traces-sampler function is not being called.
Am I defining the traces-sampler function correctly? Couldn't find any examples for it, so just guessed from the source code. Thank you.

Why does this exist?

(defrecord CljInterface [^String interface-name ^Object value]
SentryInterface
(getInterfaceName [_]
interface-name))
(defrecord CljInterfaceBinding []
InterfaceBinding
(writeInterface [_ jg interface]
(gen/generate jg (:value interface) fac/default-date-format nil nil)))
(def ^SentryClientFactory factory
(proxy [DefaultSentryClientFactory] []
(createMarshaller [^Dsn dsn]
(let [^JsonMarshaller marshaller (proxy-super createMarshaller dsn)]
(.addInterfaceBinding marshaller CljInterface (->CljInterfaceBinding))
marshaller))))

Is there a reason why this code exists? What happens without internal.clj?

EventBuilder cannot be cast to Event

Using Clojure 1.9.0 and [io.sentry/sentry-clj "0.7.0", I'm getting

#error {
 :cause "io.sentry.event.EventBuilder cannot be cast to io.sentry.event.Event"
 :via
 [{:type java.lang.ClassCastException
   :message "io.sentry.event.EventBuilder cannot be cast to io.sentry.event.Event"
   :at [sentry_clj.core$send_event invokeStatic "core.clj" 144]}]
 :trace
 [[sentry_clj.core$send_event invokeStatic "core.clj" 144]
  [sentry_clj.core$send_event invoke "core.clj" 123]
  [user$eval1616 invokeStatic "NO_SOURCE_FILE" 7]
  [user$eval1616 invoke "NO_SOURCE_FILE" 7]
  [clojure.lang.Compiler eval "Compiler.java" 7062]
  [clojure.lang.Compiler eval "Compiler.java" 7025]
  [clojure.core$eval invokeStatic "core.clj" 3206]
  [clojure.core$eval invoke "core.clj" 3202]
  [clojure.main$repl$read_eval_print__8572$fn__8575 invoke "main.clj" 243]
  [clojure.main$repl$read_eval_print__8572 invoke "main.clj" 243]
  [clojure.main$repl$fn__8581 invoke "main.clj" 261]
  [clojure.main$repl invokeStatic "main.clj" 261]
  [clojure.main$repl_opt invokeStatic "main.clj" 325]
  [clojure.main$main invokeStatic "main.clj" 424]
  [clojure.main$main doInvoke "main.clj" 387]
  [clojure.lang.RestFn invoke "RestFn.java" 397]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.RestFn applyTo "RestFn.java" 132]
  [clojure.lang.Var applyTo "Var.java" 702]
  [clojure.main main "main.java" 37]]}

for the following code (run at the REPL):

(require '[sentry-clj.core :as sentry])
(def sentry-dsn "")
(sentry/init! sentry-dsn)
(sentry/send-event {:throwable (Exception. "Foo bar!")})

Using version 0.6.1 works fine 👍

Crash when using sentry-log4j: java.lang.NoSuchMethodError: io.sentry.SentryClient.getMdcTags()Ljava/util/Set;

This is probably reproducible in Java.

Minimal reproduction: https://github.com/not-raspberry/sentry-clojure-log4j-repro

Dependencies: https://github.com/not-raspberry/sentry-clojure-log4j-repro/blob/master/project.clj#L7-L11

Output:

$ lein run
2017-11-17 14:21:20,477 ERROR sentry-repro.core: ERROR
2017-11-17 14:21:20,492 INFO  io.sentry.DefaultSentryClientFactory: Using an HTTPS connection to Sentry.
Exception in thread "main" java.lang.NoSuchMethodError: io.sentry.SentryClient.getMdcTags()Ljava/util/Set;, compiling:(/tmp/form-init720909482945021916.clj:1:72)
        at clojure.lang.Compiler.load(Compiler.java:7391)
        at clojure.lang.Compiler.loadFile(Compiler.java:7317)
        at clojure.main$load_script.invokeStatic(main.clj:275)
        at clojure.main$init_opt.invokeStatic(main.clj:277)
        at clojure.main$init_opt.invoke(main.clj:277)
        at clojure.main$initialize.invokeStatic(main.clj:308)
        at clojure.main$null_opt.invokeStatic(main.clj:342)
        at clojure.main$null_opt.invoke(main.clj:339)
        at clojure.main$main.invokeStatic(main.clj:421)
        at clojure.main$main.doInvoke(main.clj:384)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.lang.Var.invoke(Var.java:383)
        at clojure.lang.AFn.applyToHelper(AFn.java:156)
        at clojure.lang.Var.applyTo(Var.java:700)
        at clojure.main.main(main.java:37)
Caused by: java.lang.NoSuchMethodError: io.sentry.SentryClient.getMdcTags()Ljava/util/Set;
        at io.sentry.log4j.SentryAppender.createEventBuilder(SentryAppender.java:131)
        at io.sentry.log4j.SentryAppender.append(SentryAppender.java:84)
        at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
        at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
        at org.apache.log4j.Category.callAppenders(Category.java:206)
        at org.apache.log4j.Category.forcedLog(Category.java:391)
        at org.apache.log4j.Category.log(Category.java:856)
        at org.slf4j.impl.Log4jLoggerAdapter.error(Log4jLoggerAdapter.java:498)
        at clojure.tools.logging$eval436$fn__441.invoke(logging.clj:286)
        at clojure.tools.logging.impl$eval178$fn__192$G__169__203.invoke(impl.clj:16)
        at clojure.tools.logging$log_STAR_.invokeStatic(logging.clj:64)
        at clojure.tools.logging$log_STAR_.invoke(logging.clj:43)
        at sentry_repro.core$_main.invokeStatic(core.clj:7)
        at sentry_repro.core$_main.doInvoke(core.clj:6)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.Var.invoke(Var.java:375)
        at user$eval3130.invokeStatic(form-init720909482945021916.clj:1)
        at user$eval3130.invoke(form-init720909482945021916.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:6927)
        at clojure.lang.Compiler.eval(Compiler.java:6917)
        at clojure.lang.Compiler.load(Compiler.java:7379)
        ... 14 more
2017-11-17 14:21:20,501 INFO  io.sentry.connection.AsyncConnection: Automatic shutdown of the async connection
2017-11-17 14:21:20,501 INFO  io.sentry.connection.AsyncConnection: Gracefully shutdown sentry threads.
2017-11-17 14:21:20,501 INFO  io.sentry.connection.AsyncConnection: Shutdown finished.

Support for special contexts

Right now the context code lets you specify extra keys and values, and has a hard coded representation. However there are various special keys that Sentry supports (e.g. the "os" key) which display slightly more nicely in the Sentry UI. In the underlying Java library these have explicit classes to represent them.

I'm wondering if there's any interest in supporting these special keys better. One drawback would be that changing the way these keys are handled would change the data sent to the server and therefore potentially break people's existing setups, so it'd need to be opt in.

Uncaught handler option documentation does not match code

In the README, it says that :uncaught-handler-enabled supersedes the deprecated :enable-uncaught-exception-handler.

If you look at the changelog, it says for version 5.5.165:

Deprecated enable-uncaught-exception-handler and added uncaught-handler-enabled to improve naming consistency with Java SDK.

but then for version 6.13.191 it says:

Remove uncaught-handler-enabled as it's been removed from the Java SDK

  • Use enable-uncaught-exception-handler instead

And indeed, in this commit enable-uncaught-exception-handler was deprecated in favor of uncaught-handler-enabled. However, it was never officially "undeprecated" and in this commit the newer (favored) option uncaught-handler-enabled was unceremoniously removed and replaced with the old (supposedly deprecated) option.

So it's a bit unclear what the intention is. From where I'm standing, it looks like some back-and-forth deliberation was done and eventually the decision was made that the deprecation and the new name didn't make sense and essentially rolled back to the pre-deprecation situation.

If that's indeed the situation and this is as intended, please update the README to correctly reflect the fact that :uncaught-handler-enabled doesn't actually do anything (i.e. remove mentions of it), and that :enable-uncaught-exception-handler should be used (i.e., remove the sentence that says it's deprecated).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.