-
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.
Merge branch 'opensearch-project:main' into segment-download-stats
- Loading branch information
Showing
35 changed files
with
741 additions
and
419 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
70 changes: 70 additions & 0 deletions
70
libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultSpanScope.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,70 @@ | ||
/* | ||
* 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; | ||
|
||
import java.util.function.Consumer; | ||
|
||
/** | ||
* Default implementation of Scope | ||
*/ | ||
public class DefaultSpanScope implements SpanScope { | ||
|
||
private final Span span; | ||
|
||
private final Consumer<Span> onCloseConsumer; | ||
|
||
/** | ||
* Creates Scope instance for the given span | ||
* | ||
* @param span underlying span | ||
* @param onCloseConsumer consumer to execute on scope close | ||
*/ | ||
public DefaultSpanScope(Span span, Consumer<Span> onCloseConsumer) { | ||
this.span = span; | ||
this.onCloseConsumer = onCloseConsumer; | ||
} | ||
|
||
@Override | ||
public void addSpanAttribute(String key, String value) { | ||
span.addAttribute(key, value); | ||
} | ||
|
||
@Override | ||
public void addSpanAttribute(String key, long value) { | ||
span.addAttribute(key, value); | ||
} | ||
|
||
@Override | ||
public void addSpanAttribute(String key, double value) { | ||
span.addAttribute(key, value); | ||
} | ||
|
||
@Override | ||
public void addSpanAttribute(String key, boolean value) { | ||
span.addAttribute(key, value); | ||
} | ||
|
||
@Override | ||
public void addSpanEvent(String event) { | ||
span.addEvent(event); | ||
} | ||
|
||
@Override | ||
public void setError(Exception exception) { | ||
span.setError(exception); | ||
} | ||
|
||
/** | ||
* Executes the runnable to end the scope | ||
*/ | ||
@Override | ||
public void close() { | ||
onCloseConsumer.accept(span); | ||
} | ||
} |
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
26 changes: 0 additions & 26 deletions
26
libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Scope.java
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/ScopeImpl.java
This file was deleted.
Oops, something went wrong.
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
74 changes: 74 additions & 0 deletions
74
libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanScope.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,74 @@ | ||
/* | ||
* 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; | ||
|
||
import org.opensearch.telemetry.tracing.noop.NoopSpanScope; | ||
|
||
/** | ||
* An auto-closeable that represents scope of the span. | ||
* It provides interface for all the span operations. | ||
*/ | ||
public interface SpanScope extends AutoCloseable { | ||
/** | ||
* No-op Scope implementation | ||
*/ | ||
SpanScope NO_OP = new NoopSpanScope(); | ||
|
||
/** | ||
* Adds string attribute to the {@link Span}. | ||
* | ||
* @param key attribute key | ||
* @param value attribute value | ||
*/ | ||
void addSpanAttribute(String key, String value); | ||
|
||
/** | ||
* Adds long attribute to the {@link Span}. | ||
* | ||
* @param key attribute key | ||
* @param value attribute value | ||
*/ | ||
void addSpanAttribute(String key, long value); | ||
|
||
/** | ||
* Adds double attribute to the {@link Span}. | ||
* | ||
* @param key attribute key | ||
* @param value attribute value | ||
*/ | ||
void addSpanAttribute(String key, double value); | ||
|
||
/** | ||
* Adds boolean attribute to the {@link Span}. | ||
* | ||
* @param key attribute key | ||
* @param value attribute value | ||
*/ | ||
void addSpanAttribute(String key, boolean value); | ||
|
||
/** | ||
* Adds an event to the {@link Span}. | ||
* | ||
* @param event event name | ||
*/ | ||
void addSpanEvent(String event); | ||
|
||
/** | ||
* Records error in the span | ||
* | ||
* @param exception exception to be recorded | ||
*/ | ||
void setError(Exception exception); | ||
|
||
/** | ||
* closes the scope | ||
*/ | ||
@Override | ||
void close(); | ||
} |
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.