diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 51bf065..5faf9de 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,2 +1,3 @@ -#### 0.5.2 November 11 2019 ### -* Upgraded all dependencies. \ No newline at end of file +#### 0.5.3 January 29 2020 ### +* Upgraded to latest Akka.NET, Kafka drivers. +* [OpenTracing: Using AsyncLocalScopeManager as a default tracer's ScopeManager](https://github.com/petabridge/Petabridge.Tracing.Zipkin/pull/131) \ No newline at end of file diff --git a/build-system/windows-release.yaml b/build-system/windows-release.yaml index 7c76df6..d774f6a 100644 --- a/build-system/windows-release.yaml +++ b/build-system/windows-release.yaml @@ -9,6 +9,7 @@ trigger: branches: include: - refs/tags/* + pr: none variables: @@ -26,7 +27,7 @@ steps: displayName: 'FAKE Build' inputs: filename: build.cmd - arguments: 'All SignClientUser=$(signingUsername) SignClientSecret=$(signingPassword) nugetpublishurl=https://api.nuget.org/v3/index.json nugetkey=$(nugetKey)' + arguments: 'nuget SignClientUser=$(signingUsername) SignClientSecret=$(signingPassword) nugetpublishurl=https://api.nuget.org/v3/index.json nugetkey=$(nugetKey)' - task: GitHubRelease@0 displayName: 'GitHub release (create)' diff --git a/build.fsx b/build.fsx index 9a79ea1..ecab0ae 100644 --- a/build.fsx +++ b/build.fsx @@ -23,15 +23,22 @@ let solutionFile = FindFirstMatchingFile "*.sln" __SOURCE_DIRECTORY__ // dynami let buildNumber = environVarOrDefault "BUILD_NUMBER" "0" let hasTeamCity = (not (buildNumber = "0")) // check if we have the TeamCity environment variable for build # set let preReleaseVersionSuffix = "beta" + (if (not (buildNumber = "0")) then (buildNumber) else DateTime.UtcNow.Ticks.ToString()) -let versionSuffix = - match (getBuildParam "nugetprerelease") with - | "dev" -> preReleaseVersionSuffix - | _ -> "" let releaseNotes = - File.ReadLines "./RELEASE_NOTES.md" + File.ReadLines (__SOURCE_DIRECTORY__ @@ "RELEASE_NOTES.md") |> ReleaseNotesHelper.parseReleaseNotes +let versionFromReleaseNotes = + match releaseNotes.SemVer.PreRelease with + | Some r -> r.Origin + | None -> "" + +let versionSuffix = + match (getBuildParam "nugetprerelease") with + | "dev" -> preReleaseVersionSuffix + | "" -> versionFromReleaseNotes + | str -> str + // Directories let toolsDir = __SOURCE_DIRECTORY__ @@ "tools" let output = __SOURCE_DIRECTORY__ @@ "bin" diff --git a/src/Petabridge.Tracing.Zipkin.Integration.Tests/Petabridge.Tracing.Zipkin.Integration.Tests.csproj b/src/Petabridge.Tracing.Zipkin.Integration.Tests/Petabridge.Tracing.Zipkin.Integration.Tests.csproj index 9791ce3..dcad978 100644 --- a/src/Petabridge.Tracing.Zipkin.Integration.Tests/Petabridge.Tracing.Zipkin.Integration.Tests.csproj +++ b/src/Petabridge.Tracing.Zipkin.Integration.Tests/Petabridge.Tracing.Zipkin.Integration.Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/Petabridge.Tracing.Zipkin.Tests/Petabridge.Tracing.Zipkin.Tests.csproj b/src/Petabridge.Tracing.Zipkin.Tests/Petabridge.Tracing.Zipkin.Tests.csproj index cb85f7a..6509fff 100644 --- a/src/Petabridge.Tracing.Zipkin.Tests/Petabridge.Tracing.Zipkin.Tests.csproj +++ b/src/Petabridge.Tracing.Zipkin.Tests/Petabridge.Tracing.Zipkin.Tests.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/Petabridge.Tracing.Zipkin.Tests/TracerSpec.cs b/src/Petabridge.Tracing.Zipkin.Tests/TracerSpec.cs new file mode 100644 index 0000000..2acd4ee --- /dev/null +++ b/src/Petabridge.Tracing.Zipkin.Tests/TracerSpec.cs @@ -0,0 +1,23 @@ +using FluentAssertions; +using Xunit; + +namespace Petabridge.Tracing.Zipkin.Tests +{ + public class TracerSpec + { + [Fact] + public void Should_have_active_span_when_scope_is_used() + { + var url = "http://localhost:9411"; + using (var tracer = new ZipkinTracer(new ZipkinTracerOptions(url, "ZipkinTest", debug: true))) + { + using (var scope = tracer.BuildSpan("ShouldSendSpans").StartActive(finishSpanOnDispose: true)) + { + tracer.ActiveSpan.Should().NotBeNull(); + } + + tracer.ActiveSpan.Should().BeNull(); + } + } + } +} \ No newline at end of file diff --git a/src/Petabridge.Tracing.Zipkin/Petabridge.Tracing.Zipkin.csproj b/src/Petabridge.Tracing.Zipkin/Petabridge.Tracing.Zipkin.csproj index abdfeb8..d6b7215 100644 --- a/src/Petabridge.Tracing.Zipkin/Petabridge.Tracing.Zipkin.csproj +++ b/src/Petabridge.Tracing.Zipkin/Petabridge.Tracing.Zipkin.csproj @@ -14,11 +14,11 @@ - - + + - + \ No newline at end of file diff --git a/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/KafkaReportingActor.cs b/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/KafkaReportingActor.cs index ccd81ec..bbd0229 100644 --- a/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/KafkaReportingActor.cs +++ b/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/KafkaReportingActor.cs @@ -10,7 +10,6 @@ using Akka.Actor; using Akka.Event; using Confluent.Kafka; -using Confluent.Kafka.Serialization; using Phobos.Actor.Common; namespace Petabridge.Tracing.Zipkin.Reporting.Kafka @@ -58,16 +57,19 @@ private void Batching() RescheduleBatchTransmission(); }); - Receive>(msg => + Receive>(result => { - if (msg.Error.HasError && _log.IsErrorEnabled) + if (_log.IsDebugEnabled) + _log.Debug("Successfully posted spans [{0} bytes] to Kafka for topic [{1}]", result.Message.Value.Length, result.Topic); + }); + + Receive>(ex => + { + if (_log.IsErrorEnabled) _log.Error( "Error [{0}][{1}] occurred while uploading spans [{3} bytes] to Kafka endpoints [{2}] for topic [{4}]", - msg.Error.Code, msg.Error.Reason, - string.Join(",", _options.BootstrapServers), msg.Value.Length, msg.Topic); - else if (_log.IsDebugEnabled) - _log.Debug("Successfully posted spans [{0} bytes] to Kafka for topic [{1}]", msg.Value.Length, - msg.Topic); + ex.Error.Code, ex.Error.Reason, + string.Join(",", _options.BootstrapServers), ex.DeliveryResult.Message.Value.Length, ex.DeliveryResult.Topic); }); // Indicates that one of our HTTP requests timed out @@ -81,7 +83,8 @@ private void Batching() private void ExecuteDelivery() { - _kafkaProducer.TransmitSpans(PendingMessages).PipeTo(Self); + _kafkaProducer.TransmitSpans(PendingMessages) + .PipeTo(Self, failure: ex => ex as ProduceException); PendingMessages.Clear(); RescheduleBatchTransmission(); @@ -98,9 +101,10 @@ private void RescheduleBatchTransmission() protected override void PreStart() { RescheduleBatchTransmission(); - _kafkaProducer = new KafkaTransmitter(_options.TopicName, - new Producer(_options.ToDriverConfig(), - new NullSerializer(), new ByteArraySerializer()), _options.Serializer); + var producerBuilder = new ProducerBuilder(_options.ToDriverConfig()) + .SetKeySerializer(Serializers.Null) + .SetValueSerializer(Serializers.ByteArray); + _kafkaProducer = new KafkaTransmitter(_options.TopicName, producerBuilder.Build(), _options.Serializer); if (_options.DebugLogging) _log.Debug("Connected to Kafka at [{0}] on topic [{1}] for Zipkin", diff --git a/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/KafkaTransmitter.cs b/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/KafkaTransmitter.cs index cf0fea4..f0d2b24 100644 --- a/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/KafkaTransmitter.cs +++ b/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/KafkaTransmitter.cs @@ -16,11 +16,11 @@ namespace Petabridge.Tracing.Zipkin.Reporting.Kafka /// public sealed class KafkaTransmitter : IDisposable { - private readonly Producer _producer; + private readonly IProducer _producer; private readonly ISpanSerializer _serializer; private readonly string _topicName; - public KafkaTransmitter(string topicName, Producer producer, ISpanSerializer serializer) + public KafkaTransmitter(string topicName, IProducer producer, ISpanSerializer serializer) { _producer = producer; _serializer = serializer; @@ -32,14 +32,13 @@ public void Dispose() _producer?.Dispose(); } - public async Task> TransmitSpans(IEnumerable spans) + public async Task> TransmitSpans(IEnumerable spans) { - using (var stream = - SerializationStreamManager.StreamManager.GetStream("Petabridge.Tracing.Zipkin.KafkaTransmitter")) + using (var stream = SerializationStreamManager.StreamManager.GetStream("Petabridge.Tracing.Zipkin.KafkaTransmitter")) { _serializer.Serialize(stream, spans); var outboundBytes = stream.ToArray(); - return await _producer.ProduceAsync(_topicName, null, outboundBytes).ConfigureAwait(false); + return await _producer.ProduceAsync(_topicName, new Message() { Key = null, Value = outboundBytes }).ConfigureAwait(false); } } } diff --git a/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/ZipkinKafkaReportingOptions.cs b/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/ZipkinKafkaReportingOptions.cs index 7d3195a..7412f24 100644 --- a/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/ZipkinKafkaReportingOptions.cs +++ b/src/Petabridge.Tracing.Zipkin/Reporting/Kafka/ZipkinKafkaReportingOptions.cs @@ -87,9 +87,9 @@ public ZipkinKafkaReportingOptions(IReadOnlyList bootstrapServers, /// Creates a configuration object in the style expected by the Confluent.Kafka driver. /// /// A new dictionary instance each time. - public IReadOnlyDictionary ToDriverConfig() + public IReadOnlyDictionary ToDriverConfig() { - return new Dictionary + return new Dictionary { {"bootstrap.servers", string.Join(",", BootstrapServers)}, {"request.required.acks", "0"} // don't wait for broker to send ACKs back (it's just trace data) diff --git a/src/Petabridge.Tracing.Zipkin/ZipkinTracer.cs b/src/Petabridge.Tracing.Zipkin/ZipkinTracer.cs index 513172b..814a0c8 100644 --- a/src/Petabridge.Tracing.Zipkin/ZipkinTracer.cs +++ b/src/Petabridge.Tracing.Zipkin/ZipkinTracer.cs @@ -7,6 +7,7 @@ using System; using OpenTracing; using OpenTracing.Propagation; +using OpenTracing.Util; using Petabridge.Tracing.Zipkin.Exceptions; using Petabridge.Tracing.Zipkin.Propagation; using Petabridge.Tracing.Zipkin.Sampling; @@ -29,7 +30,7 @@ public ZipkinTracer(ZipkinTracerOptions options) _reporter = options.Reporter; LocalEndpoint = options.LocalEndpoint; TimeProvider = options.TimeProvider ?? new DateTimeOffsetTimeProvider(); - ScopeManager = options.ScopeManager ?? NoOp.ScopeManager; + ScopeManager = options.ScopeManager ?? new AsyncLocalScopeManager(); IdProvider = options.IdProvider ?? ThreadLocalRngSpanIdProvider.TraceId128BitProvider; Sampler = options.Sampler ?? NoSampler.Instance; Options = options; diff --git a/src/common.props b/src/common.props index befdc1c..710063e 100644 --- a/src/common.props +++ b/src/common.props @@ -2,8 +2,9 @@ Copyright © 2015-2018 Petabridge Petabridge - 0.5.2 - Upgraded all dependencies. + 0.5.3 + Upgraded to latest Akka.NET, Kafka drivers. +[OpenTracing: Using AsyncLocalScopeManager as a default tracer's ScopeManager](https://github.com/petabridge/Petabridge.Tracing.Zipkin/pull/131) https://petabridge.com/images/logo.png https://github.com/petabridge/Petabridge.Tracing.Zipkin @@ -15,7 +16,7 @@ $(NoWarn);CS1591 - 1.3.16 + 1.3.17 2.4.1 1.2.2 16.4.0