JF91.OpenTelemetry.Net7
1.0.0
استخدم هذه الحزمة لدمج OpenTelemetry في ASP.NET Web API باستخدام appsettings.json
اتبع هذه الخطوات لإنجاز ذلك:
dotnet add package JF91.OpenTelemetry
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenTelemetryServices(builder.Configuration);
builder.Services.AddOpenTelemetryServices
(
builder.Configuration,
jaegerOptions =>
{
jaegerOptions.Enabled = true;
jaegerOptions.Endpoint = "http://www.test.com";
jaegerOptions.Protocol = JaegerProtocols.Http;
},
zipkinOptions =>
{
zipkinOptions.Enabled = true;
zipkinOptions.Endpoint = "http://www.test.com";
},
influxdbOptions =>
{
influxdbOptions.Enabled = true;
influxdbOptions.Url = "http://www.test.com";
influxdbOptions.Protocol = JaegerProtocols.Http;
},
new List>
{
otlp_one =>
{
otlp_one.Enabled = true;
otlp_one.Url = "http://www.test.com";
otlp_one.Protocol = OtlpProtocols.Http;
},
otlp_two =>
{
otlp_two.Enabled = true;
otlp_two.Url = "http://www.test2.com";
otlp_two.Protocol = OtlpProtocols.Grpc;
}
},
prometheusOptions =>
{
prometheusOptions.Enabled = true;
prometheusOptions.ScrapeEndpointPath = "/test";
prometheusOptions.ScrapeResponseCacheDurationMilliseconds = 1000;
}
);
المثال 1: سيتجاوز 3 مصدري OTLP في appsettings.json وخيارين مخصصين أول خيارين مخصصين لتصدير OTLP في appsettings.json من أول خيارين مخصصين.
المثال 2: سيتجاوز مصدرا OTLP في appsettings.json و3 خيارات مخصصة مصدري OTLP في appsettings.json من أول خيارين مخصصين.
app.Run();
app.AddOpenTelemetryExtensions();
appsettings.json
الخاص بك وقم بتعديله حسب احتياجاتك: "OpenTelemetrySettings": {
"EnableTraces": true,
"EnableMetrics": true,
"Exporters": {
"Console": {
"Enabled": true
},
"Jaeger": {
"Enabled": true,
"Endpoint": "http://localhost:14268/api/traces",
"Protocol": "udp"
},
"Zipkin": {
"Enabled": false,
"Endpoint": " https://localhost:9411/api/v2/spans"
},
"Prometheus": {
"Enabled": true,
"ScrapeEndpointPath": "/metrics-text",
"ScrapeResponseCacheDurationMilliseconds": 300
},
"InfluxDB": {
"Enabled": false,
"Url": "http://localhost:8086",
"Protocol": "http"
},
"Otlp": [
{
"Enabled": true,
"Url": "http://localhost:4317",
"Protocol": "grpc"
},
{
"Enabled": false,
"Url": "http://localhost:4317",
"Protocol": "http"
}
]
},
"Instrumentation": {
"Http": true,
"EfCore": false,
"Hangfire": false,
"SqlClient": false,
"Redis": false
}
}
Jaeger.Protocol: udp / http | الافتراضي => udp
[OtlpProtocols] > InfluxDB.Protocol: grpc / http | الافتراضي => grpc