Skip to content

Commit

Permalink
Added zipkin support for OTLP.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Nov 20, 2022
1 parent 3d3391a commit 5c4408c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
44 changes: 44 additions & 0 deletions backend/extensions/Squidex.Extensions/APM/Zipkin/ZipkinPlugin.cs
Original file line number Diff line number Diff line change
@@ -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<bool>("logging:zipkin:enabled"))
{
services.AddSingleton<ITelemetryConfigurator,
Configurator>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<PackageReference Include="OpenSearch.Net" Version="1.2.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.3.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.3.1" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.3.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc8" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.OpenTelemetry.Exporter.Stackdriver" Version="0.0.0-alpha.0.384" />
Expand Down
7 changes: 7 additions & 0 deletions backend/src/Squidex/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5c4408c

Please sign in to comment.