Skip to content

Commit 5a17595

Browse files
Add information for connector o11y (#75)
## Description 📝 Adds information for connector o11y by breaking the page into debugging + error-handling sections. Additionally, we split the debugging section into local development steps and those for cloud-deployed connectors. ## Quick Links 🚀 [Debug & Handle Errors with Lambda Connectors](https://robdominguez-doc-2689-add-in.promptql-docs.pages.dev/business-logic/errors/) --------- Co-authored-by: Sean Park-Ross <[email protected]>
1 parent 83ff88c commit 5a17595

File tree

1 file changed

+66
-15
lines changed

1 file changed

+66
-15
lines changed

docs/business-logic/errors.mdx

+66-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
sidebar_position: 6
3-
sidebar_label: Handle errors
3+
sidebar_label: Debug & handle errors
44
description:
55
"Learn how to handle errors effectively to improve PromptQL's understanding and accuracy when interacting with your
66
custom business logic."
@@ -14,29 +14,69 @@ keywords:
1414
import Tabs from "@theme/Tabs";
1515
import TabItem from "@theme/TabItem";
1616

17-
# Handle Errors with Lambda Connectors
17+
# Debug and Handle Errors with Lambda Connectors
1818

1919
## Introduction
2020

21-
By default, lambda connectors return a generic `internal error` message whenever an exception is encountered in your
22-
custom business logic and **log the details of the error in the OpenTelemetry trace associated with the request**.
21+
When developing with lambda connectors, understanding what went wrong — and why — is just as important as handling the
22+
error itself. By default for security reasons, lambda connectors return a generic `internal error` message when exceptions occur, while the
23+
full details are logged in the [OpenTelemetry trace](#access-opentelemetry-traces) for that request.
2324

24-
The Native Data Connector specification identifies a
25-
[valid set of status codes](https://hasura.github.io/ndc-spec/specification/error-handling.html) which can be used to
26-
improve PromptQL's understanding of errors when they occur.
25+
This page covers strategies for both **debugging issues** during development and **handling errors** effectively in
26+
deployed connectors. You'll learn how to inspect traces, return custom error messages, and use supported error classes
27+
to improve PromptQL's understanding and self-corrective capabilities.
2728

28-
:::info How detailed should error messages be?
29+
For a full list of supported status codes, refer to the
30+
[Native Data Connector error specification](https://hasura.github.io/ndc-spec/specification/error-handling.html).
2931

30-
Exposing stack traces to end users is generally discouraged. Instead, administrators can review traces logged in the
31-
OpenTelemetry traces to access detailed stack trace information.
32+
## Debugging
3233

33-
That said, the more clarity provided in an error message, the better PromptQL can self-correct and improve its
34-
understanding of the function. Clear, descriptive error messages allow PromptQL to learn from errors and provide more
35-
accurate interactions with your data over time.
34+
### Local development
35+
36+
As your connector is running inside a Docker container, any logs (i.e., `console.log()`, `print()`, or `fmt.Println()`)
37+
from your custom business logic will be visible in the container's logs.
38+
39+
These logs are printed to your terminal when running the default `ddn run docker-start` command, can be viewed by
40+
running `docker logs <lambda_container_name>`, or via Docker Desktop.
41+
42+
:::info Enable watch mode
43+
44+
We recommend enabling Compose Watch on your lambda connectors to create a shorter feedback loop during development. See
45+
the guide [here](/business-logic/dev-mode.mdx).
3646

3747
:::
3848

39-
## Return custom error messages
49+
### Deployed connectors
50+
51+
For deployed connectors, you can use the DDN CLI to locate the connector's build ID and then output the logs to your
52+
terminal.
53+
54+
#### Step 1. List all builds for a connector
55+
56+
Start by entering a project directory.
57+
58+
```ddn title="For example, to get the list of builds for a connector named my_ts:"
59+
ddn connector build get --connector-name my_ts
60+
```
61+
62+
```plaintext title="Which will return a list of all builds for my_ts:"
63+
+---------------------+----------+--------------------------------------+---------------+------------------------------------------------------------------------------+------------------------------------------------------------------------------+----------------+-----------------------+
64+
| CREATION TIME | SUBGRAPH | CONNECTORBUILD ID | CONNECTOR | READ URL | WRITE URL | STATUS | HUBCONNECTOR |
65+
+---------------------+----------+--------------------------------------+---------------+------------------------------------------------------------------------------+------------------------------------------------------------------------------+----------------+-----------------------+
66+
| 13 Apr 25 19:07 PDT | app | b336c2f5-de3a-4d11-9f88-52578f3d8d92 | my_ts | https://service-b336c2f5-de3a-4d11-9f88-52578f3d8d92-<project-id>.a.run.app | https://service-b336c2f5-de3a-4d11-9f88-52578f3d8d92-<project-id>.a.run.app | deploy_success | hasura/nodejs:v1.13.0 |
67+
+---------------------+----------+--------------------------------------+---------------+------------------------------------------------------------------------------+------------------------------------------------------------------------------+----------------+-----------------------+
68+
```
69+
70+
#### Step 2. Fetch the logs for a build
71+
72+
```ddn title="Then, use the CONNECTORBUILD ID to fetch the logs:"
73+
ddn connector build logs b336c2f5-de3a-4d11-9f88-52578f3d8d92
74+
```
75+
76+
The [`ddn connector build logs` command](/reference/cli/commands/ddn_connector_build_logs.mdx) supports tailing logs
77+
along with other customizations.
78+
79+
## Returning custom error messages
4080

4181
Lambda connectors allow you to throw classes of errors with your own custom message and metadata to indicate specific
4282
error conditions. These classes are designed to provide clarity in error handling when PromptQL interacts with your data
@@ -138,7 +178,18 @@ func FunctionHello(ctx context.Context, state *types.State, arguments *HelloArgu
138178

139179
</Tabs>
140180

141-
## Access OpenTelemetry traces
181+
:::info How detailed should error messages be?
182+
183+
Exposing stack traces to end users is generally discouraged. Instead, administrators can review traces logged in the
184+
OpenTelemetry traces to access detailed stack trace information.
185+
186+
That said, the more clarity provided in an error message, the better PromptQL can self-correct and improve its
187+
understanding of the function. Clear, descriptive error messages allow PromptQL to learn from errors and provide more
188+
accurate interactions with your data over time.
189+
190+
:::
191+
192+
### Access OpenTelemetry traces {#access-opentelemetry-traces}
142193

143194
Traces — complete with your custom error messages — are available for each request. You can find these in the `Insights`
144195
tab of your project's console. These traces help you understand how PromptQL is interacting with your data and where

0 commit comments

Comments
 (0)