Add more logs, 95%ram alert for GmxMarkets, Proxy retry 2times max
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using System.Text.Json;
|
||||||
using Managing.Application.Abstractions.Repositories;
|
using Managing.Application.Abstractions.Repositories;
|
||||||
using Managing.Application.Abstractions.Services;
|
using Managing.Application.Abstractions.Services;
|
||||||
using Managing.Common;
|
using Managing.Common;
|
||||||
@@ -424,6 +425,7 @@ public class EvmManager : IEvmManager
|
|||||||
{
|
{
|
||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
$"Warning: GMX API returned empty candles array for ticker {ticker}, timeframe {timeframe}, startDate {startDate:yyyy-MM-dd HH:mm:ss}");
|
$"Warning: GMX API returned empty candles array for ticker {ticker}, timeframe {timeframe}, startDate {startDate:yyyy-MM-dd HH:mm:ss}");
|
||||||
|
|
||||||
return new List<Candle>();
|
return new List<Candle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,6 +435,8 @@ public class EvmManager : IEvmManager
|
|||||||
{
|
{
|
||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
$"Warning: No candles found after filtering for ticker {ticker}, timeframe {timeframe}, startDate {startDate:yyyy-MM-dd HH:mm:ss}. Total candles before filtering: {gmxPrices.Candles.Count}");
|
$"Warning: No candles found after filtering for ticker {ticker}, timeframe {timeframe}, startDate {startDate:yyyy-MM-dd HH:mm:ss}. Total candles before filtering: {gmxPrices.Candles.Count}");
|
||||||
|
Console.WriteLine(JsonSerializer.Serialize(filteredCandles));
|
||||||
|
SentrySdk.CaptureException(new Exception($"No candles found after filtering for ticker {ticker}, timeframe {timeframe}, startDate {startDate:yyyy-MM-dd HH:mm:ss}. Total candles before filtering: {gmxPrices.Candles.Count}"));
|
||||||
return new List<Candle>();
|
return new List<Candle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -548,6 +552,7 @@ public class EvmManager : IEvmManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
SentrySdk.CaptureException(ex);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -735,7 +740,7 @@ public class EvmManager : IEvmManager
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e);
|
SentrySdk.CaptureException(e);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -751,6 +756,7 @@ public class EvmManager : IEvmManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
SentrySdk.CaptureException(ex);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -777,6 +783,7 @@ public class EvmManager : IEvmManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
SentrySdk.CaptureException(ex);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -874,6 +881,7 @@ public class EvmManager : IEvmManager
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
SentrySdk.CaptureException(ex);
|
||||||
Console.Error.WriteLine($"Error getting estimated gas fee: {ex.Message}");
|
Console.Error.WriteLine($"Error getting estimated gas fee: {ex.Message}");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ namespace Managing.Infrastructure.Evm.Services
|
|||||||
public class Web3ProxySettings
|
public class Web3ProxySettings
|
||||||
{
|
{
|
||||||
public string BaseUrl { get; set; } = "http://localhost:3000";
|
public string BaseUrl { get; set; } = "http://localhost:3000";
|
||||||
public int MaxRetryAttempts { get; set; } = 3;
|
public int MaxRetryAttempts { get; set; } = 2;
|
||||||
public int RetryDelayMs { get; set; } = 1000;
|
public int RetryDelayMs { get; set; } = 2500;
|
||||||
public int TimeoutSeconds { get; set; } = 30;
|
public int TimeoutSeconds { get; set; } = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,12 +50,13 @@ interface CacheEntry {
|
|||||||
timestamp: number;
|
timestamp: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CACHE_TTL = 30 * 60 * 1000; // 30 minutes in milliseconds
|
const CACHE_TTL = 60 * 60 * 1000; // 60 minutes in milliseconds (increased from 30 minutes)
|
||||||
const marketsCache = new Map<string, CacheEntry>();
|
const marketsCache = new Map<string, CacheEntry>();
|
||||||
const MAX_CACHE_SIZE = 5; // Limit cache size to prevent memory issues
|
const MAX_CACHE_SIZE = 20; // Increased cache size to allow more markets data
|
||||||
const OPERATION_TIMEOUT = 30000; // 30 seconds timeout for operations
|
const OPERATION_TIMEOUT = 30000; // 30 seconds timeout for operations
|
||||||
|
|
||||||
const MEMORY_WARNING_THRESHOLD = 0.8; // Warn when memory usage exceeds 80%
|
const MEMORY_WARNING_THRESHOLD = 0.85; // Warn when memory usage exceeds 85%
|
||||||
|
const MEMORY_CLEAR_THRESHOLD = 0.95; // Clear cache when memory usage exceeds 95%
|
||||||
const MAX_GAS_FEE_USD = 1.5; // Maximum gas fee in USD (1 USDC)
|
const MAX_GAS_FEE_USD = 1.5; // Maximum gas fee in USD (1 USDC)
|
||||||
|
|
||||||
// Memory monitoring function
|
// Memory monitoring function
|
||||||
@@ -68,7 +69,7 @@ function checkMemoryUsage() {
|
|||||||
console.warn(`⚠️ High memory usage detected: ${(usage * 100).toFixed(1)}% (${Math.round(used.heapUsed / 1024 / 1024)}MB / ${Math.round(total / 1024 / 1024)}MB)`);
|
console.warn(`⚠️ High memory usage detected: ${(usage * 100).toFixed(1)}% (${Math.round(used.heapUsed / 1024 / 1024)}MB / ${Math.round(total / 1024 / 1024)}MB)`);
|
||||||
|
|
||||||
// Clear cache if memory usage is too high
|
// Clear cache if memory usage is too high
|
||||||
if (usage > 0.9) {
|
if (usage > MEMORY_CLEAR_THRESHOLD) {
|
||||||
console.warn(`🧹 Clearing markets cache due to high memory usage`);
|
console.warn(`🧹 Clearing markets cache due to high memory usage`);
|
||||||
marketsCache.clear();
|
marketsCache.clear();
|
||||||
pendingRequests.clear();
|
pendingRequests.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user