Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
prepare 4.1.1 release (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-darkly authored Mar 23, 2018
1 parent 8ed370a commit f94680d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the LaunchDarkly .NET SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).

## [4.1.1] - 2018-03-23
### Fixed
- Fixed a [bug](https://github.com/launchdarkly/.net-client/issues/75) in the event sampling feature that was introduced in 4.1.0: sampling might not work correctly if events were generated from multiple threads.

## [4.1.0] - 2018-03-05
### Added
- `Configuration` now has an `EventSamplingInterval` property. If greater than zero, this causes a fraction of analytics events to be sent to LaunchDarkly: one per that number of events (pseudo-randomly). For instance, setting it to 5 would cause 20% of events to be sent on average.
Expand Down
10 changes: 9 additions & 1 deletion src/LaunchDarkly.Client/EventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private void SubmitEvents(object StateInfo)

void IStoreEvents.Add(Event eventToLog)
{
if (_config.EventSamplingInterval > 1 && _random.Next(_config.EventSamplingInterval) != 0)
if (_config.EventSamplingInterval > 1 && !ShouldAddEventWithSamplingInterval(_config.EventSamplingInterval))
{
return;
}
Expand Down Expand Up @@ -77,6 +77,14 @@ void IStoreEvents.Flush()
}
}

private bool ShouldAddEventWithSamplingInterval(int interval)
{
lock (_random)
{
return _random.Next(interval) == 0;
}
}

private async Task BulkSubmitAsync(IList<Event> events)
{
var cts = new CancellationTokenSource(_config.HttpClientTimeout);
Expand Down
4 changes: 2 additions & 2 deletions src/LaunchDarkly.Client/LaunchDarkly.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>4.1.0</VersionPrefix>
<VersionPrefix>4.1.1</VersionPrefix>
<TargetFrameworks>netstandard1.4;netstandard1.6;netstandard2.0;net45</TargetFrameworks>
<PackageLicenseUrl>https://raw.githubusercontent.com/launchdarkly/.net-client/master/LICENSE</PackageLicenseUrl>
<DebugType>portable</DebugType>
Expand Down Expand Up @@ -30,7 +30,7 @@
<AssemblyOriginatorKeyFile>../../LaunchDarkly.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
<Version>4.1.0</Version>
<Version>4.1.1</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard1.4|AnyCPU'">
Expand Down

0 comments on commit f94680d

Please sign in to comment.