Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,8 @@
<Name>Datadog.Tracer</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
21 changes: 16 additions & 5 deletions src/Datadog.Tracer/AgentWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Datadog.Tracer.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -7,6 +8,8 @@ namespace Datadog.Tracer
{
internal class AgentWriter : IAgentWriter
{
private static ILog _log = LogProvider.For<AgentWriter>();

private readonly AgentWriterBuffer<List<Span>> _tracesBuffer = new AgentWriterBuffer<List<Span>>(1000);
private readonly AgentWriterBuffer<ServiceInfo> _servicesBuffer = new AgentWriterBuffer<ServiceInfo>(100);
private readonly IApi _api;
Expand All @@ -20,12 +23,20 @@ public AgentWriter(IApi api)

public void WriteServiceInfo(ServiceInfo serviceInfo)
{
_servicesBuffer.Push(serviceInfo);
var success = _servicesBuffer.Push(serviceInfo);
if (!success)
{
_log.Debug("ServiceInfo buffer is full, dropping it.");
}
}

public void WriteTrace(List<Span> trace)
{
_tracesBuffer.Push(trace);
var success = _tracesBuffer.Push(trace);
if (!success)
{
_log.Debug("Trace buffer is full, dropping it.");
}
}

public async Task FlushTracesTaskLoop()
Expand All @@ -48,9 +59,9 @@ public async Task FlushTracesTaskLoop()
await Task.WhenAll(services.Select(_api.SendServiceAsync));
}
}
catch
catch(Exception ex)
{
// TODO: log errors
_log.ErrorException("An unhandled error occurred during the flushing task", ex);
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/Datadog.Tracer/Api.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MsgPack.Serialization;
using Datadog.Tracer.Logging;
using MsgPack.Serialization;
using System;
using System.Collections.Generic;
using System.Net.Http;
Expand All @@ -10,6 +11,8 @@ namespace Datadog.Tracer
{
internal class Api : IApi
{
private static ILog _log = LogProvider.For<Api>();

private const string TracesPath = "/v0.3/traces";
private const string ServicesPath = "/v0.3/services";
private static SerializationContext _serializationContext;
Expand Down Expand Up @@ -61,9 +64,9 @@ private async Task SendAsync<T>(T value, Uri endpoint)
var response = await _client.PostAsync(endpoint, content);
response.EnsureSuccessStatusCode();
}
catch
catch(Exception ex)
{
// TODO:bertrand log
_log.ErrorException("An error occured while sending traces to the agent at {Endpoint}", ex, endpoint);
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/Datadog.Tracer/Datadog.Tracer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,18 @@
<PackageReference Include="Opentracing" Version="0.10.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>LIBLOG_PORTABLE</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.CSharp" Version="4.0.1" />
<PackageReference Include="System.Dynamic.Runtime" Version="4.0.11" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

</Project>
Loading