Skip to content

Commit a31ae4a

Browse files
Update finishSpanWithError API
1 parent 05011ae commit a31ae4a

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

ballerina/natives.bal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public isolated function finishSpan(int spanId) returns error? = @java:Method {
7777
# + spanId - Id of span to finish
7878
# + errorMessage - Error message to be recorded in the span
7979
# + return - An error if an error occurred while finishing the span
80-
public isolated function finishSpanWithError(int spanId, string errorMessage) returns error? = @java:Method {
80+
public isolated function finishSpanWithError(int spanId, error 'error) returns error? = @java:Method {
8181
'class: "io.ballerina.stdlib.observe.nativeimpl.FinishSpan",
8282
name: "finishSpanWithError"
8383
} external;

native/src/main/java/io/ballerina/stdlib/observe/nativeimpl/FinishSpan.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import io.ballerina.runtime.api.Environment;
2323
import io.ballerina.runtime.api.creators.ErrorCreator;
2424
import io.ballerina.runtime.api.utils.StringUtils;
25-
import io.ballerina.runtime.api.values.BString;
25+
import io.ballerina.runtime.api.values.BError;
2626

2727
/**
2828
* This function which implements the finishSpan method for observe.
@@ -42,9 +42,9 @@ public static Object finishSpan(Environment env, long spanId) {
4242
"already finished")));
4343
}
4444

45-
public static Object finishSpanWithError(Environment env, long spanId, BString errorMessage) {
45+
public static Object finishSpanWithError(Environment env, long spanId, BError error) {
4646
boolean isFinished = OpenTracerBallerinaWrapper.getInstance().finishSpanWithError(env, spanId,
47-
errorMessage.getValue());
47+
error);
4848

4949
if (isFinished) {
5050
return null;

native/src/main/java/io/ballerina/stdlib/observe/nativeimpl/OpenTracerBallerinaWrapper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.ballerina.runtime.api.Environment;
2323
import io.ballerina.runtime.api.creators.ErrorCreator;
2424
import io.ballerina.runtime.api.utils.StringUtils;
25+
import io.ballerina.runtime.api.values.BError;
2526
import io.ballerina.runtime.observability.ObserveUtils;
2627
import io.ballerina.runtime.observability.ObserverContext;
2728
import io.ballerina.runtime.observability.tracer.BSpan;
@@ -175,15 +176,15 @@ public boolean finishSpan(Environment env, long spanId) {
175176
* @param spanId id of the Span
176177
* @return boolean to indicate if span was finished
177178
*/
178-
public boolean finishSpanWithError(Environment env, long spanId, String errorValue) {
179+
public boolean finishSpanWithError(Environment env, long spanId, BError error) {
179180

180181
if (!enabled) {
181182
return false;
182183
}
183184
ObserverContext observerContext = observerContextMap.get(spanId);
184185
if (observerContext != null) {
185186
observerContext.addTag(TAG_KEY_ERROR, TAG_TRUE_VALUE);
186-
observerContext.addProperty(PROPERTY_ERROR_VALUE, errorValue);
187+
observerContext.addProperty(PROPERTY_ERROR_VALUE, error);
187188
if (observerContext.isSystemSpan()) {
188189
ObserveUtils.setObserverContextToCurrentFrame(env, observerContext.getParent());
189190
}

0 commit comments

Comments
 (0)