Skip to content

Commit 8917795

Browse files
feat(develop-docs): SDK Debug Mode (#12100)
Add docs for the SDK debug mode. Explain that SDKs can choose the default log level themselves.
1 parent bf4dd88 commit 8917795

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

develop-docs/sdk/expected-features/index.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,31 @@ Backend SDKs (typically used in server applications) should have backpressure ma
7777

7878
See <Link to="/sdk/telemetry/traces/backpressure/">Backpressure Management</Link> for details.
7979

80+
## Debug Mode
81+
82+
Every SDK must implement a debug mode, which is disabled by default. Users can enable it by setting the option `debug` to `true`. If the debug mode is enabled, the SDK prints out useful debugging information for two main purposes:
83+
84+
1. It helps users identify and fix SDK problems, such as misconfigurations or something going wrong with sending data to Sentry.
85+
2. It can help Sentry SDK engineers investigate issues in Sentry SDKs, which can be done while developing or by asking a user to enable the debug mode and share the debug logs.
86+
87+
As the log output can add unnecessary overhead, we advise users to refrain from enabling the debug mode in production. Still, SDKs may log fatal error messages even when the debug mode is disabled. When using debug mode extensively for the second use case, we recommend adding the diagnostic level because users could easily miss error or fatal log messages.
88+
89+
### Diagnostic Level
90+
91+
SDKs may offer an optional diagnostic level, which controls the verbosity of the debug mode. There are five different levels:
92+
93+
- `debug`: The most verbose mode
94+
- `info`: Informational messages
95+
- `warning`: Warning that something might not be right
96+
- `error`: Only SDK internal errors are printed
97+
- `fatal`: Only critical errors are printed
98+
99+
The default level can be **debug** or **error** depending on the SDK's usage of log messages. When the volume of log message is low, the default can be debug. When it is high, users might easily miss errors or fatal messages. In that case, the SDK should set the default level to **error**. This choice must be clearly documented in the user-facing docs.
100+
101+
### Auto Debug Mode
102+
103+
So users can easily spot errors during development, the SDK can automatically enable debug mode when it reliably detects it's running in a debug build. When doing so, the SDK must communicate this in the docs and with a log message when initializing the SDK. When the user explicitly sets the `debug` option to `false`, the SDK must disable the debug mode.
104+
80105
## In-App frames
81106

82107
Stack parsing can tell which frames should be identified as part of the user’s application (as opposed to part of the language, a library, or a framework), either automatically or by user configuration at startup, often declared as a package/module prefix.

0 commit comments

Comments
 (0)