Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.

Commit 4b6788d

Browse files
authored
Merge pull request #32 from influxdata/dev
1.0.0 Release
2 parents 66f6cd7 + bac527e commit 4b6788d

18 files changed

Lines changed: 842 additions & 19 deletions

Build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Push-Location $PSScriptRoot
77
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
88
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
99
$suffix = @{
10-
$true = "beta-$revision";
10+
$true = "$revision";
1111
$false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
1212

1313
if(Test-Path .\artifacts) {

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ if (!influxResult.Success)
8989
Console.Error.WriteLine(influxResult.ErrorMessage);
9090
```
9191

92+
## Diagnostics
93+
94+
The collector will not throw exceptions when communication errors occur. To be notified of metric collection issues, register an error handler:
95+
96+
```csharp
97+
CollectorLog.RegisterErrorHandler((message, exception) =>
98+
{
99+
Console.WriteLine($"{message}: {exception}");
100+
});
101+
```
102+
92103
## Status
93104

94105
This project is still undergoing some change while in development, but the core functionality is stabilizing. See issues tagged `enhancement` for roadmap items. It's currently targeting .NET 4.5.1 and .NET Core using Visual Studio 2017.

appveyor.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@ version: '{build}'
22
skip_tags: true
33
image: Visual Studio 2017
44
configuration: Release
5-
environment:
6-
# Set the DOTNET_SKIP_FIRST_TIME_EXPERIENCE environment variable to stop wasting time caching packages
7-
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
8-
# Disable sending usage data to Microsoft
9-
DOTNET_CLI_TELEMETRY_OPTOUT: true
10-
install:
11-
- ps: mkdir -Force ".\build\" | Out-Null
12-
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
13-
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli"
14-
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.1'
15-
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
165
build_script:
176
- ps: ./Build.ps1
187
test: off

influxdb-csharp.sln

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26228.9
4+
VisualStudioVersion = 15.0.26730.3
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{72DC28B9-37B5-425C-8532-5CA91D253A70}"
77
EndProject
@@ -29,6 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample", "sample\Sample\Sam
2929
EndProject
3030
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfluxDB.Collector", "src\InfluxDB.Collector\InfluxDB.Collector.csproj", "{F690F3E3-D9F0-441A-9E70-4F70998BDD1B}"
3131
EndProject
32+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmark", "sample\Benchmark\Benchmark.csproj", "{2A34EE83-FB59-4A41-8BB5-174BE678533E}"
33+
EndProject
3234
Global
3335
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3436
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,10 @@ Global
5153
{F690F3E3-D9F0-441A-9E70-4F70998BDD1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
5254
{F690F3E3-D9F0-441A-9E70-4F70998BDD1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
5355
{F690F3E3-D9F0-441A-9E70-4F70998BDD1B}.Release|Any CPU.Build.0 = Release|Any CPU
56+
{2A34EE83-FB59-4A41-8BB5-174BE678533E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57+
{2A34EE83-FB59-4A41-8BB5-174BE678533E}.Debug|Any CPU.Build.0 = Debug|Any CPU
58+
{2A34EE83-FB59-4A41-8BB5-174BE678533E}.Release|Any CPU.ActiveCfg = Release|Any CPU
59+
{2A34EE83-FB59-4A41-8BB5-174BE678533E}.Release|Any CPU.Build.0 = Release|Any CPU
5460
EndGlobalSection
5561
GlobalSection(SolutionProperties) = preSolution
5662
HideSolutionNode = FALSE
@@ -60,5 +66,9 @@ Global
6066
{34173CA2-1551-4E46-B8E7-E4629A48E415} = {75C71D21-E6FD-493F-A355-997EEF4DDF11}
6167
{DC6028D6-ED1D-4857-B5EB-28BA05E3F531} = {CD65EE64-FDA8-4ED9-A7F2-81BDD9F64C64}
6268
{F690F3E3-D9F0-441A-9E70-4F70998BDD1B} = {72DC28B9-37B5-425C-8532-5CA91D253A70}
69+
{2A34EE83-FB59-4A41-8BB5-174BE678533E} = {CD65EE64-FDA8-4ED9-A7F2-81BDD9F64C64}
70+
EndGlobalSection
71+
GlobalSection(ExtensibilityGlobals) = postSolution
72+
SolutionGuid = {AB0C6BCE-235A-4018-8644-7652EC826FF5}
6373
EndGlobalSection
6474
EndGlobal

sample/Benchmark/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BenchmarkDotNet.Artifacts

sample/Benchmark/Benchmark.csproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net46</TargetFrameworks>
5+
<AssemblyName>Sample</AssemblyName>
6+
<PackageId>Sample</PackageId>
7+
<ApplicationIcon />
8+
<OutputType>Exe</OutputType>
9+
<StartupObject />
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="BenchmarkDotNet" Version="0.10.9" />
14+
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.10.9" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\..\src\InfluxDB.LineProtocol\InfluxDB.LineProtocol.csproj" />
19+
</ItemGroup>
20+
</Project>

sample/Benchmark/EscapeTagNames.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using System.IO;
2+
using BenchmarkDotNet.Attributes;
3+
4+
namespace Benchmark
5+
{
6+
[MemoryDiagnoser]
7+
public class EscapeTagNames
8+
{
9+
private const int N = 500;
10+
11+
[Params("my_tag", "my tag")]
12+
public string TagName { get; set; }
13+
14+
[Benchmark(Baseline = true)]
15+
public string NoEscaping()
16+
{
17+
var writer = new StringWriter();
18+
19+
for (var i = 0; i < N; i++)
20+
{
21+
writer.Write(TagName);
22+
}
23+
24+
return writer.ToString();
25+
}
26+
27+
[Benchmark]
28+
public string Replace()
29+
{
30+
var writer = new StringWriter();
31+
32+
for (var i = 0; i < N; i++)
33+
{
34+
writer.Write(TagName
35+
.Replace("=", "\\=")
36+
.Replace(" ", "\\ ")
37+
.Replace(",", "\\,"));
38+
}
39+
40+
return writer.ToString();
41+
}
42+
43+
[Benchmark]
44+
public string WriteCharOrEscapeString()
45+
{
46+
var writer = new StringWriter();
47+
48+
for (var i = 0; i < N; i++)
49+
{
50+
foreach (char c in TagName)
51+
{
52+
switch (c)
53+
{
54+
case ' ':
55+
writer.Write("\\ ");
56+
break;
57+
case ',':
58+
writer.Write("\\,");
59+
break;
60+
case '=':
61+
writer.Write("\\=");
62+
break;
63+
default:
64+
writer.Write(c);
65+
break;
66+
}
67+
}
68+
}
69+
70+
return writer.ToString();
71+
}
72+
}
73+
}

sample/Benchmark/Program.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Benchmark
2+
{
3+
using BenchmarkDotNet.Running;
4+
5+
public class Program
6+
{
7+
public static void Main(string[] args)
8+
{
9+
BenchmarkRunner.Run<WriteLineProtocol>();
10+
}
11+
}
12+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using BenchmarkDotNet.Attributes;
7+
using InfluxDB.LineProtocol;
8+
using InfluxDB.LineProtocol.Payload;
9+
10+
namespace Benchmark
11+
{
12+
[MemoryDiagnoser]
13+
public class WriteLineProtocol
14+
{
15+
private const int N = 500;
16+
17+
private static readonly string[] Colours = { "red", "blue", "green" };
18+
19+
private readonly (DateTime timestamp, string colour, double value)[] data;
20+
21+
public WriteLineProtocol()
22+
{
23+
var random = new Random(755);
24+
var now = DateTime.UtcNow;
25+
data = Enumerable.Range(0, N).Select(i => (now.AddMilliseconds(random.Next(2000)), Colours[random.Next(Colours.Length)], random.NextDouble())).ToArray();
26+
}
27+
28+
[Benchmark(Baseline = true)]
29+
public string LineProtocolPoint()
30+
{
31+
var payload = new LineProtocolPayload();
32+
33+
foreach (var point in data)
34+
{
35+
payload.Add(new LineProtocolPoint(
36+
"example",
37+
new Dictionary<string, object>
38+
{
39+
{"value", point.value}
40+
},
41+
new Dictionary<string, string>
42+
{
43+
{"colour", point.colour}
44+
},
45+
point.timestamp
46+
));
47+
}
48+
49+
var writer = new StringWriter();
50+
payload.Format(writer);
51+
return writer.ToString();
52+
}
53+
54+
[Benchmark]
55+
public string LineProtocolWriter()
56+
{
57+
var writer = new LineProtocolWriter();
58+
59+
foreach (var point in data)
60+
{
61+
writer.Measurement("example").Tag("colour", point.colour).Field("value", point.value).Timestamp(point.timestamp);
62+
}
63+
64+
return writer.ToString();
65+
}
66+
67+
[Benchmark]
68+
public string StringInterpolation()
69+
{
70+
var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
71+
72+
var lines = new List<string>();
73+
74+
foreach (var point in data)
75+
{
76+
var timestamp = point.timestamp - unixEpoch;
77+
lines.Add($"example,colour={point.colour} value={point.value} {timestamp.Ticks * 100L}");
78+
}
79+
80+
return string.Join("\n", lines);
81+
}
82+
83+
[Benchmark]
84+
public string StringBuilder()
85+
{
86+
var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
87+
88+
var lines = new StringBuilder();
89+
90+
foreach (var point in data)
91+
{
92+
var timestamp = point.timestamp - unixEpoch;
93+
lines.Append("example,colour=").Append(point.colour).Append(" value=").Append(point.value).Append(" ").Append(timestamp.Ticks * 100L).Append("\n");
94+
}
95+
96+
return lines.ToString();
97+
}
98+
}
99+
}

src/InfluxDB.Collector/InfluxDB.Collector.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
2424
<Reference Include="System" />
25+
<Reference Include="System.Core" />
2526
</ItemGroup>
2627

2728
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">

0 commit comments

Comments
 (0)