Skip to content

Commit

Permalink
Merge pull request #60 from evilpilaf/naming
Browse files Browse the repository at this point in the history
Fix naming of values for consistency with the Honeycomb documentation
  • Loading branch information
evilpilaf authored Jan 24, 2021
2 parents 6034661 + bf0d275 commit 97c1c98
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 32 deletions.
10 changes: 9 additions & 1 deletion HoneycombSerilogSink.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E4F55B6D-46A4-49ED-B2B6-34CF950436F7}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
azure-pipelines.yml = azure-pipelines.yml
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
global.json = global.json
LICENSE.TXT = LICENSE.TXT
README.md = README.md
release-pipeline.yml = release-pipeline.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{87AFA633-EBC9-4A0C-AE07-C6616BAFB602}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Honeycomb.Serilog.Sink.Tests", "test\Honeycomb.Serilog.Sink.Tests\Honeycomb.Serilog.Sink.Tests.csproj", "{3153A916-94B4-418D-84BD-EB1649449CFF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Honeycomb.Serilog.Sink.Tests", "test\Honeycomb.Serilog.Sink.Tests\Honeycomb.Serilog.Sink.Tests.csproj", "{3153A916-94B4-418D-84BD-EB1649449CFF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
3 changes: 3 additions & 0 deletions HoneycombSerilogSink.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=dataset/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serilog/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ using Honeycomb.Serilog.Sink;

[...]

string teamId = "The Id of your team as defined in Honeycomb";
string dataset = "The name of the dataset wher your data will be sent";
string apiKey = "The api key given to you in Honeycomb";

var logger = new LoggerConfiguration()
.WriteTo
[...]
.HoneycombSink(teamId, apiKey)
.HoneycombSink(dataset, apiKey)
[...]
.CreateLogger();
```
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.1.201"
"version": "3.1.*"
}
}
6 changes: 3 additions & 3 deletions src/Honeycomb.Serilog.Sink/HoneycombSerilogSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ private static SocketsHttpHandler SocketsHttpHandler

private const string SelfLogMessageText = "Failure sending event to Honeycomb, received {statusCode} response with content {content}";

/// <param name="teamId">The name of the team to submit the events to</param>
/// <param name="dataset">The name of the dataset where to send the events to</param>
/// <param name="apiKey">The API key given in the Honeycomb ui</param>
public HoneycombSerilogSink(string teamId, string apiKey)
public HoneycombSerilogSink(string dataset, string apiKey)
{
_teamId = string.IsNullOrWhiteSpace(teamId) ? throw new ArgumentNullException(nameof(teamId)) : teamId;
_teamId = string.IsNullOrWhiteSpace(dataset) ? throw new ArgumentNullException(nameof(dataset)) : dataset;
_apiKey = string.IsNullOrWhiteSpace(apiKey) ? throw new ArgumentNullException(nameof(apiKey)) : apiKey;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;net462;net47;net471;net472;net48;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net461;net462;net47;net471;net472;net48;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1;net5.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -13,7 +13,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<PackageReference Include="coverlet.collector" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -27,8 +27,8 @@
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'netcoreapp3.1' ">
<PackageReference Include="System.Text.Json" Version="5.0.0" />
<ItemGroup Condition=" '$(TargetFramework)' != 'netcoreapp3.1' AND '$(TargetFramework)' != 'net5.0'">
<PackageReference Include="System.Text.Json" Version="5.0.1" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions test/Honeycomb.Serilog.Sink.Tests/HoneycombSerilogSinkStub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ internal class HoneycombSerilogSinkStub : HoneycombSerilogSink
{
private readonly HttpClient _client;

public HoneycombSerilogSinkStub(HttpClient client, string teamId, string apiKey)
: base(teamId, apiKey)
public HoneycombSerilogSinkStub(HttpClient client, string dataset, string apiKey)
: base(dataset, apiKey)
{
_client = client;
}
Expand Down
38 changes: 19 additions & 19 deletions test/Honeycomb.Serilog.Sink.Tests/HoneycombSerilogSinkTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
Expand All @@ -23,22 +23,22 @@ public class HoneycombSerilogSinkTests
[Theory]
[InlineData("")]
[InlineData(null)]
public void Create_WhenInvalidTeamIdIsProvided_ThrowsArgumentException(string teamId)
public void Create_WhenInvalidTeamIdIsProvided_ThrowsArgumentException(string dataset)
{
const string apiKey = nameof(apiKey);
Action action = () => CreateSut(teamId, apiKey);
Action action = () => CreateSut(dataset, apiKey);

action.Should().Throw<ArgumentNullException>()
.Which.Message.Should().Contain(nameof(teamId));
.Which.Message.Should().Contain(nameof(dataset));
}

[Theory]
[InlineData("")]
[InlineData(null)]
public void Create_WhenInvalidApiKeyIsProvided_ThrowsArgumentException(string apiKey)
{
const string teamId = nameof(teamId);
Action action = () => CreateSut(teamId, apiKey);
const string dataset = nameof(dataset);
Action action = () => CreateSut(dataset, apiKey);

action.Should().Throw<ArgumentNullException>()
.Which.Message.Should().Contain(nameof(apiKey));
Expand All @@ -47,12 +47,12 @@ public void Create_WhenInvalidApiKeyIsProvided_ThrowsArgumentException(string ap
[Fact]
public async Task Emit_AlwaysSendsApiKeyAsync()
{
const string teamId = nameof(teamId);
const string dataset = nameof(dataset);
const string apiKey = nameof(apiKey);

HttpClientStub clientStub = A.HttpClient();

var sut = CreateSut(teamId, apiKey, clientStub);
var sut = CreateSut(dataset, apiKey, clientStub);

await sut.EmitTestable(new LogEvent(DateTimeOffset.Now, LogEventLevel.Information, null, new MessageTemplate("", Enumerable.Empty<MessageTemplateToken>()), Enumerable.Empty<LogEventProperty>()));

Expand All @@ -63,27 +63,27 @@ public async Task Emit_AlwaysSendsApiKeyAsync()
[Fact]
public async Task Emit_CallsEndpointUsingTeamId()
{
const string teamId = nameof(teamId);
const string dataset = nameof(dataset);
const string apiKey = nameof(apiKey);

HttpClientStub clientStub = A.HttpClient();

var sut = CreateSut(teamId, apiKey, clientStub);
var sut = CreateSut(dataset, apiKey, clientStub);

await sut.EmitTestable(new LogEvent(DateTimeOffset.Now, LogEventLevel.Information, null, new MessageTemplate("", Enumerable.Empty<MessageTemplateToken>()), Enumerable.Empty<LogEventProperty>()));

clientStub.RequestSubmitted.RequestUri.ToString().Should().EndWith(teamId);
clientStub.RequestSubmitted.RequestUri.ToString().Should().EndWith(dataset);
}

[Fact]
public async Task Emit_GivenNoExceptionIsLogged_SerializesLogMessageAsJson_HasNoExceptionInMessageAsync()
{
const string teamId = nameof(teamId);
const string dataset = nameof(dataset);
const string apiKey = nameof(apiKey);

HttpClientStub clientStub = A.HttpClient();

var sut = CreateSut(teamId, apiKey, clientStub);
var sut = CreateSut(dataset, apiKey, clientStub);

var level = LogEventLevel.Fatal;

Expand Down Expand Up @@ -115,12 +115,12 @@ public async Task Emit_GivenNoExceptionIsLogged_SerializesLogMessageAsJson_HasNo
[Fact]
public async Task Emit_GivenAnExceptionToLog_SerializesLogMessageAsJson_IncludesExceptionInMessageAsync()
{
const string teamId = nameof(teamId);
const string dataset = nameof(dataset);
const string apiKey = nameof(apiKey);

HttpClientStub clientStub = A.HttpClient();

var sut = CreateSut(teamId, apiKey, clientStub);
var sut = CreateSut(dataset, apiKey, clientStub);

var level = LogEventLevel.Fatal;

Expand Down Expand Up @@ -152,12 +152,12 @@ public async Task Emit_GivenAnExceptionToLog_SerializesLogMessageAsJson_Includes
[Fact]
public async Task Emit_GivenAMessageWithProperties_SendsThemAllAsync()
{
const string teamId = nameof(teamId);
const string dataset = nameof(dataset);
const string apiKey = nameof(apiKey);

HttpClientStub clientStub = A.HttpClient();

var sut = CreateSut(teamId, apiKey, clientStub);
var sut = CreateSut(dataset, apiKey, clientStub);

var level = LogEventLevel.Fatal;

Expand Down Expand Up @@ -186,9 +186,9 @@ public async Task Emit_GivenAMessageWithProperties_SendsThemAllAsync()
}
}

private HoneycombSerilogSinkStub CreateSut(string teamId, string apiKey, HttpClient client = null)
private HoneycombSerilogSinkStub CreateSut(string dataset, string apiKey, HttpClient client = null)
{
return new HoneycombSerilogSinkStub(client, teamId, apiKey);
return new HoneycombSerilogSinkStub(client, dataset, apiKey);
}
}
}

0 comments on commit 97c1c98

Please sign in to comment.