io.sentry.SentryClient Java Examples

The following examples show how to use io.sentry.SentryClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppConfig.java    From staffjoy with MIT License 5 votes vote down vote up
@Bean
public IAcsClient acsClient(@Autowired SentryClient sentryClient) {
    IClientProfile profile = DefaultProfile.getProfile(SmsConstant.ALIYUN_REGION_ID, appProps.getAliyunAccessKey(), appProps.getAliyunAccessSecret());
    try {
        DefaultProfile.addEndpoint(SmsConstant.ALIYUN_SMS_ENDPOINT_NAME, SmsConstant.ALIYUN_REGION_ID, SmsConstant.ALIYUN_SMS_PRODUCT, SmsConstant.ALIYUN_SMS_DOMAIN);
    } catch (ClientException ex) {
        sentryClient.sendException(ex);
        logger.error("Fail to create acsClient ", ex);
    }
    IAcsClient client = new DefaultAcsClient(profile);
    return client;
}
 
Example #2
Source File: SentryFactory.java    From zhcet-web with Apache License 2.0 5 votes vote down vote up
@Override
public SentryClient createSentryClient(Dsn dsn) {
    SentryClient sentryClient = new SentryClient(createConnection(dsn), getContextManager(dsn));

    /* Create and use the ForwardedAddressResolver, which will use the
       X-FORWARDED-FOR header for the remote address if it exists. */
    ForwardedAddressResolver forwardedAddressResolver = new ForwardedAddressResolver();
    sentryClient.addBuilderHelper(new HttpEventBuilderHelper(forwardedAddressResolver));

    sentryClient.addBuilderHelper(new ContextBuilderHelper(sentryClient));
    return configureSentryClient(sentryClient, dsn);
}
 
Example #3
Source File: SentryConfiguration.java    From Lavalink with MIT License 5 votes vote down vote up
public void turnOn(String dsn, Map<String, String> tags) {
    log.info("Turning on sentry");
    SentryClient sentryClient = Sentry.init(dsn);

    if (tags != null) {
        tags.forEach(sentryClient::addTag);
    }

    // set the git commit hash this was build on as the release
    Properties gitProps = new Properties();
    try {
        //noinspection ConstantConditions
        gitProps.load(Launcher.class.getClassLoader().getResourceAsStream("git.properties"));
    } catch (NullPointerException | IOException e) {
        log.error("Failed to load git repo information", e);
    }

    String commitHash = gitProps.getProperty("git.commit.id");
    if (commitHash != null && !commitHash.isEmpty()) {
        log.info("Setting sentry release to commit hash {}", commitHash);
        sentryClient.setRelease(commitHash);
    } else {
        log.warn("No git commit hash found to set up sentry release");
    }

    getSentryLogbackAppender().start();
}