io.sentry.SentryClientFactory-从以下位置创建有效的DSN时出错:“ https:// public:private @ host:port / 1”

时间:2019-01-08 13:42:28

标签: java sentry

我是Sentry的新手,紧追this

and this

并遵循相同的步骤和代码,我有一个sbt项目,在其中创建了sentry.properties文件,其内容为

dsn=https://public:private@host:port/1

并在引发异常后运行代码(与上面的链接相同的代码)时将其放置在src/main/resources下'

18:19:26.745 [run-main-1] DEBUG io.sentry.config.Lookup - Found dsn=https://public:private@host:port/1 in sentry.properties.
18:19:26.754 [run-main-1] ERROR io.sentry.SentryClientFactory - Error creating valid DSN from: 'https://public:private@host:port/1'.
io.sentry.dsn.InvalidDsnException: Invalid DSN, the following properties aren't set '[host, public key]'
    at io.sentry.dsn.Dsn.validate(Dsn.java:209) ~[sentry-1.7.16.jar:na]
    at io.sentry.dsn.Dsn.<init>(Dsn.java:66) ~[sentry-1.7.16.jar:na]
    at io.sentry.dsn.Dsn.<init>(Dsn.java:41) ~[sentry-1.7.16.jar:na]
    at io.sentry.SentryClientFactory.resolveDsn(SentryClientFactory.java:73) [sentry-1.7.16.jar:na]
    at io.sentry.SentryClientFactory.sentryClient(SentryClientFactory.java:42) [sentry-1.7.16.jar:na]
    at io.sentry.Sentry.init(Sentry.java:81) [sentry-1.7.16.jar:na]
    at io.sentry.Sentry.init(Sentry.java:44) [sentry-1.7.16.jar:na]
    at sentry.SentryDemo$.main(SentryDemo.scala:16) [classes/:na]
    at sentry.SentryDemo.main(SentryDemo.scala) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
    at sbt.Run.invokeMain(Run.scala:67) [run-0.13.16.jar:0.13.16]
    at sbt.Run.run0(Run.scala:61) [run-0.13.16.jar:0.13.16]
    at sbt.Run.sbt$Run$$execute$1(Run.scala:51) [run-0.13.16.jar:0.13.16]
    at sbt.Run$$anonfun$run$1.apply$mcV$sp(Run.scala:55) [run-0.13.16.jar:0.13.16]
    at sbt.Run$$anonfun$run$1.apply(Run.scala:55) [run-0.13.16.jar:0.13.16]
    at sbt.Run$$anonfun$run$1.apply(Run.scala:55) [run-0.13.16.jar:0.13.16]
    at sbt.Logger$$anon$4.apply(Logger.scala:84) [logging-0.13.16.jar:0.13.16]
    at sbt.TrapExit$App.run(TrapExit.scala:248) [run-0.13.16.jar:0.13.16]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
[error] (run-main-1) io.sentry.dsn.InvalidDsnException: Invalid DSN, the following properties aren't set '[host, public key]'
io.sentry.dsn.InvalidDsnException: Invalid DSN, the following properties aren't set '[host, public key]'
    at io.sentry.dsn.Dsn.validate(Dsn.java:209)
    at io.sentry.dsn.Dsn.<init>(Dsn.java:66)
    at io.sentry.dsn.Dsn.<init>(Dsn.java:41)
    at io.sentry.SentryClientFactory.resolveDsn(SentryClientFactory.java:73)
    at io.sentry.SentryClientFactory.sentryClient(SentryClientFactory.java:42)
    at io.sentry.Sentry.init(Sentry.java:81)
    at io.sentry.Sentry.init(Sentry.java:44)
    at sentry.SentryDemo$.main(SentryDemo.scala:16)
    at sentry.SentryDemo.main(SentryDemo.scala)
    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)

是否需要在属性文件中代替dsn进行补充?我在不是基于Web的项目的项目中使用哨兵

1 个答案:

答案 0 :(得分:1)

DSN告知Sentry SDK要命中哪个哨兵实例(例如sentry.io)以及事件属于Sentry的哪个项目。

您需要从Sentry获取DSN并将其添加到您的项目中。 在Sentry的项目设置页面中,您将看到:Client keys (DSN)

Sentry Client keys menu

然后您将看到DSN,如下所示:

Example DSN

复制此文件(右侧的按钮),然后粘贴在您的sentry.properties上,替换占位符:https://public:private@host:port/1