mirror of https://github.com/Squidex/squidex.git
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.
49 lines
1.7 KiB
49 lines
1.7 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using OpenTelemetry.Trace;
|
|
using Squidex.Infrastructure;
|
|
using Squidex.Infrastructure.Plugins;
|
|
|
|
namespace Squidex.Extensions.APM.Datadog
|
|
{
|
|
public sealed class OtlpPlugin : IPlugin
|
|
{
|
|
private sealed class Configurator : ITelemetryConfigurator
|
|
{
|
|
private readonly IConfiguration config;
|
|
|
|
public Configurator(IConfiguration config)
|
|
{
|
|
this.config = config;
|
|
}
|
|
|
|
public void Configure(TracerProviderBuilder builder)
|
|
{
|
|
// See: https://docs.microsoft.com/aspnet/core/grpc/troubleshoot#call-insecure-grpc-services-with-net-core-client
|
|
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
|
|
|
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>();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|