feat(otopcua): wire OTel via AddZbTelemetry (shared Resource + std instrumentation)
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
using OpenTelemetry.Metrics;
|
|
||||||
using OpenTelemetry.Trace;
|
|
||||||
using ZB.MOM.WW.OtOpcUa.Commons.Observability;
|
using ZB.MOM.WW.OtOpcUa.Commons.Observability;
|
||||||
|
using ZB.MOM.WW.Telemetry;
|
||||||
|
|
||||||
namespace ZB.MOM.WW.OtOpcUa.Host.Observability;
|
namespace ZB.MOM.WW.OtOpcUa.Host.Observability;
|
||||||
|
|
||||||
@@ -17,14 +16,12 @@ public static class ObservabilityExtensions
|
|||||||
/// <param name="services">The service collection to add observability services to.</param>
|
/// <param name="services">The service collection to add observability services to.</param>
|
||||||
public static IServiceCollection AddOtOpcUaObservability(this IServiceCollection services)
|
public static IServiceCollection AddOtOpcUaObservability(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddOpenTelemetry()
|
return services.AddZbTelemetry(o =>
|
||||||
.WithMetrics(b => b
|
{
|
||||||
.AddMeter(OtOpcUaTelemetry.MeterName)
|
o.ServiceName = "otopcua";
|
||||||
.AddPrometheusExporter())
|
o.Meters = [OtOpcUaTelemetry.MeterName];
|
||||||
.WithTracing(b => b
|
o.ActivitySources = [OtOpcUaTelemetry.ActivitySourceName];
|
||||||
.AddSource(OtOpcUaTelemetry.ActivitySourceName));
|
});
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -35,7 +32,7 @@ public static class ObservabilityExtensions
|
|||||||
/// <param name="app">The endpoint route builder.</param>
|
/// <param name="app">The endpoint route builder.</param>
|
||||||
public static IEndpointRouteBuilder MapOtOpcUaMetrics(this IEndpointRouteBuilder app)
|
public static IEndpointRouteBuilder MapOtOpcUaMetrics(this IEndpointRouteBuilder app)
|
||||||
{
|
{
|
||||||
app.MapPrometheusScrapingEndpoint("/metrics");
|
app.MapZbMetrics();
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user