-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (31 loc) · 1.15 KB
/
Program.cs
File metadata and controls
39 lines (31 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Messages;
using MQContract;
using MQContract.NATS;
using NATS.Client.JetStream.Models;
using OpenTelemetry;
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
var serviceName = "MQContract";
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource(serviceName) // Tracks activities from this source
.SetResourceBuilder(OpenTelemetry.Resources.ResourceBuilder.CreateDefault().AddService(serviceName))
.AddOtlpExporter(options =>
{
options.Endpoint = new("http://localhost:4317");
}) // Optional: Export to OTLP endpoint
.Build();
var serviceConnection = new Connection(new NATS.Client.Core.NatsOpts()
{
LoggerFactory=new Microsoft.Extensions.Logging.LoggerFactory(),
Name="NATSSample"
});
var streamConfig = new StreamConfig("StoredArrivalsStream", ["StoredArrivals"])
{
MaxBytes = 100 * 1024 * 1024
};
await serviceConnection.CreateStreamAsync(streamConfig);
var mapper = new ChannelMapper()
.AddPublishSubscriptionMap("StoredArrivals", "StoredArrivalsStream");
await SampleExecution.ExecuteSample(serviceConnection, "NatsIO", mapper);