From 5c4408c8cc662deb5abf768e023229aa55807acf Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 20 Nov 2022 17:00:41 +0100 Subject: [PATCH] Added zipkin support for OTLP. --- .../APM/Zipkin/ZipkinPlugin.cs | 44 +++++++++++++++++++ .../Squidex.Extensions.csproj | 1 + backend/src/Squidex/appsettings.json | 7 +++ 3 files changed, 52 insertions(+) create mode 100644 backend/extensions/Squidex.Extensions/APM/Zipkin/ZipkinPlugin.cs diff --git a/backend/extensions/Squidex.Extensions/APM/Zipkin/ZipkinPlugin.cs b/backend/extensions/Squidex.Extensions/APM/Zipkin/ZipkinPlugin.cs new file mode 100644 index 0000000000..e94073116d --- /dev/null +++ b/backend/extensions/Squidex.Extensions/APM/Zipkin/ZipkinPlugin.cs @@ -0,0 +1,44 @@ +// ========================================================================== +// 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.Trace; +using Squidex.Infrastructure; +using Squidex.Infrastructure.Plugins; + +namespace Squidex.Extensions.APM.Zipkin; + +public sealed class ZipkinPlugin : IPlugin +{ + private sealed class Configurator : ITelemetryConfigurator + { + private readonly IConfiguration config; + + public Configurator(IConfiguration config) + { + this.config = config; + } + + public void Configure(TracerProviderBuilder builder) + { + builder.AddZipkinExporter(options => + { + config.GetSection("logging:zipkin").Bind(options); + }); + } + } + + public void ConfigureServices(IServiceCollection services, IConfiguration config) + { + if (config.GetValue("logging:zipkin:enabled")) + { + services.AddSingleton(); + } + } +} diff --git a/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj b/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj index f0915c5cf5..be687262cc 100644 --- a/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj +++ b/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj @@ -32,6 +32,7 @@ + diff --git a/backend/src/Squidex/appsettings.json b/backend/src/Squidex/appsettings.json index 4748e41c74..0c9ab7f877 100644 --- a/backend/src/Squidex/appsettings.json +++ b/backend/src/Squidex/appsettings.json @@ -343,6 +343,13 @@ "sampling": 1.0 }, + "zipkin": { + // True, to enable Zipkin integration. + "enabled": false, + + "endpoint": "http://localhost:9411/api/v2/spans" + }, + "applicationInsights": { // True, to enable application insights integraon. "enabled": false,