Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion influxdb-csharp.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.3
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{72DC28B9-37B5-425C-8532-5CA91D253A70}"
EndProject
Expand Down Expand Up @@ -31,6 +31,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfluxDB.Collector", "src\I
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmark", "sample\Benchmark\Benchmark.csproj", "{2A34EE83-FB59-4A41-8BB5-174BE678533E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InfluxDb.UdpSupport.ConsoleTest", "test\Consoles\InfluxDb.UdpSupport.ConsoleTest\InfluxDb.UdpSupport.ConsoleTest.csproj", "{1B138F1D-A772-4656-9142-442DEFB969E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample-UDP-Support", "sample\Sample-UDP-Support\Sample-UDP-Support.csproj", "{62A1A1E7-CCF5-49D9-B462-F11EEF7F5591}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -57,6 +61,14 @@ Global
{2A34EE83-FB59-4A41-8BB5-174BE678533E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A34EE83-FB59-4A41-8BB5-174BE678533E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A34EE83-FB59-4A41-8BB5-174BE678533E}.Release|Any CPU.Build.0 = Release|Any CPU
{1B138F1D-A772-4656-9142-442DEFB969E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B138F1D-A772-4656-9142-442DEFB969E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B138F1D-A772-4656-9142-442DEFB969E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B138F1D-A772-4656-9142-442DEFB969E5}.Release|Any CPU.Build.0 = Release|Any CPU
{62A1A1E7-CCF5-49D9-B462-F11EEF7F5591}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62A1A1E7-CCF5-49D9-B462-F11EEF7F5591}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62A1A1E7-CCF5-49D9-B462-F11EEF7F5591}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62A1A1E7-CCF5-49D9-B462-F11EEF7F5591}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -67,6 +79,8 @@ Global
{DC6028D6-ED1D-4857-B5EB-28BA05E3F531} = {CD65EE64-FDA8-4ED9-A7F2-81BDD9F64C64}
{F690F3E3-D9F0-441A-9E70-4F70998BDD1B} = {72DC28B9-37B5-425C-8532-5CA91D253A70}
{2A34EE83-FB59-4A41-8BB5-174BE678533E} = {CD65EE64-FDA8-4ED9-A7F2-81BDD9F64C64}
{1B138F1D-A772-4656-9142-442DEFB969E5} = {75C71D21-E6FD-493F-A355-997EEF4DDF11}
{62A1A1E7-CCF5-49D9-B462-F11EEF7F5591} = {CD65EE64-FDA8-4ED9-A7F2-81BDD9F64C64}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AB0C6BCE-235A-4018-8644-7652EC826FF5}
Expand Down
6 changes: 3 additions & 3 deletions sample/Benchmark/Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net46</TargetFrameworks>
<TargetFrameworks>net461</TargetFrameworks>
<AssemblyName>Sample</AssemblyName>
<PackageId>Sample</PackageId>
<ApplicationIcon />
Expand All @@ -10,8 +10,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.10.9" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.10.9" />
<PackageReference Include="BenchmarkDotNet" Version="0.10.12" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.10.12" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions sample/Sample-UDP-Support/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
73 changes: 73 additions & 0 deletions sample/Sample-UDP-Support/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using InfluxDB.Collector;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;

// influx-db command line:
// start with
// # influx
// # show databases
// # CREATE DATABASE {name}
// # DROP DATABASE {name}
// # precision rfc3339
// # use <database>
// # SHOW MEASUREMENTS
// # SHOW MEASUREMENTS WITH MEASUREMENT =~ /v1\..*/ -- all fields from measurements that start with 'v1.'
// # SHOW SERIES
// # SHOW SERIES [FROM <measurement_name> [WHERE <tag_key>='<tag_value>']]
// # DROP SERIES FROM /v1.*\.end/
// # SHOW TAG KEYS
// # SHOW TAG KEYS FROM "v1.cos"
// # SHOW FIELD KEYS
// # SHOW FIELD KEYS FROM /v1\..*\.sin/ -- all fields from series that start with 'v1.' and end with '.sin'

/*
# influx
docker run --name influx -p 8086:8086 -p 8089:8089/udp -p 8088:8088 -v C:\Docker\Volumes\influxdb\db:/var/lib/influxdb -v C:\Docker\Volumes\influxdb\config\influxdb.conf:/etc/influxdb/influxdb.conf:ro influxdb -config /etc/influxdb/influxdb.conf
docker run -d -p 8083:8083 -p 8086:8086 -p 8089:4444/udp --expose 8083 --expose 8086 --expose 4444 -e UDP_DB="playground" tutum/influxdb

*/
namespace Sample
{
public static class Program
{
public static void Main(string[] args)
{
Collect().Wait();

Console.ReadKey();
}

async static Task Collect()
{
var process = Process.GetCurrentProcess();

Metrics.Collector = new CollectorConfiguration()
.Tag.With("host", Environment.GetEnvironmentVariable("COMPUTERNAME"))
.Tag.With("os", Environment.GetEnvironmentVariable("OS"))
.Tag.With("process", Path.GetFileName(process.MainModule.FileName))
.Batch.AtInterval(TimeSpan.FromSeconds(2))
//.WriteTo.InfluxDB("http://localhost:8086", "data")
.WriteTo.InfluxDB("udp://localhost:8089", "data")
.CreateCollector();

while (true)
{
Metrics.Increment("iterations");

Metrics.Write("cpu_time",
new Dictionary<string, object>
{
{ "value", process.TotalProcessorTime.TotalMilliseconds },
{ "user", process.UserProcessorTime.TotalMilliseconds }
});

Metrics.Measure("working_set", process.WorkingSet64);

await Task.Delay(1000);
}
}
}
}
36 changes: 36 additions & 0 deletions sample/Sample-UDP-Support/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Sample-UDP-Support")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Sample-UDP-Support")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("62a1a1e7-ccf5-49d9-b462-f11eef7f5591")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
63 changes: 63 additions & 0 deletions sample/Sample-UDP-Support/Sample-UDP-Support.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{62A1A1E7-CCF5-49D9-B462-F11EEF7F5591}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Sample_UDP_Support</RootNamespace>
<AssemblyName>Sample-UDP-Support</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\InfluxDB.Collector\InfluxDB.Collector.csproj">
<Project>{f690f3e3-d9f0-441a-9e70-4f70998bdd1b}</Project>
<Name>InfluxDB.Collector</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\InfluxDB.LineProtocol\InfluxDB.LineProtocol.csproj">
<Project>{069e0ac5-a2cf-4584-89a7-f475276e244c}</Project>
<Name>InfluxDB.LineProtocol</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
4 changes: 4 additions & 0 deletions sample/Sample-UDP-Support/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Threading" version="4.3.0" targetFramework="net461" />
</packages>
2 changes: 1 addition & 1 deletion sample/Sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net452;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
<AssemblyName>Sample</AssemblyName>
<PackageId>Sample</PackageId>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ class PipelinedCollectorEmitConfiguration : CollectorEmitConfiguration
{
readonly CollectorConfiguration _configuration;
readonly List<Action<PointData[]>> _emitters = new List<Action<PointData[]>>();
LineProtocolClient _client;
private ILineProtocolClient _client;

public PipelinedCollectorEmitConfiguration(CollectorConfiguration configuration)
public PipelinedCollectorEmitConfiguration(
CollectorConfiguration configuration)
{
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
_configuration = configuration;
}

public override CollectorConfiguration InfluxDB(Uri serverBaseAddress, string database, string username = null, string password = null)
{
_client = new LineProtocolClient(serverBaseAddress, database, username, password);
if (string.Compare(serverBaseAddress.Scheme, "udp", ignoreCase: true) == 0)
_client = new LineProtocolUdpClient(serverBaseAddress, database, username, password);
else
_client = new LineProtocolClient(serverBaseAddress, database, username, password);
return _configuration;
}

Expand Down
25 changes: 9 additions & 16 deletions src/InfluxDB.Collector/InfluxDB.Collector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>A minimal metrics collection API for InfluxDB</Description>
<Authors>influxdb-csharp Contributors</Authors>
<TargetFrameworks>net45;netstandard1.3</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a move to drop the old targets is probably worthwhile, given the additional maintenance/test burden of multi-targeting. We'd need to mark this as breaking, however, and rev the package to 2.0.

<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>InfluxDB.Collector</AssemblyName>
<VersionPrefix>1.1.1</VersionPrefix>
Expand All @@ -17,22 +17,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Net.Sockets" Version="4.3.0" />
<ProjectReference Include="..\InfluxDB.LineProtocol\InfluxDB.LineProtocol.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.Collections" Version="4.0.11" />
<PackageReference Include="System.Linq" Version="4.1.0" />
<PackageReference Include="System.Threading" Version="4.0.11" />
<PackageReference Include="System.Runtime" Version="4.1.0" />
<PackageReference Include="System.Net.Http" Version="4.1.1" />
<PackageReference Include="System.Console" Version="4.0.0" />
<PackageReference Include="System.Runtime.Extensions" Version="4.1.0" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Linq" Version="4.3.0" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.3" />
<PackageReference Include="System.Console" Version="4.3.0" />
<PackageReference Include="System.Runtime.Extensions" Version="4.3.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace InfluxDB.Collector.Pipeline.Emit
{
class HttpLineProtocolEmitter : IDisposable, IPointEmitter
{
readonly LineProtocolClient _client;
readonly ILineProtocolClient _client;

public HttpLineProtocolEmitter(LineProtocolClient client)
public HttpLineProtocolEmitter(ILineProtocolClient client)
{
if (client == null) throw new ArgumentNullException(nameof(client));
_client = client;
Expand Down
16 changes: 16 additions & 0 deletions src/InfluxDB.LineProtocol/Client/ILineProtocolClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Threading;
using System.Threading.Tasks;
using InfluxDB.LineProtocol.Payload;

namespace InfluxDB.LineProtocol.Client
{
public interface ILineProtocolClient
{
Task<LineProtocolWriteResult> SendAsync(
LineProtocolWriter lineProtocolWriter,
CancellationToken cancellationToken = default(CancellationToken));
Task<LineProtocolWriteResult> WriteAsync(
LineProtocolPayload payload,
CancellationToken cancellationToken = default(CancellationToken));
}
}
Loading