Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove RandomGenerator again #143

Merged
merged 1 commit into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions src/OpenTelemetry.Abstractions/Trace/IRandomGenerator.cs

This file was deleted.

58 changes: 0 additions & 58 deletions src/OpenTelemetry/Trace/Internal/RandomGenerator.cs

This file was deleted.

5 changes: 1 addition & 4 deletions src/OpenTelemetry/Trace/SpanBuilderOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
10 changes: 4 additions & 6 deletions src/OpenTelemetry/Trace/Tracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,24 @@ public sealed class Tracer : ITracer
/// <summary>
/// Creates an instance of <see cref="ITracer"/>.
/// </summary>
/// <param name="randomGenerator">Span id generator.</param>
/// <param name="startEndHandler">Start/end event handler.</param>
/// <param name="traceConfig">Trace configuration.</param>
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)
{
}

/// <summary>
/// Creates an instance of <see cref="ITracer"/>.
/// </summary>
/// <param name="randomGenerator">Span id generator.</param>
/// <param name="startEndHandler">Start/end event handler.</param>
/// <param name="traceConfig">Trace configuration.</param>
/// <param name="spanExporter">Exporter for span.</param>
/// <param name="binaryFormat">Binary format context propagator.</param>
/// <param name="textFormat">Text format context propagator.</param>
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();
Expand Down
3 changes: 1 addition & 2 deletions src/OpenTelemetry/Trace/Tracing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public sealed class Tracing

internal Tracing()
{
IRandomGenerator randomHandler = new RandomGenerator();
IEventQueue eventQueue = new SimpleEventQueue();

TraceConfig = new Config.TraceConfig();
Expand All @@ -54,7 +53,7 @@ internal Tracing()
((ExportComponent)ExportComponent).SampledSpanStore,
eventQueue);

tracer = new Tracer(randomHandler, startEndHandler, TraceConfig);
tracer = new Tracer(startEndHandler, TraceConfig);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public BasicTests(WebApplicationFactory<Startup> factory)
public async Task SuccesfulTemplateControllerCallGeneratesASpan()
{
var startEndHandler = new Mock<IStartEndHandler>();
var tracer = new Tracer(new RandomGenerator(), startEndHandler.Object, new TraceConfig());
var tracer = new Tracer(startEndHandler.Object, new TraceConfig());

void ConfigureTestServices(IServiceCollection services) =>
services.AddSingleton<ITracer>(tracer);
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public override async Task<bool> ProcessAsync(HttpContext context)
public async Task SuccesfulTemplateControllerCallGeneratesASpan()
{
var startEndHandler = new Mock<IStartEndHandler>();
var tracer = new Tracer(new RandomGenerator(), startEndHandler.Object, new TraceConfig());
var tracer = new Tracer(startEndHandler.Object, new TraceConfig());

// Arrange
using (var client = this.factory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public async Task HttpOutCallsAreCollectedSuccesfullyAsync(HttpOutTestCase tc)
out var port);

var startEndHandler = new Mock<IStartEndHandler>();
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class StackExchangeRedisCallsCollectorTests
public async void ProfilerSessionUsesTheSameDefault()
{
var startEndHandler = new Mock<IStartEndHandler>();
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))
{
Expand Down
2 changes: 1 addition & 1 deletion test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public SpanBuilderTest()
{
// MockitoAnnotations.initMocks(this);
spanBuilderOptions =
new SpanBuilderOptions(new RandomGenerator(), startEndHandler, traceConfig);
new SpanBuilderOptions(startEndHandler, traceConfig);
var configMock = Mock.Get<ITraceConfig>(traceConfig);
configMock.Setup((c) => c.ActiveTraceParams).Returns(alwaysSampleTraceParams);
// when(traceConfig.getActiveTraceParams()).thenReturn(alwaysSampleTraceParams);
Expand Down
2 changes: 1 addition & 1 deletion test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public TracerTest()
{
startEndHandler = Mock.Of<IStartEndHandler>();
traceConfig = Mock.Of<ITraceConfig>();
tracer = new Tracer(new RandomGenerator(), startEndHandler, traceConfig);
tracer = new Tracer(startEndHandler, traceConfig);
}

[Fact]
Expand Down