代码之家  ›  专栏  ›  技术社区  ›  Shubham Goel

在Java中进行了哨兵集成,如下所示。哨兵仪表盘上一个事件都没有。原因可能是什么?

  •  -1
  • Shubham Goel  · 技术社区  · 4 年前
      Sentry.init("https://a96e4f7079404e12823024df8367d521@o443980.ingest.sentry.io/5418440");
      sentry = SentryClientFactory.sentryClient();
      logWithStaticAPI();
    
    
    static  void logWithStaticAPI() {
        // Note that all fields set on the context are optional. Context data is copied onto
        // all future events in the current context (until the context is cleared).
    
        // Record a breadcrumb in the current context. By default the last 100 breadcrumbs are kept.
        Sentry.getContext().recordBreadcrumb(
                new BreadcrumbBuilder().setMessage("User made an action").build()
        );
    
        // Set the user in the current context.
        Sentry.getContext().setUser(
                new UserBuilder().setEmail("hello@sentry.io").build()
        );
    
        // Add extra data to future events in this context.
        Sentry.getContext().addExtra("extra", "thing");
    
        // Add an additional tag to future events in this context.
        Sentry.getContext().addTag("tagName", "tagValue");
    
        /*
         This sends a simple event to Sentry using the statically stored instance
         that was created in the ``main`` method.
         */
        Sentry.capture("This is a test");
    
        try {
            unsafeMethod();
        } catch (Exception e) {
            // This sends an exception event to Sentry using the statically stored instance
            // that was created in the ``main`` method.
            Sentry.capture(e);
        }
    }
    
    0 回复  |  直到 4 年前
        1
  •  0
  •   Shubham Goel    4 年前

    回答我自己的问题。 大约一天后它就开始工作了。所以在整合后要有耐心。

    推荐文章