Skip to content

Commit

Permalink
Rename Span.putAttribute*() to Span.setAttribute*() (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosalberto authored and tedsuo committed Apr 4, 2019
1 parent 5620380 commit 9daa388
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions api/src/main/java/openconsensus/trace/BlankSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public final class BlankSpan extends Span {
private BlankSpan() {}

@Override
public void putAttribute(String key, AttributeValue value) {
public void setAttribute(String key, AttributeValue value) {
Utils.checkNotNull(key, "key");
Utils.checkNotNull(value, "value");
}

@Override
public void putAttributes(Map<String, AttributeValue> attributes) {
public void setAttributes(Map<String, AttributeValue> attributes) {
Utils.checkNotNull(attributes, "attributes");
}

Expand Down
8 changes: 4 additions & 4 deletions api/src/main/java/openconsensus/trace/Span.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ public abstract class Span {
* @param value the value for this attribute.
* @since 0.1.0
*/
public abstract void putAttribute(String key, AttributeValue value);
public abstract void setAttribute(String key, AttributeValue value);

/**
* Sets a set of attributes to the {@code Span}. The effect of this call is equivalent to that of
* calling {@link #putAttribute(String, AttributeValue)} once for each element in the specified
* calling {@link #setAttribute(String, AttributeValue)} once for each element in the specified
* map.
*
* @param attributes the attributes that will be added and associated with the {@code Span}.
* @since 0.1.0
*/
public abstract void putAttributes(Map<String, AttributeValue> attributes);
public abstract void setAttributes(Map<String, AttributeValue> attributes);

/**
* Adds an event to the {@code Span}.
Expand All @@ -66,7 +66,7 @@ public abstract class Span {
*
* @param name the name of the event.
* @param attributes the attributes that will be added; these are associated with this event, not
* the {@code Span} as for {@link #putAttributes(Map)}.
* the {@code Span} as for {@link #setAttributes(Map)}.
* @since 0.1.0
*/
public abstract void addEvent(String name, Map<String, AttributeValue> attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ public SpanContext context() {

@Override
public Span setTag(String key, String value) {
span.putAttribute(key, AttributeValue.stringAttributeValue(value));
span.setAttribute(key, AttributeValue.stringAttributeValue(value));
return this;
}

@Override
public Span setTag(String key, boolean value) {
span.putAttribute(key, AttributeValue.booleanAttributeValue(value));
span.setAttribute(key, AttributeValue.booleanAttributeValue(value));
return this;
}

@Override
public Span setTag(String key, Number value) {
// TODO - Verify only the 'basic' types are supported/used.
if (value instanceof Integer || value instanceof Long) {
span.putAttribute(key, AttributeValue.longAttributeValue(value.longValue()));
span.setAttribute(key, AttributeValue.longAttributeValue(value.longValue()));
} else if (value instanceof Float || value instanceof Double) {
span.putAttribute(key, AttributeValue.doubleAttributeValue(value.doubleValue()));
span.setAttribute(key, AttributeValue.doubleAttributeValue(value.doubleValue()));
} else {
throw new IllegalArgumentException("Number type not supported");
}
Expand Down

0 comments on commit 9daa388

Please sign in to comment.