mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Merge pull request #413 from TeamPiped/sentry-tracing
Ignore ErrorResponse and implement tracing.
This commit is contained in:
commit
fa1b3163d4
2 changed files with 17 additions and 1 deletions
|
@ -29,7 +29,12 @@ public class Main {
|
||||||
YoutubeStreamExtractor.forceFetchAndroidClient(true);
|
YoutubeStreamExtractor.forceFetchAndroidClient(true);
|
||||||
YoutubeStreamExtractor.forceFetchIosClient(true);
|
YoutubeStreamExtractor.forceFetchIosClient(true);
|
||||||
|
|
||||||
Sentry.init(Constants.SENTRY_DSN);
|
Sentry.init(options -> {
|
||||||
|
options.setDsn(Constants.SENTRY_DSN);
|
||||||
|
options.setRelease(Constants.VERSION);
|
||||||
|
options.addIgnoredExceptionForType(ErrorResponse.class);
|
||||||
|
options.setTracesSampleRate(0.1);
|
||||||
|
});
|
||||||
|
|
||||||
Injector.useSpecializer();
|
Injector.useSpecializer();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ package me.kavin.piped.server.handlers;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.grack.nanojson.JsonObject;
|
import com.grack.nanojson.JsonObject;
|
||||||
import com.grack.nanojson.JsonWriter;
|
import com.grack.nanojson.JsonWriter;
|
||||||
|
import io.sentry.ITransaction;
|
||||||
|
import io.sentry.Sentry;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
import me.kavin.piped.consts.Constants;
|
import me.kavin.piped.consts.Constants;
|
||||||
import me.kavin.piped.utils.*;
|
import me.kavin.piped.utils.*;
|
||||||
|
@ -36,6 +38,7 @@ public class StreamHandlers {
|
||||||
public static byte[] streamsResponse(String videoId) throws Exception {
|
public static byte[] streamsResponse(String videoId) throws Exception {
|
||||||
|
|
||||||
final var futureStream = Multithreading.supplyAsync(() -> {
|
final var futureStream = Multithreading.supplyAsync(() -> {
|
||||||
|
ITransaction transaction = Sentry.startTransaction("StreamInfo fetch", "fetch");
|
||||||
try {
|
try {
|
||||||
return StreamInfo.getInfo("https://www.youtube.com/watch?v=" + videoId);
|
return StreamInfo.getInfo("https://www.youtube.com/watch?v=" + videoId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -54,21 +57,29 @@ public class StreamHandlers {
|
||||||
});
|
});
|
||||||
|
|
||||||
final var futureLBRY = Multithreading.supplyAsync(() -> {
|
final var futureLBRY = Multithreading.supplyAsync(() -> {
|
||||||
|
ITransaction transaction = Sentry.startTransaction("LBRY Stream fetch", "fetch");
|
||||||
try {
|
try {
|
||||||
|
var childTask = transaction.startChild("fetch", "LBRY ID fetch");
|
||||||
String lbryId = futureLbryId.get(2, TimeUnit.SECONDS);
|
String lbryId = futureLbryId.get(2, TimeUnit.SECONDS);
|
||||||
|
childTask.finish();
|
||||||
|
|
||||||
return LbryHelper.getLBRYStreamURL(lbryId);
|
return LbryHelper.getLBRYStreamURL(lbryId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ExceptionHandler.handle(e);
|
ExceptionHandler.handle(e);
|
||||||
|
} finally {
|
||||||
|
transaction.finish();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
final var futureDislikeRating = Multithreading.supplyAsync(() -> {
|
final var futureDislikeRating = Multithreading.supplyAsync(() -> {
|
||||||
|
ITransaction transaction = Sentry.startTransaction("Dislike Rating", "fetch");
|
||||||
try {
|
try {
|
||||||
return RydHelper.getDislikeRating(videoId);
|
return RydHelper.getDislikeRating(videoId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ExceptionHandler.handle(e);
|
ExceptionHandler.handle(e);
|
||||||
|
} finally {
|
||||||
|
transaction.finish();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue