-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Добавли возможность настройки для логирования в трассы и в консоль #41
base: master
Are you sure you want to change the base?
Changes from all commits
f4dfcf0
3a1fbfe
867bf46
cdc1c4f
9c90357
64098a1
7b32ba8
95f6cb4
a4e970f
fb88fb0
ab07777
188773b
4c5494f
cda5b0a
1954fc0
c314fa3
ba4e0cb
5283bdc
1d7114e
4b083c0
e20dcbf
432a666
3a7c71a
8649320
380a755
cb1bf80
ab1b9db
e7fef20
c94f953
0f49a8d
981c069
31a8b3e
bb83f5c
d278902
7c60ca2
2054363
e81e554
bad517f
9b059a6
4033fa2
31b1b6e
9650453
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Byndyusoft/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Liveness/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=middlewares/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
using Byndyusoft.MaskedSerialization.Annotations.Attributes; | ||
using Byndyusoft.Telemetry.Abstraction.Attributes; | ||
|
||
namespace Byndyusoft.Net.RabbitMq | ||
{ | ||
public class Message | ||
{ | ||
public string Property { get; set; } = default!; | ||
[TelemetryItem] public string Property { get; set; } = default!; | ||
|
||
[Masked] public string Secret { get; set; } = default!; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,87 @@ | ||
using System.Diagnostics; | ||
using System.Threading.Tasks; | ||
using Byndyusoft.Net.RabbitMq.HostedServices; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using OpenTelemetry; | ||
using OpenTelemetry.Resources; | ||
using OpenTelemetry.Trace; | ||
|
||
namespace Byndyusoft.Net.RabbitMq | ||
{ | ||
public static class Program | ||
{ | ||
private static readonly ActivitySource ActivitySource = new(nameof(Program)); | ||
|
||
public static async Task Main(string[] args) | ||
{ | ||
using var tracerProvider = Sdk.CreateTracerProviderBuilder() | ||
.SetResourceBuilder(ResourceBuilder.CreateDefault() | ||
.AddService("Byndyusoft.Net.RabbitMq")) | ||
.SetSampler(new AlwaysOnSampler()) | ||
.AddSource(ActivitySource.Name) | ||
.AddJaegerExporter(jaeger => | ||
{ | ||
jaeger.AgentHost = "localhost"; | ||
jaeger.AgentPort = 6831; | ||
}) | ||
.AddRabbitMqClientInstrumentation() | ||
.Build(); | ||
|
||
await CreateHostBuilder(args).RunConsoleAsync(); | ||
} | ||
|
||
private static IHostBuilder CreateHostBuilder(string[] args) | ||
{ | ||
return Host.CreateDefaultBuilder(args) | ||
.ConfigureHostOptions(options => | ||
{ | ||
options.BackgroundServiceExceptionBehavior = BackgroundServiceExceptionBehavior.Ignore; | ||
}) | ||
.ConfigureLogging(log => log.AddConsole()) | ||
.ConfigureAppConfiguration(configuration => { configuration.AddJsonFile("appsettings.json", true); }) | ||
.ConfigureServices((_, services) => | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
services.AddRabbitMqRpc(); | ||
services.AddSingleton<MathRpcServiceClient>(); | ||
services.AddRpcService<MathRpcService>(); | ||
webBuilder.UseStartup<Startup>(); | ||
webBuilder.ConfigureLogging(i => i.AddConsole()); | ||
//webBuilder.UseSerilog((context, configuration) => configuration | ||
// .UseDefaultSettings(context.Configuration) | ||
// .UseOpenTelemetryTraces() | ||
// .WriteToOpenTelemetry(activityEventBuilder: StructuredActivityEventBuilder.Instance)); | ||
}); | ||
} | ||
} | ||
|
||
//services.AddHostedService<PullingExample>(); | ||
//services.AddHostedService<RetryAndErrorExample>(); | ||
services.AddHostedService<RpcExample>(); | ||
public class Startup | ||
{ | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddOpenTelemetry() | ||
.WithTracing(builder => builder | ||
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("Byndyusoft.Net.RabbitMq")) | ||
.AddJaegerExporter(jaeger => | ||
{ | ||
jaeger.AgentHost = "localhost"; | ||
jaeger.AgentPort = 6831; | ||
}) | ||
.AddRabbitMqClientInstrumentation(o => | ||
{ | ||
o.LogEventsInTrace = true; | ||
o.LogEventsInLogs = true; | ||
o.RecordExceptions = true; | ||
})); | ||
services.AddRabbitMqRpc(); | ||
services.AddSingleton<MathRpcServiceClient>(); | ||
services.AddRpcService<MathRpcService>(); | ||
|
||
//services.AddHostedService<SubscribeAsMessagePackExample>(); | ||
//services.AddHostedService<PullingExample>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Зачем эти участки? Может их удалить или описать в README, как пользоваться примерами? |
||
//services.AddHostedService<RetryAndErrorExample>(); | ||
//services.AddHostedService<RpcExample>(); | ||
|
||
//services.AddHostedService<RpcServerExample>(); | ||
//services.AddHostedService<SubscribeAsExample>(); | ||
//services.AddHostedService<SubscribeAsJsonExample>(); | ||
//services.AddHostedService<SubscribeExchangeExample>(); | ||
//services.AddHostedService<ClientFactoryExample>(); | ||
services.AddHostedService<SubscribeAsMessagePackExample>(); | ||
|
||
//services.AddHostedService<QueueInstallerHostedService>(); | ||
//services.AddHostedService<RpcServerExample>(); | ||
//services.AddHostedService<SubscribeAsExample>(); | ||
//services.AddHostedService<SubscribeAsJsonExample>(); | ||
//services.AddHostedService<SubscribeExchangeExample>(); | ||
//services.AddHostedService<ClientFactoryExample>(); | ||
|
||
//services.AddRabbitMqClient("host=localhost;username=guest;password=guest"); | ||
//services.AddHostedService<QueueInstallerHostedService>(); | ||
|
||
//services.AddRabbitMqClient("client-factory", "host=localhost;username=guest;password=guest"); | ||
services.AddInMemoryRabbitMqClient(); | ||
services.AddRabbitMqClient("host=localhost;username=guest;password=guest"); | ||
|
||
services.BuildServiceProvider(new ServiceProviderOptions | ||
{ | ||
ValidateOnBuild = true, | ||
ValidateScopes = true | ||
}); | ||
}); | ||
//services.AddRabbitMqClient("client-factory", "host=localhost;username=guest;password=guest"); | ||
//services.AddInMemoryRabbitMqClient(); | ||
|
||
services.BuildServiceProvider(new ServiceProviderOptions | ||
{ | ||
ValidateOnBuild = true, | ||
ValidateScopes = true | ||
}); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | ||
{ | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
<ItemGroup> | ||
<PackageReference Include="System.Text.Json" Version="7.0.0" /> | ||
<PackageReference Include="Byndyusoft.Net.Http.Json" Version="0.3.1" /> | ||
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.0" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Исправить форматирование |
||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System; | ||
using System.Net.Http; | ||
|
||
namespace Byndyusoft.Messaging.RabbitMq | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Byndyusoft.Messaging.RabbitMq.Diagnostics.Consts | ||
{ | ||
public class DiagnosticNames | ||
{ | ||
public static string RabbitMq = "Byndyusoft.RabbitMq"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Byndyusoft.Messaging.RabbitMq.Diagnostics.Consts | ||
{ | ||
public class EventNames | ||
{ | ||
public static string MessagePublishing = "Byndyusoft.RabbitMq.Message.Publishing"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $"{DiagnosticNames}.Message.Publishing" ? |
||
public static string MessageReturned = "Byndyusoft.RabbitMq.Message.Returned"; | ||
public static string MessageGot = "Byndyusoft.RabbitMq.Message.Got"; | ||
public static string MessageModelRead = "Byndyusoft.RabbitMq.Message.ModelRead"; | ||
public static string MessageReplied = "Byndyusoft.RabbitMq.Message.Replied"; | ||
public static string MessageConsumed = "Byndyusoft.RabbitMq.Message.Consumed"; | ||
public static string UnhandledException = "Byndyusoft.RabbitMq.UnhandledException"; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RequestParams странно смотрится в реббите