Skip to content

Commit 22bcf4b

Browse files
committed
add opentelemetry as a logging provider option
1 parent 061ba55 commit 22bcf4b

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

src/ServiceControl.Audit/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ These settings are only here so that we can debug ServiceControl while developin
2222
<add key="ServiceControl.Audit/PersistenceType" value="InMemory" />
2323
<!--<add key="ServiceControl.Audit/PersistenceType" value="RavenDB" />-->
2424

25-
<!-- options are any comma separated combination of NLog,Seq -->
25+
<!-- options are any comma separated combination of NLog,Seq,Otlp -->
2626
<add key="ServiceControl.Audit/LoggingProviders" value="NLog,Seq"/>
2727
<add key="ServiceControl.Audit/SeqAddress" value="http://localhost:5341"/>
2828
</appSettings>

src/ServiceControl.Infrastructure/LoggerUtil.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.Extensions.DependencyInjection;
55
using Microsoft.Extensions.Logging;
66
using NLog.Extensions.Logging;
7+
using OpenTelemetry.Logs;
78
using ServiceControl.Infrastructure.TestLogger;
89

910
[Flags]
@@ -13,6 +14,7 @@ public enum Loggers
1314
Test = 1 << 0,
1415
NLog = 1 << 1,
1516
Seq = 1 << 2,
17+
Otlp = 1 << 3,
1618
}
1719

1820
public static class LoggerUtil
@@ -47,6 +49,10 @@ public static void BuildLogger(this ILoggingBuilder loggingBuilder, LogLevel lev
4749
loggingBuilder.AddSeq();
4850
}
4951
}
52+
if (IsLoggingTo(Loggers.Otlp))
53+
{
54+
loggingBuilder.AddOpenTelemetry(configure => configure.AddOtlpExporter());
55+
}
5056

5157
loggingBuilder.SetMinimumLevel(level);
5258
}

src/ServiceControl.Infrastructure/LoggingSettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public LoggingSettings(SettingsRootNamespace rootNamespace, LogLevel defaultLeve
2626
LoggerUtil.SeqAddress = seqAddress;
2727
}
2828
}
29+
if (loggingProviders.Contains("Otlp"))
30+
{
31+
activeLoggers |= Loggers.Otlp;
32+
}
2933
//this defaults to NLog because historically that was the default, and we don't want to break existing installs that don't have the config key to define loggingProviders
3034
LoggerUtil.ActiveLoggers = activeLoggers == Loggers.None ? Loggers.NLog : activeLoggers;
3135

src/ServiceControl.Monitoring/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ These settings are only here so that we can debug ServiceControl while developin
1919
<!--<add key="Monitoring/TransportType" value="RabbitMQ.QuorumConventionalRouting" />-->
2020
<!--<add key="Monitoring/TransportType" value="SQLServer" />-->
2121

22-
<!-- options are any comma separated combination of NLog,Seq -->
22+
<!-- options are any comma separated combination of NLog,Seq,Otlp -->
2323
<add key="Monitoring/LoggingProviders" value="NLog,Seq"/>
2424
<add key="Monitoring/SeqAddress" value="http://localhost:5341"/>
2525
</appSettings>

src/ServiceControl/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ These settings are only here so that we can debug ServiceControl while developin
2424

2525
<add key="ServiceControl/PersistenceType" value="RavenDB" />
2626

27-
<!-- options are any comma separated combination of NLog,Seq -->
27+
<!-- options are any comma separated combination of NLog,Seq,Otlp -->
2828
<add key="ServiceControl/LoggingProviders" value="NLog,Seq"/>
2929
<add key="ServiceControl/SeqAddress" value="http://localhost:5341"/>
3030
</appSettings>

0 commit comments

Comments
 (0)