本文整理汇总了Java中io.sentry.Sentry类的典型用法代码示例。如果您正苦于以下问题:Java Sentry类的具体用法?Java Sentry怎么用?Java Sentry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sentry类属于io.sentry包,在下文中一共展示了Sentry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPipeItem
import io.sentry.Sentry; //导入依赖的package包/类
/**
* spawns the pipeItem for all players (if they are near enough)
*/
public void createPipeItem(PipeItem pipeItem) {
try {
List<Player> playerList = LocationUtils.getPlayerList(pipeItem.getBlockLoc().getWorld());
for (Player on : playerList) {
if (on.getWorld().equals(pipeItem.getBlockLoc().getWorld())) {
if (pipeItem.getBlockLoc().distance(on.getLocation()) <= TransportPipes.instance.settingsUtils.getOrLoadPlayerSettings(on).getRenderDistance()) {
spawnItem(on, pipeItem);
}
}
}
} catch (Exception e) {
e.printStackTrace();
Sentry.capture(e);
}
}
示例2: updatePipeItem
import io.sentry.Sentry; //导入依赖的package包/类
/**
* updates the pipeItem (location) for all players (if they are near enough)
*/
public void updatePipeItem(PipeItem pipeItem) {
try {
List<Player> playerList = LocationUtils.getPlayerList(pipeItem.getBlockLoc().getWorld());
for (Player on : playerList) {
if (on.getWorld().equals(pipeItem.getBlockLoc().getWorld())) {
if (pipeItem.getBlockLoc().distance(on.getLocation()) <= TransportPipes.instance.settingsUtils.getOrLoadPlayerSettings(on).getRenderDistance()) {
getProtocol().updatePipeItem(on, pipeItem);
}
}
}
} catch (Exception e) {
e.printStackTrace();
Sentry.capture(e);
}
}
示例3: initSentryOnCurrentThread
import io.sentry.Sentry; //导入依赖的package包/类
public static void initSentryOnCurrentThread() {
Sentry.init("https://2eb0fc30f86a4871a85755ecdde11679:[email protected]/252970");
Sentry.getContext().setUser(new UserBuilder().setUsername("RoboTricker").build());
Sentry.getContext().addTag("thread", Thread.currentThread().getName());
Sentry.getContext().addTag("version", TransportPipes.instance.getDescription().getVersion());
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
Sentry.capture(e);
}
});
}
示例4: onReceive
import io.sentry.Sentry; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (gateway == null) {
gateway = new HTTPGateway(Config.shared().apiURL());
}
final Bundle bundle = intent.getExtras();
try {
if (null == bundle)
return;
final Object[] objects = (Object[]) bundle.get("pdus");
for (int i = 0, size = objects.length; i < size; i++) {
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) objects[i]);
String phoneNumber = smsMessage.getDisplayOriginatingAddress();
String body = smsMessage.getMessageBody();
Log.i(getClass().getName(), phoneNumber + " " + body);
gateway.message(phoneNumber, body);
}
} catch (Exception e) {
Log.e(getClass().getName(), e.getMessage());
Sentry.capture(e);
}
Log.i(getClass().getName(), "On receive");
}
示例5: onCreate
import io.sentry.Sentry; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Context ctx = this.getApplicationContext();
// Use the Sentry DSN (client key) from the Project Settings page on Sentry
Config.initialize(getApplicationContext());
Config config = Config.shared();
String sentryDsn = config.sentry();
Sentry.init(sentryDsn, new AndroidSentryClientFactory(ctx));
Intent intent = new Intent(this, IncomingService.class);
startService(intent);
Log.i(getClass().getName(), "Activity created]");
}
示例6: initSentry
import io.sentry.Sentry; //导入依赖的package包/类
private void initSentry() {
String sentryDsn = config.getSentryDsn();
if (sentryDsn == null || sentryDsn.isEmpty()) {
turnOffSentry();
return;
}
SentryClient sentryClient = Sentry.init(sentryDsn);
// set the git commit hash this was build on as the release
Properties gitProps = new Properties();
try {
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.full");
if (commitHash == null || commitHash.isEmpty()) {
return;
}
sentryClient.setRelease(commitHash);
}
示例7: main
import io.sentry.Sentry; //导入依赖的package包/类
/**
* Main entry point.
* @param args Arguments
* @throws IOException If fails
*/
public static void main(final String... args) throws IOException {
Sentry.init(Manifests.read("ThreeCopies-SentryDsn"));
final Base base = new DyBase(new Dynamo());
new Routine(
base,
new Shell.Safe(
new Ssh(
"d1.threecopies.com",
Ssh.PORT,
"threecopies",
new TextOf(
new ResourceOf("com/threecopies/routine/ssh.key")
).asString()
)
),
new Region.Simple(
Manifests.read("ThreeCopies-S3Key"),
Manifests.read("ThreeCopies-S3Secret")
).bucket("logs.threecopies.com")
).start();
new FtCli(new TkApp(base), args).start(Exit.NEVER);
}
示例8: job
import io.sentry.Sentry; //导入依赖的package包/类
/**
* Create one job for the pipe.
* @param pipe The pipe
* @return The job for this pipe
*/
private Runnable job(final Pipe pipe) {
return new VerboseRunnable(
new RunnableOf<>(
new FuncWithFallback<Pipe, Boolean>(
new FuncOf<>(new Cycle(this.base)),
new FuncOf<>(
error -> {
Sentry.capture(error);
throw new IllegalStateException(error);
}
)
),
pipe
),
true, true
);
}
示例9: addDefaultContext
import io.sentry.Sentry; //导入依赖的package包/类
private static void addDefaultContext() {
Context context = Sentry.getContext();
context.addTag("full_release", Constants.VERSION);
context.addTag("java_version", System.getProperty("java.version"));
context.addTag("os_name", System.getProperty("os.name"));
context.addTag("os_arch", System.getProperty("os.arch"));
context.addTag("os_version", System.getProperty("os.version"));
context.addExtra("processors", Runtime.getRuntime().availableProcessors());
context.addExtra("memory_max", Runtime.getRuntime().maxMemory());
context.addExtra("memory_total", Runtime.getRuntime().totalMemory());
context.addExtra("memory_free", Runtime.getRuntime().freeMemory());
context.addExtra("server_host", serverHost);
context.addExtra("server_port_http", serverPortHttp);
context.addExtra("server_port_https", serverPortHttps);
context.addExtra("sponge_api", spongeApi);
context.addExtra("sponge_game", spongeGame);
context.addExtra("sponge_impl", spongeImpl);
context.addExtra("plugins", pluginList);
}
示例10: setSentryContext
import io.sentry.Sentry; //导入依赖的package包/类
public static void setSentryContext(IGuild guild, IUser user, IChannel chan, IMessage message){
if (guild != null && ! guild.isDeleted()){
Sentry.getContext().addTag("Guild", guild.getStringID() + " - " + guild.getName());
if (chan != null && ! chan.isDeleted())
Sentry.getContext().addTag("Channel", chan.getStringID() + " - " + chan.getName());
else
Sentry.getContext().addTag("Channel", "null");
}
else
Sentry.getContext().addTag("Guild", "null");
if (user != null)
Sentry.getContext().addTag("User", user.getStringID() + " - " + user.getName());
else
Sentry.getContext().addTag("User", "null");
if (message != null)
Sentry.getContext().addTag("Message", message.getContent());
else
Sentry.getContext().addTag("Message", "null");
}
示例11: main
import io.sentry.Sentry; //导入依赖的package包/类
public static void main(String[] args)
{
Sentry.init(System.getenv().get("SENTRY_DSN"));
ScheduledExecutorService scheduler = buildAndRunScheduler();
WorkerManager workers = buildWorkers(config);
workers.start();
ApiServer server = new ApiServer(ApiApplication.class, config);
server.start();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
shutdownAndAwaitTermination(scheduler);
server.stop();
workers.stop();
}));
}
示例12: buildAndRunScheduler
import io.sentry.Sentry; //导入依赖的package包/类
private static ScheduledExecutorService buildAndRunScheduler()
{
ThreadFactory threadFactory = new ThreadFactoryBuilder()
.setNameFormat("scheduler-%d")
.setUncaughtExceptionHandler((t, e) -> {
Sentry.capture(e);
LOG.error("Uncaught exception at scheduler: " + e.getMessage());
})
.build();
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(threadFactory);
// Schedule at most every 3 hours
scheduler.scheduleWithFixedDelay(() -> { scheduleIfEmpty(config.getQueueConfig().getUserRankingQueue()); }, 1, 3, TimeUnit.HOURS);
scheduler.scheduleWithFixedDelay(() -> { scheduleIfEmpty(config.getQueueConfig().getOrgRankingQueue()); }, 2, 3, TimeUnit.HOURS);
scheduler.scheduleWithFixedDelay(() -> { scheduleIfEmpty(config.getQueueConfig().getRepoRankingQueue()); }, 3, 3, TimeUnit.HOURS);
// Schedule at most every 1 hour
//scheduler.scheduleWithFixedDelay(() -> { scheduleIfEmpty(config.getQueueConfig().getNewUserQueue()); }, 1, 1, TimeUnit.HOURS);
// Schedule at most every 24 hour
//scheduler.scheduleWithFixedDelay(() -> { scheduleIfEmpty(config.getQueueConfig().getSearchedUserQueue()); }, 1, 24, TimeUnit.HOURS);
return scheduler;
}
示例13: shutdownAndAwaitTermination
import io.sentry.Sentry; //导入依赖的package包/类
private static void shutdownAndAwaitTermination(ExecutorService executor)
{
executor.shutdown();
try {
if (!executor.awaitTermination(60, TimeUnit.SECONDS)) {
executor.shutdownNow();
if (!executor.awaitTermination(60, TimeUnit.SECONDS)) {
LOG.error("Failed to shutdown scheduler");
}
}
}
catch (InterruptedException e) {
Sentry.capture(e);
LOG.error("Scheduler shutdown interrupted: " + e.getMessage());
executor.shutdownNow();
Thread.currentThread().interrupt();
}
}
示例14: isBlockProtectedByLWC
import io.sentry.Sentry; //导入依赖的package包/类
public static boolean isBlockProtectedByLWC(Block b) {
if (Bukkit.getPluginManager().isPluginEnabled("LWC")) {
try {
return com.griefcraft.lwc.LWC.getInstance().findProtection(b) != null;
} catch (Exception e) {
e.printStackTrace();
Sentry.capture(e);
}
}
return false;
}
示例15: isBlockAtLocationOccluding
import io.sentry.Sentry; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private static boolean isBlockAtLocationOccluding(Location loc) {
try {
ChunkSnapshot snapshot = null;
int chunkX = (int) Math.floor(loc.getBlockX() / 16d);
int chunkZ = (int) Math.floor(loc.getBlockZ() / 16d);
ChunkCoords cc = new ChunkCoords(loc.getWorld().getName(), chunkX, chunkZ);
if (TransportPipes.instance.blockChangeListener.cachedChunkSnapshots.containsKey(cc)) {
snapshot = TransportPipes.instance.blockChangeListener.cachedChunkSnapshots.get(cc);
}
if (snapshot == null) {
return false;
}
int relativeX = loc.getBlockX() % 16;
if (relativeX < 0) {
relativeX = 16 + relativeX;
}
int relativeZ = loc.getBlockZ() % 16;
if (relativeZ < 0) {
relativeZ = 16 + relativeZ;
}
Material material = Material.getMaterial(snapshot.getBlockTypeId(relativeX, loc.getBlockY(), relativeZ));
return material.isOccluding();
} catch (Exception e) {
e.printStackTrace();
Sentry.capture(e);
return false;
}
}