forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tracing Framework] Add support for SpanKind
Signed-off-by: Gagan Juneja <[email protected]>
- Loading branch information
Gagan Juneja
committed
Sep 19, 2023
1 parent
2a5b124
commit 82c9732
Showing
18 changed files
with
243 additions
and
76 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
28 changes: 28 additions & 0 deletions
28
libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanKind.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,28 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* Type of Span. | ||
*/ | ||
public enum SpanKind { | ||
/** | ||
* Span represents the client side code. | ||
*/ | ||
CLIENT, | ||
/** | ||
* Span represents the server side code. | ||
*/ | ||
SERVER, | ||
|
||
/** | ||
* Span represents the internal calls. This is the default value of a span type. | ||
*/ | ||
INTERNAL; | ||
} |
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
43 changes: 43 additions & 0 deletions
43
.../telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelSpanKindConverter.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,43 @@ | ||
/* | ||
* 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 io.opentelemetry.api.trace.SpanKind; | ||
|
||
/** | ||
* Converts {@link org.opensearch.telemetry.tracing.SpanKind} to OTel {@link SpanKind} | ||
*/ | ||
final class OTelSpanKindConverter { | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
private OTelSpanKindConverter() {} | ||
|
||
/** | ||
* SpanKind converter. | ||
* @param spanKind span kind. | ||
* @return otel attributes. | ||
*/ | ||
static SpanKind convert(org.opensearch.telemetry.tracing.SpanKind spanKind) { | ||
if (spanKind == null) { | ||
return SpanKind.INTERNAL; | ||
} else { | ||
switch (spanKind) { | ||
case CLIENT: | ||
return SpanKind.CLIENT; | ||
case SERVER: | ||
return SpanKind.SERVER; | ||
case INTERNAL: | ||
default: | ||
return SpanKind.INTERNAL; | ||
} | ||
} | ||
} | ||
} |
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.