This commit is contained in:
Austin Parker 2019-05-14 08:29:56 -07:00 committed by Sergey Kanzhelev
parent 68421615fe
commit f39f11cee1
11 changed files with 37 additions and 37 deletions

View File

@ -62,13 +62,13 @@ namespace OpenTelemetry.Trace
/// </summary>
/// <param name="key">Key of the attribute.</param>
/// <param name="value">Attribute value.</param>
void PutAttribute(string key, IAttributeValue value);
void SetAttribute(string key, IAttributeValue value);
/// <summary>
/// Puts a list of attributes to the span.
/// </summary>
/// <param name="attributes">Collection of attributes name/value pairs.</param>
void PutAttributes(IDictionary<string, IAttributeValue> attributes);
void SetAttributes(IDictionary<string, IAttributeValue> attributes);
/// <summary>
/// Adds a single annotation to the span.

View File

@ -30,7 +30,7 @@ namespace OpenTelemetry.Trace
/// <returns>Span with populated http method properties.</returns>
public static ISpan PutHttpMethodAttribute(this ISpan span, string method)
{
span.PutAttribute(SpanAttributeConstants.HttpMethodKey, AttributeValue.StringAttributeValue(method));
span.SetAttribute(SpanAttributeConstants.HttpMethodKey, AttributeValue.StringAttributeValue(method));
return span;
}
@ -43,7 +43,7 @@ namespace OpenTelemetry.Trace
/// <returns>Span with populated status code properties.</returns>
public static ISpan PutHttpStatusCodeAttribute(this ISpan span, int statusCode)
{
span.PutAttribute(SpanAttributeConstants.HttpStatusCodeKey, AttributeValue.LongAttributeValue(statusCode));
span.SetAttribute(SpanAttributeConstants.HttpStatusCodeKey, AttributeValue.LongAttributeValue(statusCode));
return span;
}
@ -58,7 +58,7 @@ namespace OpenTelemetry.Trace
{
if (!string.IsNullOrWhiteSpace(userAgent))
{
span.PutAttribute(SpanAttributeConstants.HttpUserAgentKey, AttributeValue.StringAttributeValue(userAgent));
span.SetAttribute(SpanAttributeConstants.HttpUserAgentKey, AttributeValue.StringAttributeValue(userAgent));
}
return span;
@ -76,11 +76,11 @@ namespace OpenTelemetry.Trace
{
if (port == 80 || port == 443)
{
span.PutAttribute(SpanAttributeConstants.HttpHostKey, AttributeValue.StringAttributeValue(hostName));
span.SetAttribute(SpanAttributeConstants.HttpHostKey, AttributeValue.StringAttributeValue(hostName));
}
else
{
span.PutAttribute(SpanAttributeConstants.HttpHostKey, AttributeValue.StringAttributeValue(hostName + ":" + port));
span.SetAttribute(SpanAttributeConstants.HttpHostKey, AttributeValue.StringAttributeValue(hostName + ":" + port));
}
return span;
@ -97,7 +97,7 @@ namespace OpenTelemetry.Trace
{
if (!string.IsNullOrEmpty(route))
{
span.PutAttribute(SpanAttributeConstants.HttpRouteKey, AttributeValue.StringAttributeValue(route));
span.SetAttribute(SpanAttributeConstants.HttpRouteKey, AttributeValue.StringAttributeValue(route));
}
return span;
@ -114,7 +114,7 @@ namespace OpenTelemetry.Trace
{
if (!string.IsNullOrEmpty(rawUrl))
{
span.PutAttribute(SpanAttributeConstants.HttpUrlKey, AttributeValue.StringAttributeValue(rawUrl));
span.SetAttribute(SpanAttributeConstants.HttpUrlKey, AttributeValue.StringAttributeValue(rawUrl));
}
return span;
@ -129,7 +129,7 @@ namespace OpenTelemetry.Trace
/// <returns>Span with populated path properties.</returns>
public static ISpan PutHttpPathAttribute(this ISpan span, string path)
{
span.PutAttribute(SpanAttributeConstants.HttpPathKey, AttributeValue.StringAttributeValue(path));
span.SetAttribute(SpanAttributeConstants.HttpPathKey, AttributeValue.StringAttributeValue(path));
return span;
}
@ -142,7 +142,7 @@ namespace OpenTelemetry.Trace
/// <returns>Span with populated response size properties.</returns>
public static ISpan PutHttpResponseSizeAttribute(this ISpan span, long size)
{
span.PutAttribute(SpanAttributeConstants.HttpResponseSizeKey, AttributeValue.LongAttributeValue(size));
span.SetAttribute(SpanAttributeConstants.HttpResponseSizeKey, AttributeValue.LongAttributeValue(size));
return span;
}
@ -155,7 +155,7 @@ namespace OpenTelemetry.Trace
/// <returns>Span with populated request size properties.</returns>
public static ISpan PutHttpRequestSizeAttribute(this ISpan span, long size)
{
span.PutAttribute(SpanAttributeConstants.HttpRequestSizeKey, AttributeValue.LongAttributeValue(size));
span.SetAttribute(SpanAttributeConstants.HttpRequestSizeKey, AttributeValue.LongAttributeValue(size));
return span;
}

View File

@ -50,7 +50,7 @@ namespace OpenTelemetry.Collector.AspNetCore.Common
foreach (var tag in activity.Tags)
{
span.PutAttribute(tag.Key, AttributeValue.StringAttributeValue(tag.Value));
span.SetAttribute(tag.Key, AttributeValue.StringAttributeValue(tag.Value));
}
}

View File

@ -50,7 +50,7 @@ namespace OpenTelemetry.Collector.Dependencies.Common
foreach (var tag in activity.Tags)
{
span.PutAttribute(tag.Key, AttributeValue.StringAttributeValue(tag.Value));
span.SetAttribute(tag.Key, AttributeValue.StringAttributeValue(tag.Value));
}
}

View File

@ -70,11 +70,11 @@ namespace OpenTelemetry.Trace.Internal
public override bool HasEnded => true;
public override void PutAttributes(IDictionary<string, IAttributeValue> attributes)
public override void SetAttributes(IDictionary<string, IAttributeValue> attributes)
{
}
public override void PutAttribute(string key, IAttributeValue value)
public override void SetAttribute(string key, IAttributeValue value)
{
}

View File

@ -245,7 +245,7 @@ namespace OpenTelemetry.Trace
}
}
public override void PutAttribute(string key, IAttributeValue value)
public override void SetAttribute(string key, IAttributeValue value)
{
if (!this.Options.HasFlag(SpanOptions.RecordEvents))
{
@ -264,7 +264,7 @@ namespace OpenTelemetry.Trace
}
}
public override void PutAttributes(IDictionary<string, IAttributeValue> attributes)
public override void SetAttributes(IDictionary<string, IAttributeValue> attributes)
{
if (!this.Options.HasFlag(SpanOptions.RecordEvents))
{

View File

@ -99,13 +99,13 @@ namespace OpenTelemetry.Trace
public abstract bool HasEnded { get; }
/// <inheritdoc/>
public virtual void PutAttribute(string key, IAttributeValue value)
public virtual void SetAttribute(string key, IAttributeValue value)
{
this.PutAttributes(new Dictionary<string, IAttributeValue>() { { key, value } });
this.SetAttributes(new Dictionary<string, IAttributeValue>() { { key, value } });
}
/// <inheritdoc/>
public abstract void PutAttributes(IDictionary<string, IAttributeValue> attributes);
public abstract void SetAttributes(IDictionary<string, IAttributeValue> attributes);
/// <inheritdoc/>
public void AddAnnotation(string description)

View File

@ -42,10 +42,10 @@ namespace OpenTelemetry.Trace.Test
multipleAttributes.Add("MyLongAttributeKey", AttributeValue<long>.Create(123));
multipleAttributes.Add("MyDoubleAttributeKey", AttributeValue<double>.Create(0.005));
// Tests only that all the methods are not crashing/throwing errors.
BlankSpan.Instance.PutAttribute(
BlankSpan.Instance.SetAttribute(
"MyStringAttributeKey2", AttributeValue<string>.Create("MyStringAttributeValue2"));
BlankSpan.Instance.PutAttributes(attributes);
BlankSpan.Instance.PutAttributes(multipleAttributes);
BlankSpan.Instance.SetAttributes(attributes);
BlankSpan.Instance.SetAttributes(multipleAttributes);
BlankSpan.Instance.AddAnnotation("MyAnnotation");
BlankSpan.Instance.AddAnnotation("MyAnnotation", attributes);
BlankSpan.Instance.AddAnnotation("MyAnnotation", multipleAttributes);

View File

@ -63,7 +63,7 @@ namespace OpenTelemetry.Trace.Test
{
}
public override void PutAttributes(IDictionary<string, IAttributeValue> attributes)
public override void SetAttributes(IDictionary<string, IAttributeValue> attributes)
{
}

View File

@ -73,9 +73,9 @@ namespace OpenTelemetry.Trace.Test
var mockSpan = new Mock<NoopSpan>(spanContext, spanOptions) { CallBase = true };
NoopSpan span = mockSpan.Object;
IAttributeValue val = AttributeValue<bool>.Create(true);
span.PutAttribute("MyKey", val);
span.SetAttribute("MyKey", val);
span.End();
mockSpan.Verify((s) => s.PutAttributes(It.Is<IDictionary<string, IAttributeValue>>((d) => d.ContainsKey("MyKey"))));
mockSpan.Verify((s) => s.SetAttributes(It.Is<IDictionary<string, IAttributeValue>>((d) => d.ContainsKey("MyKey"))));
}

View File

@ -74,7 +74,7 @@ namespace OpenTelemetry.Trace.Test
startEndHandler,
timestampConverter);
// Check that adding trace events after Span#End() does not throw any exception.
span.PutAttributes(attributes);
span.SetAttributes(attributes);
span.AddAnnotation(Annotation.FromDescription(ANNOTATION_DESCRIPTION));
span.AddAnnotation(ANNOTATION_DESCRIPTION, attributes);
span.AddMessageEvent(
@ -101,8 +101,8 @@ namespace OpenTelemetry.Trace.Test
span.End();
// Check that adding trace events after Span#End() does not throw any exception and are not
// recorded.
span.PutAttributes(attributes);
span.PutAttribute(
span.SetAttributes(attributes);
span.SetAttribute(
"MySingleStringAttributeKey",
AttributeValue.StringAttributeValue("MySingleStringAttributeValue"));
span.AddAnnotation(Annotation.FromDescription(ANNOTATION_DESCRIPTION));
@ -134,10 +134,10 @@ namespace OpenTelemetry.Trace.Test
startEndHandler,
timestampConverter);
span.PutAttribute(
span.SetAttribute(
"MySingleStringAttributeKey",
AttributeValue.StringAttributeValue("MySingleStringAttributeValue"));
span.PutAttributes(attributes);
span.SetAttributes(attributes);
interval = TimeSpan.FromMilliseconds(100);
span.AddAnnotation(Annotation.FromDescription(ANNOTATION_DESCRIPTION));
interval = TimeSpan.FromMilliseconds(200);
@ -192,10 +192,10 @@ namespace OpenTelemetry.Trace.Test
startEndHandler,
timestampConverter);
span.PutAttribute(
span.SetAttribute(
"MySingleStringAttributeKey",
AttributeValue.StringAttributeValue("MySingleStringAttributeValue"));
span.PutAttributes(attributes);
span.SetAttributes(attributes);
interval = TimeSpan.FromMilliseconds(100);
span.AddAnnotation(Annotation.FromDescription(ANNOTATION_DESCRIPTION));
interval = TimeSpan.FromMilliseconds(200);
@ -309,7 +309,7 @@ namespace OpenTelemetry.Trace.Test
{
IDictionary<String, IAttributeValue> attributes = new Dictionary<String, IAttributeValue>();
attributes.Add("MyStringAttributeKey" + i, AttributeValue.LongAttributeValue(i));
span.PutAttributes(attributes);
span.SetAttributes(attributes);
}
ISpanData spanData = ((Span)span).ToSpanData();
Assert.Equal(maxNumberOfAttributes, spanData.Attributes.DroppedAttributesCount);
@ -356,7 +356,7 @@ namespace OpenTelemetry.Trace.Test
{
IDictionary<String, IAttributeValue> attributes = new Dictionary<String, IAttributeValue>();
attributes.Add("MyStringAttributeKey" + i, AttributeValue.LongAttributeValue(i));
span.PutAttributes(attributes);
span.SetAttributes(attributes);
}
ISpanData spanData = ((Span)span).ToSpanData();
Assert.Equal(maxNumberOfAttributes, spanData.Attributes.DroppedAttributesCount);
@ -373,7 +373,7 @@ namespace OpenTelemetry.Trace.Test
{
IDictionary<String, IAttributeValue> attributes = new Dictionary<String, IAttributeValue>();
attributes.Add("MyStringAttributeKey" + i, AttributeValue.LongAttributeValue(i));
span.PutAttributes(attributes);
span.SetAttributes(attributes);
}
spanData = ((Span)span).ToSpanData();
Assert.Equal(maxNumberOfAttributes * 3 / 2, spanData.Attributes.DroppedAttributesCount);