Adding array of primitives to TelemetrySpan (#999)
* Adding array of primitives to TelemetrySpan * updating tests * removing baggage methods
This commit is contained in:
parent
80edb939e4
commit
da8cd0d5c8
|
|
@ -15,7 +15,6 @@
|
|||
// </copyright>
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
|
@ -149,7 +148,57 @@ namespace OpenTelemetry.Trace
|
|||
return this;
|
||||
}
|
||||
|
||||
// TODO: SetAttribute(string key, array of primitives)
|
||||
/// <summary>
|
||||
/// Sets a new attribute on the span.
|
||||
/// </summary>
|
||||
/// <param name="key">Attribute key.</param>
|
||||
/// <param name="values">Attribute values.</param>
|
||||
/// <returns>The <see cref="TelemetrySpan"/> instance for chaining.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public TelemetrySpan SetAttribute(string key, string[] values)
|
||||
{
|
||||
this.Activity?.SetTag(key, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new attribute on the span.
|
||||
/// </summary>
|
||||
/// <param name="key">Attribute key.</param>
|
||||
/// <param name="values">Attribute values.</param>
|
||||
/// <returns>The <see cref="TelemetrySpan"/> instance for chaining.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public TelemetrySpan SetAttribute(string key, int[] values)
|
||||
{
|
||||
this.Activity?.SetTag(key, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new attribute on the span.
|
||||
/// </summary>
|
||||
/// <param name="key">Attribute key.</param>
|
||||
/// <param name="values">Attribute values.</param>
|
||||
/// <returns>The <see cref="TelemetrySpan"/> instance for chaining.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public TelemetrySpan SetAttribute(string key, bool[] values)
|
||||
{
|
||||
this.Activity?.SetTag(key, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new attribute on the span.
|
||||
/// </summary>
|
||||
/// <param name="key">Attribute key.</param>
|
||||
/// <param name="values">Attribute values.</param>
|
||||
/// <returns>The <see cref="TelemetrySpan"/> instance for chaining.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public TelemetrySpan SetAttribute(string key, double[] values)
|
||||
{
|
||||
this.Activity?.SetTag(key, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a single Event to the <see cref="TelemetrySpan"/>.
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ namespace OpenTelemetry.Shims.OpenTracing
|
|||
}
|
||||
else
|
||||
{
|
||||
this.Span.SetAttribute(key, value.ToString());
|
||||
this.Span.SetAttribute(key, value);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
@ -202,7 +202,7 @@ namespace OpenTelemetry.Shims.OpenTracing
|
|||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
this.Span.SetAttribute(key, value.ToString());
|
||||
this.Span.SetAttribute(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ namespace OpenTelemetry.Shims.OpenTracing
|
|||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
this.Span.SetAttribute(key, value.ToString());
|
||||
this.Span.SetAttribute(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -228,8 +228,8 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
shim.SetTag("foo", true);
|
||||
shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, true);
|
||||
|
||||
Assert.Equal("foo", shim.Span.Activity.Tags.First().Key);
|
||||
Assert.True(bool.Parse(shim.Span.Activity.Tags.First().Value));
|
||||
Assert.Equal("foo", shim.Span.Activity.TagObjects.First().Key);
|
||||
Assert.True((bool)shim.Span.Activity.TagObjects.First().Value);
|
||||
|
||||
// A boolean tag named "error" is a special case that must be checked
|
||||
Assert.Equal(Status.Unknown, shim.Span.Activity.GetStatus());
|
||||
|
|
@ -249,9 +249,9 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
|
||||
shim.SetTag("foo", 1);
|
||||
|
||||
Assert.Single(shim.Span.Activity.Tags);
|
||||
Assert.Equal("foo", shim.Span.Activity.Tags.First().Key);
|
||||
Assert.Equal(1L, int.Parse(shim.Span.Activity.Tags.First().Value));
|
||||
Assert.Single(shim.Span.Activity.TagObjects);
|
||||
Assert.Equal("foo", shim.Span.Activity.TagObjects.First().Key);
|
||||
Assert.Equal(1L, (int)shim.Span.Activity.TagObjects.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -264,9 +264,9 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
|
||||
shim.SetTag("foo", 1D);
|
||||
|
||||
Assert.Single(shim.Span.Activity.Tags);
|
||||
Assert.Equal("foo", shim.Span.Activity.Tags.First().Key);
|
||||
Assert.Equal(1, double.Parse(shim.Span.Activity.Tags.First().Value));
|
||||
Assert.Single(shim.Span.Activity.TagObjects);
|
||||
Assert.Equal("foo", shim.Span.Activity.TagObjects.First().Key);
|
||||
Assert.Equal(1, (double)shim.Span.Activity.TagObjects.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -280,8 +280,8 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
shim.SetTag(new BooleanTag("foo"), true);
|
||||
shim.SetTag(new BooleanTag(global::OpenTracing.Tag.Tags.Error.Key), true);
|
||||
|
||||
Assert.Equal("foo", shim.Span.Activity.Tags.First().Key);
|
||||
Assert.True(bool.Parse(shim.Span.Activity.Tags.First().Value));
|
||||
Assert.Equal("foo", shim.Span.Activity.TagObjects.First().Key);
|
||||
Assert.True((bool)shim.Span.Activity.TagObjects.First().Value);
|
||||
|
||||
// A boolean tag named "error" is a special case that must be checked
|
||||
Assert.Equal(Status.Unknown, shim.Span.Activity.GetStatus());
|
||||
|
|
@ -316,9 +316,9 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
|
||||
shim.SetTag(new IntTag("foo"), 1);
|
||||
|
||||
Assert.Single(shim.Span.Activity.Tags);
|
||||
Assert.Equal("foo", shim.Span.Activity.Tags.First().Key);
|
||||
Assert.Equal(1L, int.Parse(shim.Span.Activity.Tags.First().Value));
|
||||
Assert.Single(shim.Span.Activity.TagObjects);
|
||||
Assert.Equal("foo", shim.Span.Activity.TagObjects.First().Key);
|
||||
Assert.Equal(1L, (int)shim.Span.Activity.TagObjects.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -332,13 +332,13 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
shim.SetTag(new IntOrStringTag("foo"), 1);
|
||||
shim.SetTag(new IntOrStringTag("bar"), "baz");
|
||||
|
||||
Assert.Equal(2, shim.Span.Activity.Tags.Count());
|
||||
Assert.Equal(2, shim.Span.Activity.TagObjects.Count());
|
||||
|
||||
Assert.Equal("foo", shim.Span.Activity.Tags.First().Key);
|
||||
Assert.Equal(1L, int.Parse(shim.Span.Activity.Tags.First().Value));
|
||||
Assert.Equal("foo", shim.Span.Activity.TagObjects.First().Key);
|
||||
Assert.Equal(1L, (int)shim.Span.Activity.TagObjects.First().Value);
|
||||
|
||||
Assert.Equal("bar", shim.Span.Activity.Tags.Last().Key);
|
||||
Assert.Equal("baz", shim.Span.Activity.Tags.Last().Value);
|
||||
Assert.Equal("bar", shim.Span.Activity.TagObjects.Last().Key);
|
||||
Assert.Equal("baz", shim.Span.Activity.TagObjects.Last().Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue