如何在哨兵中显示完整的堆栈跟踪

时间:2017-07-24 08:04:54

标签: java logback sentry

Sentry具有特定功能"In Application"。它从stacktraces中隐藏了许多有关来自公共库和框架的调用的有用信息。

他们提供财产

stacktrace.app.packages=com.mycompany,com.other.name

配置必须显示的包,但是如果stacktrace看起来像:

Exception: exception message
    at package.which.must.be.shown.MyClass.method
    at package.from.common.library.CommonClass.method
    at pachage.which.must.be.shown.NyClass2.method2
    ...

然后哨兵在调用CommonClass后隐藏所有内容,我们无法看到对MyClass2的调用

我使用sentry版本1.3.0 for java with sentry-logback。

如何禁用"在应用程序"在哨兵中使用功能并在UI中获取所有堆栈跟踪?

UPD:
我在日志中看到的内容:


    13:56:35.065 [main] ERROR my.package.MyClass - java.io.IOException: org.springframework.ws.client.WebServiceIOException: I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at my.package.MyClass.someMethod1(...)
        at my.package.MyClass.someMethod2(...)
        at my.package.MyClass.someMethod3(...)
        at my.package.MyClass.someMethod4(...)
        at my.package.MyClass.someMethod5(...)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58)
    Caused by: org.springframework.ws.client.WebServiceIOException: I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:561)
        at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)
        at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:383)
        at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:373)
        at my.package.MyClass.someMethod6(...)
        ... 18 more
    Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1316)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1291)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
        at org.springframework.ws.transport.http.HttpUrlConnection.getRequestOutputStream(HttpUrlConnection.java:89)
        at org.springframework.ws.transport.AbstractSenderConnection$RequestTransportOutputStream.createOutputStream(AbstractSenderConnection.java:87)
        at org.springframework.ws.transport.TransportOutputStream.getOutputStream(TransportOutputStream.java:41)
        at org.springframework.ws.transport.TransportOutputStream.write(TransportOutputStream.java:64)
        at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:1314)
        at org.springframework.ws.soap.saaj.SaajSoapMessage.writeTo(SaajSoapMessage.java:275)
        at org.springframework.ws.transport.AbstractWebServiceConnection.send(AbstractWebServiceConnection.java:46)
        at org.springframework.ws.client.core.WebServiceTemplate.sendRequest(WebServiceTemplate.java:658)
        at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:606)
        at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
        ... 22 more
    Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
        at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
        at sun.security.validator.Validator.validate(Validator.java:260)
        at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491)
        ... 44 more
    Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
        at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
        at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
        ... 50 more

我在Sentry UI中看到的" Raw"启用模式:

Message:

    java.io.IOException: org.springframework.ws.client.WebServiceIOException: I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at my.package.MyClass.someMethod1(...)
        at my.package.MyClass.someMethod2(...)
        at my.package.MyClass.someMethod3(...)
        at ...

Stacktrace: 

    at my.package.MyClass.someMethod4(...)
        at my.package.MyClass.someMethod5(...)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java)

Json file: 

    {
      "id": "a66cfa8cadc44b1faf3f6024cc49155d",
      "project": 2,
      "release": null,
      "dist": null,
      "platform": "java",
      "culprit": "my.package.MyClass.someMethod4(...)",
      "message": "java.io.IOException: org.springframework.ws.client.WebServiceIOException: I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target\n\tat my.package.MyClass.someMethod1(...)\n\tat my.package.MyClass.someMethod2(...)\n\tat my.package.MyClass.someMethod3(...)\n\tat ...",
      "datetime": "2017-07-24T13:56:35.000000Z",
      "time_spent": null,
      "tags": [
        [
          "transaction",
          "my.package.MyClass.someMethod4(...)"
        ],
        [
          "logger",
          "my.package.MyClass"
        ],
        [
          "server_name",
          "63bf11aa43e5"
        ],
        [
          "level",
          "error"
        ]
      ],
      "errors": [],
      "extra": {
        "Sentry-Threadname": "main",
        "HOSTNAME": "63bf11aa43e5"
      },
      "fingerprint": [
        "{{ default }}"
      ],
      "metadata": {
        "title": "java.io.IOException: org.springframework.ws.client.WebServiceIOException: I/O error: sun.security..."
      },
      "received": 1500904595,
      "sdk": {
        "client_ip": "172.17.0.8",
        "version": "1.3.0-41286",
        "name": "sentry-java",
        "integrations": [
          "logback"
        ]
      },
      "sentry.interfaces.Message": {
        "message": "java.io.IOException: org.springframework.ws.client.WebServiceIOException: I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target\n\tat my.package.MyClass.someMethod1(...)\n\tat my.package.MyClass.someMethod2(...)\n\tat my.package.MyClass.someMethod3(...)\n\tat ...",
      },
      "sentry.interfaces.Stacktrace": {
        "frames": [
          {
            "function": "invoke0",
            "abs_path": "NativeMethodAccessorImpl.java",
            "in_app": false,
            "module": "sun.reflect.NativeMethodAccessorImpl",
            "filename": "NativeMethodAccessorImpl.java"
          },
          {
            "function": "someMethod5",
            "abs_path": "MyClass.java",
            "module": "my.package.MyClass",
            "in_app": false,
            "filename": "MyClass.java"
          },
          {
            "function": "someMethod4",
            "abs_path": "MyClass.java",
            "module": "my.package.MyClass",
            "in_app": false,
            "filename": "MyClass.java"
          },
          {
            "function": "someMethod3",
            "abs_path": "MyClass.java",
            "module": "my.package.MyClass",
            "in_app": false,
            "filename": "MyClass.java"
          },
          {
            "function": "someMethod2",
            "abs_path": "MyClass.java",
            "module": "my.package.MyClass",
            "in_app": false,
            "filename": "MyClass.java"
          },
          {
            "function": "someMethod1",
            "abs_path": "MyClass.java",
            "module": "my.package.MyClass",
            "in_app": false,
            "filename": "MyClass.java"
          }
        ],
        "registers": null,
        "frames_omitted": null
      },
      "type": "default",
      "version": "6"
    }

2 个答案:

答案 0 :(得分:0)

UI中有一个切换(在堆栈跟踪的右上角),默认情况下会显示应用程序框架。您可以选择" Full"或" Raw"代替。

sentry ui buttons

答案 1 :(得分:0)

对不起,这是我的错。

我深入研究了代码并看到了

log.error("Exception wac occured: " + getPrettyStackTrace(ex));

代替

log.error("Exception was occured.", ex);

因此,sentry打印出正确的堆栈跟踪,而这只是愚蠢的错误。