-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Adds attributes to startSpan * Update Changelog * Adds attributes to startSpan * Refactor code * Add java doc * Refactor code * Refactor code * Refactor code * Removes dependency --------- Signed-off-by: Gagan Juneja <gjjuneja@amazon.com> Co-authored-by: Gagan Juneja <gjjuneja@amazon.com>
- Loading branch information
1 parent
156118a
commit a3cfccc
Showing
19 changed files
with
439 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/Attributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.telemetry.tracing.attributes; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Class to create attributes for a span. | ||
*/ | ||
public class Attributes { | ||
private final Map<String, Object> attributesMap; | ||
/** | ||
* Empty value. | ||
*/ | ||
public final static Attributes EMPTY = new Attributes(Collections.emptyMap()); | ||
|
||
/** | ||
* Factory method. | ||
* @return attributes. | ||
*/ | ||
public static Attributes create() { | ||
return new Attributes(new HashMap<>()); | ||
} | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
private Attributes(Map<String, Object> attributesMap) { | ||
this.attributesMap = attributesMap; | ||
} | ||
|
||
/** | ||
* Add String attribute. | ||
* @param key key | ||
* @param value value | ||
* @return Same instance. | ||
*/ | ||
public Attributes addAttribute(String key, String value) { | ||
Objects.requireNonNull(value, "value cannot be null"); | ||
attributesMap.put(key, value); | ||
return this; | ||
} | ||
|
||
/** | ||
* Add long attribute. | ||
* @param key key | ||
* @param value value | ||
* @return Same instance. | ||
*/ | ||
public Attributes addAttribute(String key, long value) { | ||
attributesMap.put(key, value); | ||
return this; | ||
}; | ||
|
||
/** | ||
* Add double attribute. | ||
* @param key key | ||
* @param value value | ||
* @return Same instance. | ||
*/ | ||
public Attributes addAttribute(String key, double value) { | ||
attributesMap.put(key, value); | ||
return this; | ||
}; | ||
|
||
/** | ||
* Add boolean attribute. | ||
* @param key key | ||
* @param value value | ||
* @return Same instance. | ||
*/ | ||
public Attributes addAttribute(String key, boolean value) { | ||
attributesMap.put(key, value); | ||
return this; | ||
}; | ||
|
||
/** | ||
* Returns the attribute map. | ||
* @return attributes map | ||
*/ | ||
public Map<String, ?> getAttributesMap() { | ||
return Collections.unmodifiableMap(attributesMap); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
/** | ||
* Contains No-op implementations | ||
*/ | ||
package org.opensearch.telemetry.tracing.attributes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.