diff --git a/examples/Console/InstrumentationWithActivitySource.cs b/examples/Console/InstrumentationWithActivitySource.cs index 0e2b320e25e..ee7927f8c0d 100644 --- a/examples/Console/InstrumentationWithActivitySource.cs +++ b/examples/Console/InstrumentationWithActivitySource.cs @@ -30,8 +30,8 @@ namespace Examples.Console internal class InstrumentationWithActivitySource : IDisposable { private const string RequestPath = "/api/request"; - private SampleServer server = new SampleServer(); - private SampleClient client = new SampleClient(); + private readonly SampleServer server = new SampleServer(); + private readonly SampleClient client = new SampleClient(); public void Start(ushort port = 19999) { @@ -48,7 +48,7 @@ public void Dispose() private class SampleServer : IDisposable { - private HttpListener listener = new HttpListener(); + private readonly HttpListener listener = new HttpListener(); public void Start(string url) { diff --git a/src/OpenTelemetry.Exporter.ZPages/Implementation/ZPagesActivityTracker.cs b/src/OpenTelemetry.Exporter.ZPages/Implementation/ZPagesActivityTracker.cs index b7011c74fbb..b09279f8834 100644 --- a/src/OpenTelemetry.Exporter.ZPages/Implementation/ZPagesActivityTracker.cs +++ b/src/OpenTelemetry.Exporter.ZPages/Implementation/ZPagesActivityTracker.cs @@ -26,7 +26,7 @@ namespace OpenTelemetry.Exporter.ZPages.Implementation /// internal static class ZPagesActivityTracker { - private static long startTime; + private static readonly long StartTime; /// /// Initializes static members of the class. @@ -41,7 +41,7 @@ static ZPagesActivityTracker() TotalEndedCount = new Dictionary(); TotalErrorCount = new Dictionary(); TotalLatency = new Dictionary(); - startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds(); + StartTime = DateTimeOffset.Now.ToUnixTimeMilliseconds(); } /// @@ -103,7 +103,7 @@ public static void PurgeCurrentMinuteData(object source, ElapsedEventArgs e) CurrentMinuteList.Clear(); // Remove the stale activity information which is at the end of the list - if (DateTimeOffset.Now.ToUnixTimeMilliseconds() - startTime >= RetentionTime) + if (DateTimeOffset.Now.ToUnixTimeMilliseconds() - StartTime >= RetentionTime) { ZQueue.RemoveLast(); } diff --git a/src/OpenTelemetry/CompositeProcessor.cs b/src/OpenTelemetry/CompositeProcessor.cs index 2b504e6432a..cf2a2861ef6 100644 --- a/src/OpenTelemetry/CompositeProcessor.cs +++ b/src/OpenTelemetry/CompositeProcessor.cs @@ -24,7 +24,7 @@ namespace OpenTelemetry { public class CompositeProcessor : BaseProcessor { - private DoublyLinkedListNode head; + private readonly DoublyLinkedListNode head; private DoublyLinkedListNode tail; private bool disposed; diff --git a/src/OpenTelemetry/DiagnosticSourceInstrumentation/DiagnosticSourceSubscriber.cs b/src/OpenTelemetry/DiagnosticSourceInstrumentation/DiagnosticSourceSubscriber.cs index 6fc3fb28553..7af54876057 100644 --- a/src/OpenTelemetry/DiagnosticSourceInstrumentation/DiagnosticSourceSubscriber.cs +++ b/src/OpenTelemetry/DiagnosticSourceInstrumentation/DiagnosticSourceSubscriber.cs @@ -22,12 +22,12 @@ namespace OpenTelemetry.Instrumentation { internal class DiagnosticSourceSubscriber : IDisposable, IObserver { + private readonly List listenerSubscriptions; private readonly Func handlerFactory; private readonly Func diagnosticSourceFilter; private readonly Func isEnabledFilter; private long disposed; private IDisposable allSourcesSubscription; - private List listenerSubscriptions; public DiagnosticSourceSubscriber( ListenerHandler handler, diff --git a/test/OpenTelemetry.Tests/Instrumentation/DiagnosticSourceListenerTest.cs b/test/OpenTelemetry.Tests/Instrumentation/DiagnosticSourceListenerTest.cs index 9878cb5ae3b..7e9b6fc2de7 100644 --- a/test/OpenTelemetry.Tests/Instrumentation/DiagnosticSourceListenerTest.cs +++ b/test/OpenTelemetry.Tests/Instrumentation/DiagnosticSourceListenerTest.cs @@ -21,9 +21,9 @@ namespace OpenTelemetry.Instrumentation.Tests public class DiagnosticSourceListenerTest { private const string TestSourceName = "TestSourceName"; - private DiagnosticSource diagnosticSource; - private TestListenerHandler testListenerHandler; - private DiagnosticSourceSubscriber testDiagnosticSourceSubscriber; + private readonly DiagnosticSource diagnosticSource; + private readonly TestListenerHandler testListenerHandler; + private readonly DiagnosticSourceSubscriber testDiagnosticSourceSubscriber; public DiagnosticSourceListenerTest() {