Enable optional OpenTelemetry tracing configuration.
Added a feature flag (`useOtel`) to conditionally enable OpenTelemetry tracing. This allows developers to toggle tracing for debugging or testing without affecting the default behavior.
This commit is contained in:
parent
1d7fd81b3e
commit
d19fc6e976
|
|
@ -96,6 +96,7 @@ const bool useTenantsFromConfiguration = true;
|
|||
const bool useSecrets = false;
|
||||
const bool disableVariableWrappers = false;
|
||||
const bool disableVariableCopying = false;
|
||||
const bool useOtel = false;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var services = builder.Services;
|
||||
|
|
@ -120,13 +121,15 @@ var sqlDatabaseProvider = Enum.Parse<SqlDatabaseProvider>(configuration["Databas
|
|||
TypeAliasRegistry.RegisterAlias("OrderReceivedProducerFactory", typeof(GenericProducerFactory<string, OrderReceived>));
|
||||
TypeAliasRegistry.RegisterAlias("OrderReceivedConsumerFactory", typeof(GenericConsumerFactory<string, OrderReceived>));
|
||||
|
||||
if (useOtel)
|
||||
{
|
||||
// Configure OpenTelemetry Tracing
|
||||
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||
.AddSource("Elsa.Workflows") // Match your ActivitySource name here
|
||||
.SetSampler(new AlwaysOnSampler()) // Always record traces for testing
|
||||
.AddConsoleExporter() // Export spans to the console (optional)
|
||||
.Build();
|
||||
|
||||
}
|
||||
|
||||
// Add Elsa services.
|
||||
services
|
||||
|
|
|
|||
Loading…
Reference in a new issue