Skip to content

Commit

Permalink
WIP remove thrift code
Browse files Browse the repository at this point in the history
  • Loading branch information
EGHornbostel committed Jul 10, 2019
1 parent ba897aa commit bbbcf47
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/Thrift/Transports/Server/TServerFramedTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected override async Task<TClientTransport> AcceptImplementationAsync(Cancel
{
if (cancellationToken.IsCancellationRequested)
{
return await Task.FromCanceled<TClientTransport>(cancellationToken);
return await Task.FromCanceled<TClientTransport>(cancellationToken).ConfigureAwait(false);
}

if (_server == null)
Expand Down Expand Up @@ -147,4 +147,4 @@ public override void Close()
}
}
}
}
}
157 changes: 154 additions & 3 deletions src/OpenTelemetry.Exporter.Jaeger/Implimentation/JaegerSpan.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="JaegerSpan.cs" company="OpenTelemetry Authors">
// <copyright file="JaegerSpan.cs" company="OpenTelemetry Authors">
// Copyright 2018, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,9 +20,13 @@ namespace OpenTelemetry.Exporter.Jaeger.Implimentation
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks;
#if NET46
using Thrift.Protocol;
#else
using Thrift.Protocols;
using Thrift.Protocols.Entities;
#endif

public class JaegerSpan : TAbstractBase
{
Expand Down Expand Up @@ -65,6 +69,152 @@ public JaegerSpan(long traceIdLow, long traceIdHigh, long spanId, long parentSpa

public List<JaegerLog> Logs { get; set; }

#if NET46
public void Write(TProtocol oprot)
{
oprot.IncrementRecursionDepth();
try
{
var struc = new TStruct("Span");
oprot.WriteStructBegin(struc);

var field = new TField
{
Name = "traceIdLow",
Type = TType.I64,
ID = 1,
};

oprot.WriteFieldBegin(field);
oprot.WriteI64(this.TraceIdLow);
oprot.WriteFieldEnd();

field.Name = "traceIdHigh";
field.Type = TType.I64;
field.ID = 2;

oprot.WriteFieldBegin(field);
oprot.WriteI64(this.TraceIdHigh);
oprot.WriteFieldEnd();

field.Name = "spanId";
field.Type = TType.I64;
field.ID = 3;

oprot.WriteFieldBegin(field);
oprot.WriteI64(this.SpanId);
oprot.WriteFieldEnd();

field.Name = "parentSpanId";
field.Type = TType.I64;
field.ID = 4;

oprot.WriteFieldBegin(field);
oprot.WriteI64(this.ParentSpanId);
oprot.WriteFieldEnd();

field.Name = "operationName";
field.Type = TType.String;
field.ID = 5;

oprot.WriteFieldBegin(field);
oprot.WriteString(this.OperationName);
oprot.WriteFieldEnd();

if (this.References != null)
{
field.Name = "references";
field.Type = TType.List;
field.ID = 6;
oprot.WriteFieldBegin(field);
{
oprot.WriteListBegin(new TList(TType.Struct, this.References.Count));

foreach (JaegerSpanRef sr in this.References)
{
sr.Write(oprot);
}

oprot.WriteListEnd();
}

oprot.WriteFieldEnd();
}

field.Name = "flags";
field.Type = TType.I32;
field.ID = 7;

oprot.WriteFieldBegin(field);
oprot.WriteI32(this.Flags);
oprot.WriteFieldEnd();

field.Name = "startTime";
field.Type = TType.I64;
field.ID = 8;

oprot.WriteFieldBegin(field);
oprot.WriteI64(this.StartTime);
oprot.WriteFieldEnd();

field.Name = "duration";
field.Type = TType.I64;
field.ID = 9;

oprot.WriteFieldBegin(field);
oprot.WriteI64(this.Duration);
oprot.WriteFieldEnd();

if (this.JaegerTags != null)
{
field.Name = "JaegerTags";
field.Type = TType.List;
field.ID = 10;

oprot.WriteFieldBegin(field);
{
oprot.WriteListBegin(new TList(TType.Struct, this.JaegerTags.Count));

foreach (JaegerTag jt in this.JaegerTags)
{
await jt.Write(oprot);
}

oprot.WriteListEnd();
}

oprot.WriteFieldEnd();
}

if (this.Logs != null)
{
field.Name = "logs";
field.Type = TType.List;
field.ID = 11;
oprot.WriteFieldBegin(field);
{
oprot.WriteListBegin(new TList(TType.Struct, this.Logs.Count));

foreach (JaegerLog jl in this.Logs)
{
await jl.Write(oprot);
}

oprot.WriteListEnd();
}

oprot.WriteFieldEnd();
}

oprot.WriteFieldStop();
oprot.WriteStructEnd();
}
finally
{
oprot.DecrementRecursionDepth();
}
}
#else
public async Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
{
oprot.IncrementRecursionDepth();
Expand Down Expand Up @@ -209,6 +359,7 @@ public async Task WriteAsync(TProtocol oprot, CancellationToken cancellationToke
oprot.DecrementRecursionDepth();
}
}
#endif

public override string ToString()
{
Expand Down Expand Up @@ -249,6 +400,6 @@ public override string ToString()

sb.Append(")");
return sb.ToString();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
<PackageTags>Tracing;OpenTelemetry;Management;Monitoring;Jaeger;distributed-tracing</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ApacheThrift" Version="0.12.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OpenTelemetry.Abstractions\OpenTelemetry.Abstractions.csproj" />
<ProjectReference Include="..\..\lib\Thrift\Thrift.csproj" />
</ItemGroup>
</Project>

0 comments on commit bbbcf47

Please sign in to comment.