Enable FxCop - part 03 (#1016)
removing tag code review - 1 undoing to Count == 0 updating files adding IEquatable Adding tests updating version and adding tests updating net test version rollback version update adding more tests removing extra line updating files Adding more tests reverting change based on benchmark updating gethashcode updating files sampling results tests Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
parent
7f2e672dfa
commit
499933ea81
|
|
@ -64,6 +64,8 @@ dotnet_naming_symbols.constant_fields.required_modifiers = const
|
|||
# C# Coding Conventions #
|
||||
###############################
|
||||
[*.cs]
|
||||
dotnet_diagnostic.CA1031.severity = none
|
||||
dotnet_diagnostic.CA1303.severity = none
|
||||
# var preferences
|
||||
csharp_style_var_for_built_in_types = true:silent
|
||||
csharp_style_var_when_type_is_apparent = true:silent
|
||||
|
|
|
|||
|
|
@ -336,3 +336,6 @@ ASALocalRun/
|
|||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# SonarQube folder
|
||||
/.sonarqube
|
||||
|
|
|
|||
|
|
@ -47,6 +47,20 @@ namespace OpenTelemetry.Context
|
|||
/// </summary>
|
||||
public IEnumerable<CorrelationContextEntry> Entries => this.entries;
|
||||
|
||||
/// <summary>
|
||||
/// Compare two entries of <see cref="CorrelationContext"/> for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">First Entry to compare.</param>
|
||||
/// <param name="right">Second Entry to compare.</param>
|
||||
public static bool operator ==(CorrelationContext left, CorrelationContext right) => left.Equals(right);
|
||||
|
||||
/// <summary>
|
||||
/// Compare two entries of <see cref="CorrelationContext"/> for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">First Entry to compare.</param>
|
||||
/// <param name="right">Second Entry to compare.</param>
|
||||
public static bool operator !=(CorrelationContext left, CorrelationContext right) => !(left == right);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CorrelationContextEntry"/> with the specified name.
|
||||
/// </summary>
|
||||
|
|
@ -72,5 +86,17 @@ namespace OpenTelemetry.Context
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is CorrelationContext context && this.Equals(context);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.entries.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace OpenTelemetry.Context
|
|||
/// <summary>
|
||||
/// Distributed Context entry with the key, value and metadata.
|
||||
/// </summary>
|
||||
public readonly struct CorrelationContextEntry
|
||||
public readonly struct CorrelationContextEntry : System.IEquatable<CorrelationContextEntry>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CorrelationContextEntry"/> struct with the key and value.
|
||||
|
|
@ -94,26 +94,20 @@ namespace OpenTelemetry.Context
|
|||
public static bool operator !=(CorrelationContextEntry entry1, CorrelationContextEntry entry2) => !entry1.Equals(entry2);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object o)
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return o is CorrelationContextEntry that && this.Key == that.Key && this.Value == that.Value;
|
||||
return obj is CorrelationContextEntry that && this.Key == that.Key && this.Value == that.Value;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Key is null ? "{}" : $"{nameof(CorrelationContextEntry)}{{{nameof(this.Key)}={this.Key}, {nameof(this.Value)}={this.Value}}}";
|
||||
return $"{nameof(CorrelationContextEntry)}{{{nameof(this.Key)}={this.Key}, {nameof(this.Value)}={this.Value}}}";
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
if (this.Key is null)
|
||||
{
|
||||
// Default instance
|
||||
return 0;
|
||||
}
|
||||
|
||||
var h = 1;
|
||||
h *= 1000003;
|
||||
h ^= this.Key.GetHashCode();
|
||||
|
|
@ -121,5 +115,11 @@ namespace OpenTelemetry.Context
|
|||
h ^= this.Value.GetHashCode();
|
||||
return h;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(CorrelationContextEntry that)
|
||||
{
|
||||
return this.Key == that.Key && this.Value == that.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,26 @@ namespace OpenTelemetry.Context
|
|||
/// </summary>
|
||||
public CorrelationContext CorrelationContext => this.correlationContext;
|
||||
|
||||
/// <summary>
|
||||
/// Compare two entries of <see cref="DistributedContext"/> for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">First Entry to compare.</param>
|
||||
/// <param name="right">Second Entry to compare.</param>
|
||||
public static bool operator ==(DistributedContext left, DistributedContext right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare two entries of <see cref="DistributedContext"/> for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">First Entry to compare.</param>
|
||||
/// <param name="right">Second Entry to compare.</param>
|
||||
public static bool operator !=(DistributedContext left, DistributedContext right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the current <see cref="DistributedContext"/>.
|
||||
/// </summary>
|
||||
|
|
@ -81,5 +101,17 @@ namespace OpenTelemetry.Context
|
|||
{
|
||||
return this.CorrelationContext.Equals(other.CorrelationContext);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is DistributedContext context && this.Equals(context);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.correlationContext.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@ namespace OpenTelemetry.Context
|
|||
public static EmptyDisposable Instance { get; } = new EmptyDisposable();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace OpenTelemetry.Context.Propagation
|
|||
/// <returns>whether the context is a valid one or not.</returns>
|
||||
public static bool IsValid(this ActivityContext ctx)
|
||||
{
|
||||
return !(ctx == default);
|
||||
return ctx != default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,13 +233,10 @@ namespace OpenTelemetry.Context.Propagation
|
|||
return false;
|
||||
}
|
||||
|
||||
if (vendorLength > 0)
|
||||
if (vendorLength > 0 && i > 242)
|
||||
{
|
||||
if (i > 242)
|
||||
{
|
||||
// tenant section should be less than 241 characters long
|
||||
return false;
|
||||
}
|
||||
// tenant section should be less than 241 characters long
|
||||
return false;
|
||||
}
|
||||
|
||||
for (; i < key.Length; i++)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace OpenTelemetry.Context
|
|||
/// <summary>
|
||||
/// Generic runtime context management API.
|
||||
/// </summary>
|
||||
public sealed class RuntimeContext
|
||||
public static class RuntimeContext
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, object> Slots = new ConcurrentDictionary<string, object>();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,19 +14,21 @@
|
|||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenTelemetry.Context
|
||||
{
|
||||
/// <summary>
|
||||
/// The abstract context slot.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the underlying value.</typeparam>
|
||||
public abstract class RuntimeContextSlot<T>
|
||||
public abstract class RuntimeContextSlot<T> : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RuntimeContextSlot{T}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the context slot.</param>
|
||||
public RuntimeContextSlot(string name)
|
||||
protected RuntimeContextSlot(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
|
|
@ -47,5 +49,20 @@ namespace OpenTelemetry.Context
|
|||
/// </summary>
|
||||
/// <param name="value">The value to be set.</param>
|
||||
public abstract void Set(T value);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases the unmanaged resources used by this class and optionally releases the managed resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ namespace OpenTelemetry.Context
|
|||
public class ThreadLocalRuntimeContextSlot<T> : RuntimeContextSlot<T>
|
||||
{
|
||||
private readonly ThreadLocal<T> slot;
|
||||
private bool disposedValue;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ThreadLocalRuntimeContextSlot{T}"/> class.
|
||||
|
|
@ -50,5 +51,19 @@ namespace OpenTelemetry.Context
|
|||
{
|
||||
this.slot.Value = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!this.disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
this.slot.Dispose();
|
||||
}
|
||||
|
||||
this.disposedValue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace OpenTelemetry.Trace
|
|||
/// <summary>
|
||||
/// Link associated with the span.
|
||||
/// </summary>
|
||||
public readonly struct Link
|
||||
public readonly struct Link : System.IEquatable<Link>
|
||||
{
|
||||
internal readonly ActivityLink ActivityLink;
|
||||
|
||||
|
|
@ -92,5 +92,11 @@ namespace OpenTelemetry.Trace
|
|||
{
|
||||
return this.ActivityLink.GetHashCode();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Link other)
|
||||
{
|
||||
return this.ActivityLink.Equals(other.ActivityLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace OpenTelemetry.Trace
|
|||
/// child <see cref="TelemetrySpan"/> and across process boundaries. It contains the identifiers <see cref="ActivityTraceId"/>
|
||||
/// and <see cref="ActivitySpanId"/> associated with the <see cref="TelemetrySpan"/> and a set of <see cref="TraceFlags"/>.
|
||||
/// </summary>
|
||||
public readonly struct SpanContext
|
||||
public readonly struct SpanContext : System.IEquatable<SpanContext>
|
||||
{
|
||||
internal readonly ActivityContext ActivityContext;
|
||||
|
||||
|
|
@ -152,6 +152,12 @@ namespace OpenTelemetry.Trace
|
|||
return (obj is SpanContext ctx) && this.ActivityContext.Equals(ctx.ActivityContext);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(SpanContext ctx)
|
||||
{
|
||||
return this.ActivityContext.Equals(ctx.ActivityContext);
|
||||
}
|
||||
|
||||
private bool IsTraceIdValid(ActivityTraceId traceId)
|
||||
{
|
||||
return traceId != default;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ namespace OpenTelemetry.Trace
|
|||
public static class SpanHelper
|
||||
{
|
||||
private static readonly Status DefaultStatus = default;
|
||||
|
||||
private static readonly Dictionary<StatusCanonicalCode, string> StatusCanonicalCodeToStringCache = new Dictionary<StatusCanonicalCode, string>()
|
||||
{
|
||||
[StatusCanonicalCode.Ok] = StatusCanonicalCode.Ok.ToString(),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace OpenTelemetry.Trace
|
|||
/// <summary>
|
||||
/// Span execution status.
|
||||
/// </summary>
|
||||
public readonly struct Status
|
||||
public readonly struct Status : System.IEquatable<Status>
|
||||
{
|
||||
/// <summary>
|
||||
/// The operation completed successfully.
|
||||
|
|
@ -216,7 +216,7 @@ namespace OpenTelemetry.Trace
|
|||
{
|
||||
var result = 1;
|
||||
result = (31 * result) + this.CanonicalCode.GetHashCode();
|
||||
result = (31 * result) + this.Description.GetHashCode();
|
||||
result = (31 * result) + (this.Description?.GetHashCode() ?? 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -229,5 +229,11 @@ namespace OpenTelemetry.Trace
|
|||
+ nameof(this.Description) + "=" + this.Description
|
||||
+ "}";
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Status that)
|
||||
{
|
||||
return this.IsValid == that.IsValid && this.CanonicalCode == that.CanonicalCode && this.Description == that.Description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
{
|
||||
var struc = new TStruct("Batch");
|
||||
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken);
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var field = new TField
|
||||
{
|
||||
|
|
@ -64,32 +64,32 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
ID = 1,
|
||||
};
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.Transport.WriteAsync(processMessage, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.Transport.WriteAsync(processMessage, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "spans";
|
||||
field.Type = TType.List;
|
||||
field.ID = 2;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
{
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, spanMessages?.Count ?? 0), cancellationToken);
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, spanMessages?.Count ?? 0), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (spanMessages != null)
|
||||
{
|
||||
foreach (var s in spanMessages)
|
||||
{
|
||||
await oprot.Transport.WriteAsync(s.BufferWriter.Buffer, s.Offset, s.Count, cancellationToken);
|
||||
await oprot.Transport.WriteAsync(s.BufferWriter.Buffer, s.Offset, s.Count, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
await oprot.WriteListEndAsync(cancellationToken);
|
||||
await oprot.WriteListEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldStopAsync(cancellationToken);
|
||||
await oprot.WriteStructEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldStopAsync(cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteStructEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
{
|
||||
public static async Task WriteAsync(int seqId, byte[] processMessage, List<BufferWriterMemory> spanMessages, TProtocol oprot, CancellationToken cancellationToken)
|
||||
{
|
||||
await oprot.WriteMessageBeginAsync(new TMessage("emitBatch", TMessageType.Oneway, seqId), cancellationToken);
|
||||
await oprot.WriteMessageBeginAsync(new TMessage("emitBatch", TMessageType.Oneway, seqId), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
oprot.IncrementRecursionDepth();
|
||||
try
|
||||
{
|
||||
var struc = new TStruct("emitBatch_args");
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken);
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var field = new TField
|
||||
{
|
||||
|
|
@ -40,20 +40,20 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
ID = 1,
|
||||
};
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await Batch.WriteAsync(processMessage, spanMessages, oprot, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await Batch.WriteAsync(processMessage, spanMessages, oprot, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
await oprot.WriteFieldStopAsync(cancellationToken);
|
||||
await oprot.WriteStructEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldStopAsync(cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteStructEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
oprot.DecrementRecursionDepth();
|
||||
}
|
||||
|
||||
await oprot.WriteMessageEndAsync(cancellationToken);
|
||||
await oprot.Transport.FlushAsync(cancellationToken);
|
||||
await oprot.WriteMessageEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
await oprot.Transport.FlushAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
try
|
||||
{
|
||||
var struc = new TStruct("Log");
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken);
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var field = new TField
|
||||
{
|
||||
|
|
@ -49,29 +49,29 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
ID = 1,
|
||||
};
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI64Async(this.Timestamp, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI64Async(this.Timestamp, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "fields";
|
||||
field.Type = TType.List;
|
||||
field.ID = 2;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
{
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, this.Fields.Count), cancellationToken);
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, this.Fields.Count), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
for (int i = 0; i < this.Fields.Count; i++)
|
||||
{
|
||||
await this.Fields[i].WriteAsync(oprot, cancellationToken);
|
||||
await this.Fields[i].WriteAsync(oprot, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteListEndAsync(cancellationToken);
|
||||
await oprot.WriteListEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldStopAsync(cancellationToken);
|
||||
await oprot.WriteStructEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldStopAsync(cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteStructEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
try
|
||||
{
|
||||
var struc = new TStruct("Span");
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken);
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var field = new TField
|
||||
{
|
||||
|
|
@ -91,85 +91,85 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
ID = 1,
|
||||
};
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI64Async(this.TraceIdLow, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI64Async(this.TraceIdLow, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "traceIdHigh";
|
||||
field.Type = TType.I64;
|
||||
field.ID = 2;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI64Async(this.TraceIdHigh, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI64Async(this.TraceIdHigh, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "spanId";
|
||||
field.Type = TType.I64;
|
||||
field.ID = 3;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI64Async(this.SpanId, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI64Async(this.SpanId, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "parentSpanId";
|
||||
field.Type = TType.I64;
|
||||
field.ID = 4;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI64Async(this.ParentSpanId, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI64Async(this.ParentSpanId, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "operationName";
|
||||
field.Type = TType.String;
|
||||
field.ID = 5;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteStringAsync(this.OperationName, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteStringAsync(this.OperationName, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!this.References.IsEmpty)
|
||||
{
|
||||
field.Name = "references";
|
||||
field.Type = TType.List;
|
||||
field.ID = 6;
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
{
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, this.References.Count), cancellationToken);
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, this.References.Count), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
for (int i = 0; i < this.References.Count; i++)
|
||||
{
|
||||
await this.References[i].WriteAsync(oprot, cancellationToken);
|
||||
await this.References[i].WriteAsync(oprot, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteListEndAsync(cancellationToken);
|
||||
await oprot.WriteListEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
field.Name = "flags";
|
||||
field.Type = TType.I32;
|
||||
field.ID = 7;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI32Async(this.Flags, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI32Async(this.Flags, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "startTime";
|
||||
field.Type = TType.I64;
|
||||
field.ID = 8;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI64Async(this.StartTime, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI64Async(this.StartTime, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "duration";
|
||||
field.Type = TType.I64;
|
||||
field.ID = 9;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI64Async(this.Duration, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI64Async(this.Duration, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!this.Tags.IsEmpty)
|
||||
{
|
||||
|
|
@ -177,19 +177,19 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
field.Type = TType.List;
|
||||
field.ID = 10;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
{
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, this.Tags.Count), cancellationToken);
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, this.Tags.Count), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
for (int i = 0; i < this.Tags.Count; i++)
|
||||
{
|
||||
await this.Tags[i].WriteAsync(oprot, cancellationToken);
|
||||
await this.Tags[i].WriteAsync(oprot, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteListEndAsync(cancellationToken);
|
||||
await oprot.WriteListEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (!this.Logs.IsEmpty)
|
||||
|
|
@ -197,23 +197,23 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
field.Name = "logs";
|
||||
field.Type = TType.List;
|
||||
field.ID = 11;
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
{
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, this.Logs.Count), cancellationToken);
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, this.Logs.Count), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
for (int i = 0; i < this.Logs.Count; i++)
|
||||
{
|
||||
await this.Logs[i].WriteAsync(oprot, cancellationToken);
|
||||
await this.Logs[i].WriteAsync(oprot, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteListEndAsync(cancellationToken);
|
||||
await oprot.WriteListEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteFieldStopAsync(cancellationToken);
|
||||
await oprot.WriteStructEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldStopAsync(cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteStructEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
try
|
||||
{
|
||||
var struc = new TStruct("SpanRef");
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken);
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var field = new TField
|
||||
{
|
||||
|
|
@ -54,35 +54,35 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
ID = 1,
|
||||
};
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI32Async((int)this.RefType, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI32Async((int)this.RefType, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "traceIdLow";
|
||||
field.Type = TType.I64;
|
||||
field.ID = 2;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI64Async(this.TraceIdLow, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI64Async(this.TraceIdLow, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "traceIdHigh";
|
||||
field.Type = TType.I64;
|
||||
field.ID = 3;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI64Async(this.TraceIdHigh, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI64Async(this.TraceIdHigh, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "spanId";
|
||||
field.Type = TType.I64;
|
||||
field.ID = 4;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI64Async(this.SpanId, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldStopAsync(cancellationToken);
|
||||
await oprot.WriteStructEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI64Async(this.SpanId, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldStopAsync(cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteStructEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
try
|
||||
{
|
||||
var struc = new TStruct("Tag");
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken);
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var field = new TField
|
||||
{
|
||||
|
|
@ -71,26 +71,26 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
ID = 1,
|
||||
};
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteStringAsync(this.Key, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteStringAsync(this.Key, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
field.Name = "vType";
|
||||
field.Type = TType.I32;
|
||||
field.ID = 2;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI32Async((int)this.VType, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI32Async((int)this.VType, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (this.VStr != null)
|
||||
{
|
||||
field.Name = "vStr";
|
||||
field.Type = TType.String;
|
||||
field.ID = 3;
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteStringAsync(this.VStr, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteStringAsync(this.VStr, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (this.VDouble.HasValue)
|
||||
|
|
@ -98,9 +98,9 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
field.Name = "vDouble";
|
||||
field.Type = TType.Double;
|
||||
field.ID = 4;
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteDoubleAsync(this.VDouble.Value, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteDoubleAsync(this.VDouble.Value, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (this.VBool.HasValue)
|
||||
|
|
@ -108,9 +108,9 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
field.Name = "vBool";
|
||||
field.Type = TType.Bool;
|
||||
field.ID = 5;
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteBoolAsync(this.VBool.Value, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteBoolAsync(this.VBool.Value, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (this.VLong.HasValue)
|
||||
|
|
@ -118,9 +118,9 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
field.Name = "vLong";
|
||||
field.Type = TType.I64;
|
||||
field.ID = 6;
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteI64Async(this.VLong.Value, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteI64Async(this.VLong.Value, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (this.VBinary != null)
|
||||
|
|
@ -128,13 +128,13 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
field.Name = "vBinary";
|
||||
field.Type = TType.String;
|
||||
field.ID = 7;
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteBinaryAsync(this.VBinary, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteBinaryAsync(this.VBinary, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteFieldStopAsync(cancellationToken);
|
||||
await oprot.WriteStructEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldStopAsync(cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteStructEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -134,8 +134,8 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in Dispose(bool disposing).
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected async ValueTask<int> AppendInternalAsync(JaegerSpan jaegerSpan, CancellationToken cancellationToken)
|
||||
|
|
@ -237,6 +237,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
|||
this.maxFlushIntervalTimer.Dispose();
|
||||
this.thriftClient.Dispose();
|
||||
this.clientTransport.Dispose();
|
||||
this.memoryTransport.Dispose();
|
||||
this.memoryProtocol.Dispose();
|
||||
this.flushLock.Dispose();
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace OpenTelemetry.Exporter.Jaeger
|
|||
try
|
||||
{
|
||||
var struc = new TStruct("Process");
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken);
|
||||
await oprot.WriteStructBeginAsync(struc, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var field = new TField
|
||||
{
|
||||
|
|
@ -83,9 +83,9 @@ namespace OpenTelemetry.Exporter.Jaeger
|
|||
ID = 1,
|
||||
};
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteStringAsync(this.ServiceName, cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteStringAsync(this.ServiceName, cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (this.Tags != null)
|
||||
{
|
||||
|
|
@ -93,23 +93,23 @@ namespace OpenTelemetry.Exporter.Jaeger
|
|||
field.Type = TType.List;
|
||||
field.ID = 2;
|
||||
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken);
|
||||
await oprot.WriteFieldBeginAsync(field, cancellationToken).ConfigureAwait(false);
|
||||
{
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, this.Tags.Count), cancellationToken);
|
||||
await oprot.WriteListBeginAsync(new TList(TType.Struct, this.Tags.Count), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
foreach (var jt in this.Tags)
|
||||
{
|
||||
await jt.Value.WriteAsync(oprot, cancellationToken);
|
||||
await jt.Value.WriteAsync(oprot, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteListEndAsync(cancellationToken);
|
||||
await oprot.WriteListEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteFieldEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await oprot.WriteFieldStopAsync(cancellationToken);
|
||||
await oprot.WriteStructEndAsync(cancellationToken);
|
||||
await oprot.WriteFieldStopAsync(cancellationToken).ConfigureAwait(false);
|
||||
await oprot.WriteStructEndAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ namespace OpenTelemetry.Exporter.Prometheus
|
|||
if (this.httpListener != null && this.httpListener.IsListening)
|
||||
{
|
||||
this.Stop();
|
||||
this.httpListener.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ namespace OpenTelemetry.Metrics.Export
|
|||
|
||||
internal async Task ExportAsync(IEnumerable<Metric> metricToExport, CancellationToken cancellationToken)
|
||||
{
|
||||
var exportResult = await this.metricExporter.ExportAsync(metricToExport, cancellationToken);
|
||||
var exportResult = await this.metricExporter.ExportAsync(metricToExport, cancellationToken).ConfigureAwait(false);
|
||||
if (exportResult != MetricExporter.ExportResult.Success)
|
||||
{
|
||||
OpenTelemetrySdkEventSource.Log.MetricExporterErrorResult((int)exportResult);
|
||||
|
|
@ -87,7 +87,7 @@ namespace OpenTelemetry.Metrics.Export
|
|||
try
|
||||
{
|
||||
var metricToExport = this.Collect(sw);
|
||||
await this.ExportAsync(metricToExport, cancellationToken);
|
||||
await this.ExportAsync(metricToExport, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace OpenTelemetry.Trace
|
|||
/// <summary>
|
||||
/// Sampling decision.
|
||||
/// </summary>
|
||||
public readonly struct SamplingResult
|
||||
public readonly struct SamplingResult : System.IEquatable<SamplingResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SamplingResult"/> struct.
|
||||
|
|
@ -104,5 +104,11 @@ namespace OpenTelemetry.Trace
|
|||
result = (31 * result) + this.Attributes.GetHashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(SamplingResult that)
|
||||
{
|
||||
return this.Decision == that.Decision && this.Attributes.SequenceEqual(that.Attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,5 +63,40 @@ namespace OpenTelemetry.Context.Tests
|
|||
Assert.Equal("foo", entry.Key);
|
||||
Assert.Empty(entry.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestEquality()
|
||||
{
|
||||
var entry1 = new CorrelationContextEntry("key", "value1");
|
||||
var entry2 = new CorrelationContextEntry("key", "value1");
|
||||
object entry3 = entry2;
|
||||
var entry4 = new CorrelationContextEntry("key", "value2");
|
||||
|
||||
Assert.True(entry1 == entry2);
|
||||
Assert.True(entry1.Equals(entry2));
|
||||
Assert.True(entry1.Equals(entry3));
|
||||
|
||||
Assert.True(entry1 != entry4);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestToString()
|
||||
{
|
||||
var entry1 = new CorrelationContextEntry("key1", "value1");
|
||||
Assert.Equal("CorrelationContextEntry{Key=key1, Value=value1}", entry1.ToString());
|
||||
|
||||
var entry2 = new CorrelationContextEntry(null, "value1");
|
||||
Assert.Equal("CorrelationContextEntry{Key=, Value=value1}", entry2.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGetHashCode()
|
||||
{
|
||||
var entry1 = new CorrelationContextEntry("key1", "value1");
|
||||
Assert.NotEqual(0, entry1.GetHashCode());
|
||||
|
||||
var entry2 = new CorrelationContextEntry(null, "value1");
|
||||
Assert.NotEqual(0, entry2.GetHashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,18 +111,24 @@ namespace OpenTelemetry.Context.Tests
|
|||
{
|
||||
var dc1 = CorrelationContextBuilder.CreateContext(new List<CorrelationContextEntry>(2) { new CorrelationContextEntry(K1, V1), new CorrelationContextEntry(K2, V2) });
|
||||
var dc2 = CorrelationContextBuilder.CreateContext(new List<CorrelationContextEntry>(2) { new CorrelationContextEntry(K1, V1), new CorrelationContextEntry(K2, V2) });
|
||||
object odc2 = dc2;
|
||||
var dc3 = CorrelationContextBuilder.CreateContext(new List<CorrelationContextEntry>(2) { new CorrelationContextEntry(K2, V2), new CorrelationContextEntry(K1, V1) });
|
||||
var dc4 = CorrelationContextBuilder.CreateContext(new List<CorrelationContextEntry>(2) { new CorrelationContextEntry(K1, V1), new CorrelationContextEntry(K2, V1) });
|
||||
var dc5 = CorrelationContextBuilder.CreateContext(new List<CorrelationContextEntry>(2) { new CorrelationContextEntry(K1, V2), new CorrelationContextEntry(K2, V1) });
|
||||
var dc6 = CorrelationContextBuilder.CreateContext(new List<CorrelationContextEntry>(3) { new CorrelationContextEntry(K1, V2) });
|
||||
|
||||
Assert.True(dc1.Equals(dc2));
|
||||
Assert.True(dc1.Equals(odc2));
|
||||
Assert.True(dc1 == dc2);
|
||||
Assert.True(dc1.Equals(dc3));
|
||||
|
||||
Assert.False(dc1.Equals(dc4));
|
||||
Assert.True(dc1 != dc4);
|
||||
Assert.False(dc2.Equals(dc4));
|
||||
Assert.False(dc3.Equals(dc4));
|
||||
Assert.False(dc5.Equals(dc4));
|
||||
Assert.False(dc4.Equals(dc5));
|
||||
Assert.False(dc5.Equals(dc6));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,9 +59,11 @@ namespace OpenTelemetry.Trace.Tests
|
|||
{
|
||||
var link1 = new Link(this.spanContext);
|
||||
var link2 = new Link(this.spanContext);
|
||||
object link3 = new Link(this.spanContext);
|
||||
|
||||
Assert.Equal(link1, link2);
|
||||
Assert.True(link1 == link2);
|
||||
Assert.True(link1.Equals(link3));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -69,9 +71,11 @@ namespace OpenTelemetry.Trace.Tests
|
|||
{
|
||||
var link1 = new Link(this.spanContext, this.tags);
|
||||
var link2 = new Link(this.spanContext, this.tags);
|
||||
object link3 = new Link(this.spanContext, this.tags);
|
||||
|
||||
Assert.Equal(link1, link2);
|
||||
Assert.True(link1 == link2);
|
||||
Assert.True(link1.Equals(link3));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -96,6 +100,13 @@ namespace OpenTelemetry.Trace.Tests
|
|||
Assert.True(link1 != link2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGetHashCode()
|
||||
{
|
||||
var link1 = new Link(this.spanContext, this.tags);
|
||||
Assert.NotEqual(0, link1.GetHashCode());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Activity.Current = null;
|
||||
|
|
|
|||
|
|
@ -121,6 +121,19 @@ namespace OpenTelemetry.Trace.Tests
|
|||
Assert.True(context1 == context2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality4()
|
||||
{
|
||||
var traceId = ActivityTraceId.CreateRandom();
|
||||
var spanId = ActivitySpanId.CreateRandom();
|
||||
IEnumerable<KeyValuePair<string, string>> tracestate = new List<KeyValuePair<string, string>>();
|
||||
var context1 = new SpanContext(traceId, spanId, ActivityTraceFlags.None, false, tracestate);
|
||||
object context2 = new SpanContext(traceId, spanId, ActivityTraceFlags.None, false, tracestate);
|
||||
|
||||
Assert.Equal(context1, context2);
|
||||
Assert.True(context1.Equals(context2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Not_Equality_DifferentTraceId()
|
||||
{
|
||||
|
|
@ -182,5 +195,16 @@ namespace OpenTelemetry.Trace.Tests
|
|||
Assert.NotEqual(context1, context2);
|
||||
Assert.True(context1 != context2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGetHashCode()
|
||||
{
|
||||
var traceId = ActivityTraceId.CreateRandom();
|
||||
var spanId = ActivitySpanId.CreateRandom();
|
||||
IEnumerable<KeyValuePair<string, string>> tracestate = new List<KeyValuePair<string, string>>();
|
||||
var context1 = new SpanContext(traceId, spanId, ActivityTraceFlags.Recorded, true, tracestate);
|
||||
|
||||
Assert.NotEqual(0, context1.GetHashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,11 @@ namespace OpenTelemetry.Trace.Tests
|
|||
{
|
||||
var status1 = new Status(StatusCanonicalCode.Ok);
|
||||
var status2 = new Status(StatusCanonicalCode.Ok);
|
||||
object status3 = new Status(StatusCanonicalCode.Ok);
|
||||
|
||||
Assert.Equal(status1, status2);
|
||||
Assert.True(status1 == status2);
|
||||
Assert.True(status1.Equals(status3));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -61,9 +63,11 @@ namespace OpenTelemetry.Trace.Tests
|
|||
{
|
||||
var status1 = new Status(StatusCanonicalCode.Ok);
|
||||
var status2 = new Status(StatusCanonicalCode.Unknown);
|
||||
object notStatus = 1;
|
||||
|
||||
Assert.NotEqual(status1, status2);
|
||||
Assert.True(status1 != status2);
|
||||
Assert.False(status1.Equals(notStatus));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -85,5 +89,19 @@ namespace OpenTelemetry.Trace.Tests
|
|||
Assert.NotEqual(status1, status2);
|
||||
Assert.True(status1 != status2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestToString()
|
||||
{
|
||||
var status = new Status(StatusCanonicalCode.Ok);
|
||||
Assert.Equal($"Status{{CanonicalCode={status.CanonicalCode}, Description={status.Description}}}", status.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGetHashCode()
|
||||
{
|
||||
var status = new Status(StatusCanonicalCode.Ok);
|
||||
Assert.NotEqual(0, status.GetHashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue