diff --git a/src/OpenTelemetry.Abstractions/Trace/IRandomGenerator.cs b/src/OpenTelemetry.Abstractions/Trace/IRandomGenerator.cs
deleted file mode 100644
index a7b79c2b755..00000000000
--- a/src/OpenTelemetry.Abstractions/Trace/IRandomGenerator.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-//
-// Copyright 2018, OpenTelemetry Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-namespace OpenTelemetry.Trace
-{
- public interface IRandomGenerator
- {
- void NextBytes(byte[] bytes);
- }
-}
diff --git a/src/OpenTelemetry/Trace/Internal/RandomGenerator.cs b/src/OpenTelemetry/Trace/Internal/RandomGenerator.cs
deleted file mode 100644
index 30a834ba164..00000000000
--- a/src/OpenTelemetry/Trace/Internal/RandomGenerator.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Copyright 2018, OpenTelemetry Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-namespace OpenTelemetry.Trace.Internal
-{
- using System;
-
- internal class RandomGenerator : IRandomGenerator
- {
- private static readonly Random Global = new Random();
-
- [ThreadStatic]
- private static Random local;
-
- private readonly int seed;
- private readonly bool sameSeed;
-
- internal RandomGenerator()
- {
- this.sameSeed = false;
- }
-
- ///
- /// This constructur uses the same seed for all the thread static random objects.
- /// You might get the same values if a random is accessed from different threads.
- /// Use only for unit tests...
- ///
- /// Value to seed for .
- internal RandomGenerator(int seed)
- {
- this.sameSeed = true;
- this.seed = seed;
- }
-
- public void NextBytes(byte[] bytes)
- {
- if (local == null)
- {
- local = new Random(this.sameSeed ? this.seed : Global.Next());
- }
-
- local.NextBytes(bytes);
- }
- }
-}
diff --git a/src/OpenTelemetry/Trace/SpanBuilderOptions.cs b/src/OpenTelemetry/Trace/SpanBuilderOptions.cs
index b1acd82c022..f1ff88707d9 100644
--- a/src/OpenTelemetry/Trace/SpanBuilderOptions.cs
+++ b/src/OpenTelemetry/Trace/SpanBuilderOptions.cs
@@ -20,15 +20,12 @@ namespace OpenTelemetry.Trace
internal class SpanBuilderOptions
{
- internal SpanBuilderOptions(IRandomGenerator randomGenerator, IStartEndHandler startEndHandler, ITraceConfig traceConfig)
+ internal SpanBuilderOptions(IStartEndHandler startEndHandler, ITraceConfig traceConfig)
{
- this.RandomHandler = randomGenerator;
this.StartEndHandler = startEndHandler;
this.TraceConfig = traceConfig;
}
- internal IRandomGenerator RandomHandler { get; }
-
internal IStartEndHandler StartEndHandler { get; }
internal ITraceConfig TraceConfig { get; }
diff --git a/src/OpenTelemetry/Trace/Tracer.cs b/src/OpenTelemetry/Trace/Tracer.cs
index 8f707be1819..52db9ed05d8 100644
--- a/src/OpenTelemetry/Trace/Tracer.cs
+++ b/src/OpenTelemetry/Trace/Tracer.cs
@@ -38,26 +38,24 @@ public sealed class Tracer : ITracer
///
/// Creates an instance of .
///
- /// Span id generator.
/// Start/end event handler.
/// Trace configuration.
- public Tracer(IRandomGenerator randomGenerator, IStartEndHandler startEndHandler, ITraceConfig traceConfig)
- : this(randomGenerator, startEndHandler, traceConfig, null, null, null)
+ public Tracer(IStartEndHandler startEndHandler, ITraceConfig traceConfig)
+ : this(startEndHandler, traceConfig, null, null, null)
{
}
///
/// Creates an instance of .
///
- /// Span id generator.
/// Start/end event handler.
/// Trace configuration.
/// Exporter for span.
/// Binary format context propagator.
/// Text format context propagator.
- public Tracer(IRandomGenerator randomGenerator, IStartEndHandler startEndHandler, ITraceConfig traceConfig, SpanExporter spanExporter, IBinaryFormat binaryFormat, ITextFormat textFormat)
+ public Tracer(IStartEndHandler startEndHandler, ITraceConfig traceConfig, SpanExporter spanExporter, IBinaryFormat binaryFormat, ITextFormat textFormat)
{
- this.spanBuilderOptions = new SpanBuilderOptions(randomGenerator, startEndHandler, traceConfig);
+ this.spanBuilderOptions = new SpanBuilderOptions(startEndHandler, traceConfig);
this.spanExporter = spanExporter ?? (SpanExporter)SpanExporter.Create(ExporterBufferSize, ExporterScheduleDelay);
this.BinaryFormat = binaryFormat ?? new BinaryFormat();
this.TextFormat = textFormat ?? new TraceContextFormat();
diff --git a/src/OpenTelemetry/Trace/Tracing.cs b/src/OpenTelemetry/Trace/Tracing.cs
index ded0a9bbda2..2dc0d8b43d5 100644
--- a/src/OpenTelemetry/Trace/Tracing.cs
+++ b/src/OpenTelemetry/Trace/Tracing.cs
@@ -32,7 +32,6 @@ public sealed class Tracing
internal Tracing()
{
- IRandomGenerator randomHandler = new RandomGenerator();
IEventQueue eventQueue = new SimpleEventQueue();
TraceConfig = new Config.TraceConfig();
@@ -54,7 +53,7 @@ internal Tracing()
((ExportComponent)ExportComponent).SampledSpanStore,
eventQueue);
- tracer = new Tracer(randomHandler, startEndHandler, TraceConfig);
+ tracer = new Tracer(startEndHandler, TraceConfig);
}
///
diff --git a/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs b/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs
index 0fd6f28f430..cca495c9759 100644
--- a/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs
+++ b/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs
@@ -48,7 +48,7 @@ public BasicTests(WebApplicationFactory factory)
public async Task SuccesfulTemplateControllerCallGeneratesASpan()
{
var startEndHandler = new Mock();
- var tracer = new Tracer(new RandomGenerator(), startEndHandler.Object, new TraceConfig());
+ var tracer = new Tracer(startEndHandler.Object, new TraceConfig());
void ConfigureTestServices(IServiceCollection services) =>
services.AddSingleton(tracer);
@@ -104,7 +104,7 @@ public async Task SuccesfulTemplateControllerCallUsesParentContext()
Tracestate.Empty
));
- var tracer = new Tracer(new RandomGenerator(), startEndHandler.Object, new TraceConfig(), null, null, tf.Object);
+ var tracer = new Tracer(startEndHandler.Object, new TraceConfig(), null, null, tf.Object);
// Arrange
using (var client = this.factory
diff --git a/test/OpenTelemetry.Collector.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs b/test/OpenTelemetry.Collector.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs
index ea6ed663c4f..6be51d3e1a6 100644
--- a/test/OpenTelemetry.Collector.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs
+++ b/test/OpenTelemetry.Collector.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs
@@ -55,7 +55,7 @@ public override async Task ProcessAsync(HttpContext context)
public async Task SuccesfulTemplateControllerCallGeneratesASpan()
{
var startEndHandler = new Mock();
- var tracer = new Tracer(new RandomGenerator(), startEndHandler.Object, new TraceConfig());
+ var tracer = new Tracer(startEndHandler.Object, new TraceConfig());
// Arrange
using (var client = this.factory
diff --git a/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs b/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs
index b4e7835f512..ebb496df0e7 100644
--- a/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs
+++ b/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs
@@ -60,7 +60,7 @@ public async Task HttpDepenenciesCollectorInjectsHeadersAsync()
expectedSpanId = sc.SpanId;
});
- var tracer = new Tracer(new RandomGenerator(), startEndHandler.Object, new TraceConfig(), null, null, tf.Object);
+ var tracer = new Tracer(startEndHandler.Object, new TraceConfig(), null, null, tf.Object);
using (var dc = new DependenciesCollector(new DependenciesCollectorOptions(), tracer, Samplers.AlwaysSample))
{
diff --git a/test/OpenTelemetry.Collector.Dependencies.Tests/HttpClientTests.cs b/test/OpenTelemetry.Collector.Dependencies.Tests/HttpClientTests.cs
index ba62ce4b412..f964bb4ae96 100644
--- a/test/OpenTelemetry.Collector.Dependencies.Tests/HttpClientTests.cs
+++ b/test/OpenTelemetry.Collector.Dependencies.Tests/HttpClientTests.cs
@@ -99,7 +99,7 @@ public async Task HttpOutCallsAreCollectedSuccesfullyAsync(HttpOutTestCase tc)
out var port);
var startEndHandler = new Mock();
- var tracer = new Tracer(new RandomGenerator(), startEndHandler.Object, new TraceConfig());
+ var tracer = new Tracer(startEndHandler.Object, new TraceConfig());
tc.url = NormaizeValues(tc.url, host, port);
using (serverLifeTime)
diff --git a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/StackExchangeRedisCallsCollectorTests.cs b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/StackExchangeRedisCallsCollectorTests.cs
index e1454b67fdc..7f4c2cbdd66 100644
--- a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/StackExchangeRedisCallsCollectorTests.cs
+++ b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/StackExchangeRedisCallsCollectorTests.cs
@@ -30,7 +30,7 @@ public class StackExchangeRedisCallsCollectorTests
public async void ProfilerSessionUsesTheSameDefault()
{
var startEndHandler = new Mock();
- var tracer = new Tracer(new RandomGenerator(), startEndHandler.Object, new TraceConfig());
+ var tracer = new Tracer(startEndHandler.Object, new TraceConfig());
using (var collector = new StackExchangeRedisCallsCollector(tracer, null, null))
{
diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs
index 4f905d4b4ff..3eff28b3b05 100644
--- a/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs
+++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs
@@ -40,7 +40,7 @@ public SpanBuilderTest()
{
// MockitoAnnotations.initMocks(this);
spanBuilderOptions =
- new SpanBuilderOptions(new RandomGenerator(), startEndHandler, traceConfig);
+ new SpanBuilderOptions(startEndHandler, traceConfig);
var configMock = Mock.Get(traceConfig);
configMock.Setup((c) => c.ActiveTraceParams).Returns(alwaysSampleTraceParams);
// when(traceConfig.getActiveTraceParams()).thenReturn(alwaysSampleTraceParams);
diff --git a/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs
index be4e8ca6835..6e56de675ba 100644
--- a/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs
+++ b/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs
@@ -36,7 +36,7 @@ public TracerTest()
{
startEndHandler = Mock.Of();
traceConfig = Mock.Of();
- tracer = new Tracer(new RandomGenerator(), startEndHandler, traceConfig);
+ tracer = new Tracer(startEndHandler, traceConfig);
}
[Fact]