-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Adds attributes to startSpan #9199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
reta
merged 9 commits into
opensearch-project:main
from
Gaganjuneja:main-telemetry-span-attr
Aug 11, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fce43c8
Adds attributes to startSpan
f58089a
Update Changelog
bc9eec8
Adds attributes to startSpan
d661760
Refactor code
965353f
Add java doc
407079a
Refactor code
707ac18
Refactor code
ea297f7
Refactor code
cc791d1
Removes dependency
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.