From 71872ad5d762aaed403e72c2b30feee99bae08b9 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Mon, 29 Jul 2024 15:54:34 +0800 Subject: [PATCH 1/2] Add Otel --- .../BasicBaseChainAElfModule.cs | 2 ++ src/AElf.Core/AElf.Core.csproj | 3 +++ src/AElf.CrossChain.Grpc/AElf.CrossChain.Grpc.csproj | 2 +- .../Blockchain/Domain/IChainManager.cs | 2 ++ src/AElf.Kernel/Miner/Application/MiningService.cs | 2 ++ src/AElf.Launcher/Startup.cs | 12 ++++++++++++ 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/AElf.Blockchains.BasicBaseChain/BasicBaseChainAElfModule.cs b/src/AElf.Blockchains.BasicBaseChain/BasicBaseChainAElfModule.cs index 0a83ca154c..872e4d57cb 100644 --- a/src/AElf.Blockchains.BasicBaseChain/BasicBaseChainAElfModule.cs +++ b/src/AElf.Blockchains.BasicBaseChain/BasicBaseChainAElfModule.cs @@ -15,6 +15,7 @@ using AElf.Kernel.SmartContract.Parallel; using AElf.Kernel.Token; using AElf.Modularity; +using AElf.OpenTelemetry; using AElf.OS; using AElf.OS.Network.Grpc; using AElf.OS.Node.Application; @@ -52,6 +53,7 @@ namespace AElf.Blockchains.BasicBaseChain; //web api module typeof(WebWebAppAElfModule), typeof(ParallelExecutionModule), + typeof(OpenTelemetryModule), //plugin typeof(ExecutionPluginForMethodFeeModule), diff --git a/src/AElf.Core/AElf.Core.csproj b/src/AElf.Core/AElf.Core.csproj index ffab63014d..966ae08a59 100644 --- a/src/AElf.Core/AElf.Core.csproj +++ b/src/AElf.Core/AElf.Core.csproj @@ -14,6 +14,9 @@ + + + diff --git a/src/AElf.CrossChain.Grpc/AElf.CrossChain.Grpc.csproj b/src/AElf.CrossChain.Grpc/AElf.CrossChain.Grpc.csproj index 8b6b48b8de..6c08c648ae 100644 --- a/src/AElf.CrossChain.Grpc/AElf.CrossChain.Grpc.csproj +++ b/src/AElf.CrossChain.Grpc/AElf.CrossChain.Grpc.csproj @@ -24,7 +24,7 @@ - + diff --git a/src/AElf.Kernel.Core/Blockchain/Domain/IChainManager.cs b/src/AElf.Kernel.Core/Blockchain/Domain/IChainManager.cs index 7f6ca2cb4e..2a54c680c6 100644 --- a/src/AElf.Kernel.Core/Blockchain/Domain/IChainManager.cs +++ b/src/AElf.Kernel.Core/Blockchain/Domain/IChainManager.cs @@ -2,6 +2,7 @@ using System.Linq; using AElf.Kernel.Blockchain.Infrastructure; using AElf.Kernel.Infrastructure; +using AElf.OpenTelemetry.ExecutionTime; using Microsoft.Extensions.Caching.Memory; namespace AElf.Kernel.Blockchain.Domain; @@ -44,6 +45,7 @@ Task GetDiscardedBranchAsync(Chain chain, Hash irreversibleBloc Task ResetChainToLibAsync(Chain chain); } +[AggregateExecutionTime] public class ChainManager : IChainManager, ISingletonDependency { private readonly IBlockchainStore _chainBlockIndexes; diff --git a/src/AElf.Kernel/Miner/Application/MiningService.cs b/src/AElf.Kernel/Miner/Application/MiningService.cs index 46900722cb..a0612b5628 100644 --- a/src/AElf.Kernel/Miner/Application/MiningService.cs +++ b/src/AElf.Kernel/Miner/Application/MiningService.cs @@ -6,11 +6,13 @@ using AElf.Kernel.Blockchain; using AElf.Kernel.Blockchain.Application; using AElf.Kernel.SmartContractExecution.Application; +using AElf.OpenTelemetry.ExecutionTime; using Google.Protobuf.WellKnownTypes; using Volo.Abp.EventBus.Local; namespace AElf.Kernel.Miner.Application; +[AggregateExecutionTime] public class MiningService : IMiningService { private readonly IAccountService _accountService; diff --git a/src/AElf.Launcher/Startup.cs b/src/AElf.Launcher/Startup.cs index 42a4537bde..f373cbb851 100644 --- a/src/AElf.Launcher/Startup.cs +++ b/src/AElf.Launcher/Startup.cs @@ -10,6 +10,8 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Serilog; +using Serilog.Sinks.OpenTelemetry; using Volo.Abp; using Volo.Abp.Modularity.PlugIns; @@ -66,6 +68,16 @@ public void ConfigureServices(IServiceCollection services) if (_configuration["CorsOrigins"] != "*") builder.AllowCredentials(); }); }); + + Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(_configuration) +#if DEBUG + .WriteTo.OpenTelemetry( + endpoint: "http://localhost:4316/v1/logs", + protocol: OtlpProtocol.HttpProtobuf) +#endif + .CreateLogger(); + } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. From 8bb2111a33a354bcd65a8500eb62c5aa639552b9 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Fri, 16 Aug 2024 15:22:55 +0800 Subject: [PATCH 2/2] Change version to 8.0.x in global.json --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 1978c843c7..b76a0b882f 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "8.0.303" + "version": "8.0.x" } } \ No newline at end of file