You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CEXT-5395: Automatic Error Status on Root Spans (#47)
* feat: make root span be marked as errored by default according to app builder standard
* test: add tests
* chore: add changeset
* docs: update docs
* refactor: simplify successful condition check
Automatically mark root spans with an error status if they return a response that matches an unsuccessful response shape (according to [App Builder documentation](https://developer.adobe.com/app-builder/docs/guides/runtime_guides/creating-actions#unsuccessful-response))
Copy file name to clipboardExpand all lines: docs/usage.md
+12-3Lines changed: 12 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -481,12 +481,21 @@ Example use cases on when you might want to use these options are:
481
481
- **Customizing Span Names**: If you want to use a custom span name for a function, you can set the [`spanConfig.spanName`](./api-reference/interfaces/InstrumentationConfig.md#spanname) option. There are other span configuration options available, see the API reference for [`SpanConfig`](./api-reference/interfaces/InstrumentationConfig.md#spanconfig) for more details.
482
482
- **Reacting to the Result**: If you want to react to the result of a function, you can set the [`onResult`](./api-reference/interfaces/InstrumentationConfig.md#onresult) option.
483
483
- **Handling Errors**: If you want to handle errors of a function, you can set the [`onError`](./api-reference/interfaces/InstrumentationConfig.md#onerror) option.
484
-
- **Handling Success/Failure**: By default, the library considers a function successful if it doesn't throw an error. You can customize this behavior by setting the [`isSuccessful`](./api-reference/interfaces/InstrumentationConfig.md#issuccessful) option.
485
-
- This option takes a function that receives the result and returns a boolean indicating whether the operation was successful.
486
-
- The success/failure state may not matter for your use case. Internally, it determines when to trigger the [`onError`](./api-reference/interfaces/InstrumentationConfig.md#onerror) and [`onResult`](./api-reference/interfaces/InstrumentationConfig.md#onresult) hooks, and whether to [set the span status](https://opentelemetry.io/docs/concepts/signals/traces/#span-status) to `OK` or `ERROR`. Different observability backends might interpret these statuses in their own way.
484
+
- **Handling Success/Failure**: See the [Span Status](#span-status) section below for more details.
487
485
488
486
See the API reference for the configuration options available: [`InstrumentationConfig`](./api-reference/interfaces/InstrumentationConfig.md).
489
487
488
+
### Span Status
489
+
490
+
By default, the library considers a function successful if it doesn't throw an error. You can customize this behavior using the [`isSuccessful`](./api-reference/interfaces/InstrumentationConfig.md#issuccessful) option.
491
+
492
+
- This option accepts a function that receives the result and returns a boolean indicating whether the operation succeeded.
493
+
- The success/failure state may not be relevant to your use case. Internally, it determines when to trigger the [`onError`](./api-reference/interfaces/InstrumentationConfig.md#onerror) and [`onResult`](./api-reference/interfaces/InstrumentationConfig.md#onresult) hooks, and whether to [set the span status](https://opentelemetry.io/docs/concepts/signals/traces/#span-status) to `OK` or `ERROR`. Note that different observability backends may interpret these statuses differently.
494
+
495
+
#### Runtime Action Success/Failure
496
+
497
+
App Builder determines action failure by looking for an `error` property in the result (see [this section](https://developer.adobe.com/app-builder/docs/guides/runtime_guides/creating-actions#unsuccessful-response) of the App Builder documentation for more details). When using the `instrumentEntrypoint` helper (the one applied to the `main` function), this behavior is replicated to evaluate the success/failure state of the root span. The helper reads the response object and sets the span status accordingly by providing a default implementation for the [`isSuccessful`](./api-reference/interfaces/InstrumentationConfig.md#issuccessful) option that performs this `error` property check. You can override this behavior if needed by setting a custom `isSuccessful` function.
0 commit comments