Skip to content

Commit

Permalink
Add javadoc notes to encourage using the lower-overhead attribute opt…
Browse files Browse the repository at this point in the history
…ions.
  • Loading branch information
jwatson committed Sep 14, 2020
1 parent 5cb599a commit 35c1b9b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
24 changes: 24 additions & 0 deletions api/src/main/java/io/opentelemetry/common/Attributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ public <T> Builder setAttribute(AttributeKey<T> key, T value) {
/**
* Sets a String attribute into this.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @return this Builder
*/
public Builder setAttribute(String key, String value) {
Expand All @@ -236,6 +239,9 @@ public Builder setAttribute(String key, String value) {
/**
* Sets a long attribute into this.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @return this Builder
*/
public Builder setAttribute(String key, long value) {
Expand All @@ -245,6 +251,9 @@ public Builder setAttribute(String key, long value) {
/**
* Sets a double attribute into this.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @return this Builder
*/
public Builder setAttribute(String key, double value) {
Expand All @@ -254,6 +263,9 @@ public Builder setAttribute(String key, double value) {
/**
* Sets a boolean attribute into this.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @return this Builder
*/
public Builder setAttribute(String key, boolean value) {
Expand All @@ -263,6 +275,9 @@ public Builder setAttribute(String key, boolean value) {
/**
* Sets a String array attribute into this.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @return this Builder
*/
public Builder setAttribute(String key, String... value) {
Expand All @@ -272,6 +287,9 @@ public Builder setAttribute(String key, String... value) {
/**
* Sets a Long array attribute into this.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @return this Builder
*/
public Builder setAttribute(String key, Long... value) {
Expand All @@ -281,6 +299,9 @@ public Builder setAttribute(String key, Long... value) {
/**
* Sets a Double array attribute into this.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @return this Builder
*/
public Builder setAttribute(String key, Double... value) {
Expand All @@ -290,6 +311,9 @@ public Builder setAttribute(String key, Double... value) {
/**
* Sets a Boolean array attribute into this.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @return this Builder
*/
public Builder setAttribute(String key, Boolean... value) {
Expand Down
24 changes: 24 additions & 0 deletions api/src/main/java/io/opentelemetry/trace/Span.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ enum Kind {
* <p>If a null or empty String {@code value} is passed in, the attribute will be silently
* dropped. Note: this behavior could change in the future.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @param key the key for this attribute.
* @param value the value for this attribute.
* @since 0.1.0
Expand All @@ -98,6 +101,9 @@ enum Kind {
* Sets an attribute to the {@code Span}. If the {@code Span} previously contained a mapping for
* the key, the old value is replaced by the specified value.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @param key the key for this attribute.
* @param value the value for this attribute.
* @since 0.1.0
Expand All @@ -108,6 +114,9 @@ enum Kind {
* Sets an attribute to the {@code Span}. If the {@code Span} previously contained a mapping for
* the key, the old value is replaced by the specified value.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @param key the key for this attribute.
* @param value the value for this attribute.
* @since 0.1.0
Expand All @@ -118,6 +127,9 @@ enum Kind {
* Sets an attribute to the {@code Span}. If the {@code Span} previously contained a mapping for
* the key, the old value is replaced by the specified value.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @param key the key for this attribute.
* @param value the value for this attribute.
* @since 0.1.0
Expand Down Expand Up @@ -501,6 +513,9 @@ interface Builder {
* <p>If a null or empty String {@code value} is passed in, the attribute will be silently
* dropped. Note: this behavior could change in the future.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @param key the key for this attribute.
* @param value the value for this attribute.
* @return this.
Expand All @@ -513,6 +528,9 @@ interface Builder {
* Sets an attribute to the newly created {@code Span}. If {@code Span.Builder} previously
* contained a mapping for the key, the old value is replaced by the specified value.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @param key the key for this attribute.
* @param value the value for this attribute.
* @return this.
Expand All @@ -525,6 +543,9 @@ interface Builder {
* Sets an attribute to the newly created {@code Span}. If {@code Span.Builder} previously
* contained a mapping for the key, the old value is replaced by the specified value.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @param key the key for this attribute.
* @param value the value for this attribute.
* @return this.
Expand All @@ -537,6 +558,9 @@ interface Builder {
* Sets an attribute to the newly created {@code Span}. If {@code Span.Builder} previously
* contained a mapping for the key, the old value is replaced by the specified value.
*
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
* pre-allocate your keys, if possible.
*
* @param key the key for this attribute.
* @param value the value for this attribute.
* @return this.
Expand Down

0 comments on commit 35c1b9b

Please sign in to comment.