Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #134 from petabridge/dev
Browse files Browse the repository at this point in the history
v0.5.3 Release
  • Loading branch information
Aaronontheweb authored Jan 29, 2020
2 parents 48103a0 + 91cc60c commit a2e598b
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 37 deletions.
5 changes: 3 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#### 0.5.2 November 11 2019 ###
* Upgraded all dependencies.
#### 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)
3 changes: 2 additions & 1 deletion build-system/windows-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ trigger:
branches:
include:
- refs/tags/*

pr: none

variables:
Expand All @@ -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)'
Expand Down
17 changes: 12 additions & 5 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Akka.TestKit.Xunit2" Version="$(AkkaVersion)" />
<PackageReference Include="Docker.DotNet" Version="3.125.2" />
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="FluentAssertions" Version="5.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="Akka.TestKit.Xunit2" Version="$(AkkaVersion)" />
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="FluentAssertions" Version="5.10.0" />
<PackageReference Include="FsCheck.Xunit" Version="2.14.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
Expand Down
23 changes: 23 additions & 0 deletions src/Petabridge.Tracing.Zipkin.Tests/TracerSpec.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

<ItemGroup>
<PackageReference Include="Akka" Version="$(AkkaVersion)" />
<PackageReference Include="Confluent.Kafka" Version="0.11.6" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.0" />
<PackageReference Include="Confluent.Kafka" Version="1.3.0" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="OpenTracing" Version="0.12.1" />
<PackageReference Include="Phobos.Actor.Common" Version="1.0.0" />
<PackageReference Include="Phobos.Actor.Common" Version="1.1.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -58,16 +57,19 @@ private void Batching()
RescheduleBatchTransmission();
});

Receive<Message<Null, byte[]>>(msg =>
Receive<DeliveryResult<Null, byte[]>>(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<ProduceException<Null, byte[]>>(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
Expand All @@ -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<Null, byte[]>);

PendingMessages.Clear();
RescheduleBatchTransmission();
Expand All @@ -98,9 +101,10 @@ private void RescheduleBatchTransmission()
protected override void PreStart()
{
RescheduleBatchTransmission();
_kafkaProducer = new KafkaTransmitter(_options.TopicName,
new Producer<Null, byte[]>(_options.ToDriverConfig(),
new NullSerializer(), new ByteArraySerializer()), _options.Serializer);
var producerBuilder = new ProducerBuilder<Null, byte[]>(_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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ namespace Petabridge.Tracing.Zipkin.Reporting.Kafka
/// </summary>
public sealed class KafkaTransmitter : IDisposable
{
private readonly Producer<Null, byte[]> _producer;
private readonly IProducer<Null, byte[]> _producer;
private readonly ISpanSerializer _serializer;
private readonly string _topicName;

public KafkaTransmitter(string topicName, Producer<Null, byte[]> producer, ISpanSerializer serializer)
public KafkaTransmitter(string topicName, IProducer<Null, byte[]> producer, ISpanSerializer serializer)
{
_producer = producer;
_serializer = serializer;
Expand All @@ -32,14 +32,13 @@ public void Dispose()
_producer?.Dispose();
}

public async Task<Message<Null, byte[]>> TransmitSpans(IEnumerable<Span> spans)
public async Task<DeliveryResult<Null, byte[]>> TransmitSpans(IEnumerable<Span> 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<Null, byte[]>() { Key = null, Value = outboundBytes }).ConfigureAwait(false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public ZipkinKafkaReportingOptions(IReadOnlyList<string> bootstrapServers,
/// Creates a configuration object in the style expected by the Confluent.Kafka driver.
/// </summary>
/// <returns>A new dictionary instance each time.</returns>
public IReadOnlyDictionary<string, object> ToDriverConfig()
public IReadOnlyDictionary<string, string> ToDriverConfig()
{
return new Dictionary<string, object>
return new Dictionary<string, string>
{
{"bootstrap.servers", string.Join(",", BootstrapServers)},
{"request.required.acks", "0"} // don't wait for broker to send ACKs back (it's just trace data)
Expand Down
3 changes: 2 additions & 1 deletion src/Petabridge.Tracing.Zipkin/ZipkinTracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<PropertyGroup>
<Copyright>Copyright © 2015-2018 Petabridge</Copyright>
<Authors>Petabridge</Authors>
<VersionPrefix>0.5.2</VersionPrefix>
<PackageReleaseNotes>Upgraded all dependencies.</PackageReleaseNotes>
<VersionPrefix>0.5.3</VersionPrefix>
<PackageReleaseNotes>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)</PackageReleaseNotes>
<PackageIconUrl>https://petabridge.com/images/logo.png</PackageIconUrl>
<PackageProjectUrl>
https://github.com/petabridge/Petabridge.Tracing.Zipkin
Expand All @@ -15,7 +16,7 @@
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>
<PropertyGroup>
<AkkaVersion>1.3.16</AkkaVersion>
<AkkaVersion>1.3.17</AkkaVersion>
<XunitVersion>2.4.1</XunitVersion>
<NBenchVersion>1.2.2</NBenchVersion>
<TestSdkVersion>16.4.0</TestSdkVersion>
Expand Down

0 comments on commit a2e598b

Please sign in to comment.