Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

46 lines
1.5 KiB

// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.APM.Otlp;
public sealed class OtlpPlugin : IPlugin
{
private sealed class Configurator(IConfiguration config) : ITelemetryConfigurator
{
public void Configure(TracerProviderBuilder builder)
{
builder.AddOtlpExporter(options =>
{
config.GetSection("logging:otlp").Bind(options);
});
}
public void Configure(MeterProviderBuilder builder)
{
builder.AddOtlpExporter(options =>
{
config.GetSection("logging:otlp").Bind(options);
});
}
}
public void ConfigureServices(IServiceCollection services, IConfiguration config)
{
if (config.GetValue<bool>("logging:otlp:enabled"))
{
services.AddSingleton<ITelemetryConfigurator, Configurator>();
}
}
}