Skip to content

fix: the debug console of a DAP session no longer shows the debug adapter's telemetry output - #2199

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/dap-telemetry-output-not-in-console
Nov 24, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/dap-telemetry-output-not-in-console

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #2197

What

The debug console of a DAP session printed the output events of the category telemetry. DAP's output event says of it: "Send the output to telemetry instead of the client." VS Code doesn't show it either. Some debug adapters send usage data in JSON this way, which then showed up among the program's output.

Change

  • DAPClient.output skips an output event of the category telemetry (new static isTelemetry). It logs the event at DEBUG under DAPClient's logger, for whoever diagnoses a debug adapter.
  • The other categories are printed as before. getContentType loses its now unreachable telemetry case.
  • docs/dap/DAPSupport.md: the Output line says that telemetry isn't shown.

#2198 (output groups) and the coming PR for #2169 (ANSI colours) also change DAPClient.output. Whichever merges later is rebased.

Tests

  • New DAPOutputCategorySessionTest, a HeavyPlatformTestCase with an in-process debug adapter on a loopback socket, built like DAPProcessEventSessionTest. The adapter sends a telemetry, a console and a stdout output event. The console shows the last two, but not the telemetry.
  • Without the fix it fails, since the console shows {"event":"usage"}. With it, it passes, also headless.

Behaviour change

Before After
The debug console shows the debug adapter's telemetry output It doesn't; the output is logged at DEBUG

…pter's telemetry output

DAP's output event says of the category 'telemetry': "Send the output to
telemetry instead of the client". VS Code doesn't show it either. LSP4IJ
printed it in the debug console, as debug output, so usage data in JSON,
which some debug adapters send, showed up among the program's output.

DAPClient.output now skips output events of the category 'telemetry' and
logs them at DEBUG, for whoever diagnoses a debug adapter. The other
categories are printed as before.

Fixes redhat-developer#2197
@lagergren lagergren added this to the 0.30.2 milestone Nov 24, 2026
@lagergren lagergren added the bug Something isn't working label Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Telemetry-category output from debug adapters is now written to debug logs instead of appearing in the debug console. Console and program output continue to appear there.
  • Documentation
    • Clarified how debug adapter output categories are displayed, including where telemetry output is recorded.

The DAP client now logs telemetry-category output at DEBUG instead of displaying it in the debug console. Documentation describes this behavior, and an integration test checks that other output categories remain visible.

Changes: DAP telemetry output handling

Layer / File(s) Summary
Handle telemetry output
src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPClient.java, docs/dap/DAPSupport.md
The client logs telemetry-category output at DEBUG and skips console output. The documentation describes this behavior.
Verify output categories
src/test/java/com/redhat/devtools/lsp4ij/dap/client/DAPOutputCategorySessionTest.java
An integration test uses a mock DAP session to send telemetry, console, and stdout events. It checks that telemetry is absent from the console and adapter and program output are present.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: angelozerr

Merge Risk: Minimal · up to 82497

This change stops DAP telemetry output from appearing in the debug console while other output categories are shown as before. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: the debug console of a DAP session no longer shows the debug adapter's telemetry output. The raw summary confirms DAPClient.output now skips telemetry-category output…
Description check Passed The description is directly related to the changeset. It links issue #2197, explains that DAP telemetry output should not reach the debug console, lists the DAPClient.output and getContentType changes…
Linked Issues check Passed Directly linked issue #2197 requires that output events with category telemetry not reach the debug console, that console output still does, that telemetry may be logged at DEBUG under LSP4IJ's DA…
Out of Scope Changes check Passed The changed files are DAPClient.java (the telemetry skip, its DEBUG log, and removal of the unreachable telemetry case in getContentType), docs/dap/DAPSupport.md (one line stating that telemet…
Full details: Title check

Explanation

The title states the main change: the debug console of a DAP session no longer shows the debug adapter's telemetry output. The raw summary confirms DAPClient.output now skips telemetry-category output events and logs them at DEBUG, matching the title. The title is concise and specific.

Full details: Description check

Explanation

The description is directly related to the changeset. It links issue #2197, explains that DAP telemetry output should not reach the debug console, lists the DAPClient.output and getContentType changes, the docs update, and the new DAPOutputCategorySessionTest. It also includes a before/after behaviour table.

Full details: Linked Issues check

Explanation

Directly linked issue #2197 requires that output events with category telemetry not reach the debug console, that console output still does, that telemetry may be logged at DEBUG under LSP4IJ's DAP category, and that a session test with a fake adapter covers this. The PR summary states that DAPClient.output now skips telemetry events, writes their text to the debug log, and returns before console display. The summary states that getContentType no longer maps telemetry. The test DAPOutputCategorySessionTest.testTheConsoleDoesNotShowTheTelemetryOfTheDAPServer reads as intended: it sends a telemetry, a console, and a stdout output event, then asserts that the console shows the console and stdout lines and does not contain usage. Limit: the repository diff tool returned no text for DAPClient.java, so the DAPClient.output change is established from the supplied PR summary and PR description, not from the source hunk. The test was not executed.

Full details: Out of Scope Changes check

Explanation

The changed files are DAPClient.java (the telemetry skip, its DEBUG log, and removal of the unreachable telemetry case in getContentType), docs/dap/DAPSupport.md (one line stating that telemetry is not shown in the Output line), and the new DAPOutputCategorySessionTest.java. All of them connect directly to #2197. The test's mock DAP server (session server, initialization and inspection stubs) supports the test only. No unrelated change appears in the supplied summaries. The DAPClient.java hunk was not readable, so this verdict relies on the supplied summary for that file.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7a612e70-09ee-4385-b66a-afee1fec7350
Commits

Reviewing files that changed from the base of the PR and between 084bf75 and 82497c1.

Files selected for processing: 3

  • docs/dap/DAPSupport.md
  • src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPClient.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/client/DAPOutputCategorySessionTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 54.23%. Comparing base (084bf75) to head (82497c1).

Files with missing lines Patch % Lines
...m/redhat/devtools/lsp4ij/dap/client/DAPClient.java 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2199      +/-   ##
==========================================
- Coverage   54.23%   54.23%   -0.01%     
==========================================
  Files         832      832              
  Lines       35334    35337       +3     
  Branches     7286     7287       +1     
==========================================
+ Hits        19163    19164       +1     
+ Misses      13348    13341       -7     
- Partials     2823     2832       +9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit 1b49b39 into redhat-developer:main Nov 24, 2026
9 checks passed
lagergren added a commit that referenced this pull request Nov 24, 2026
…p, as console.group() gives (#2198)

Part of #2167: the indentation. Folding a group in the console is left for later.

## What

The DAP `output` event has an optional `group`, which `console.group()` and `console.groupCollapsed()` give, for instance:
- `start` begins a group;
- `startCollapsed` begins a collapsed one;
- `end` ends the current group.

LSP4IJ's debug console printed grouped output flat, with the group headers looking like any other line.

## Change

New package-private `DAPOutputGroups`, one per `DAPClient`, so each session of a `startDebugging` tree has its own groups. `DAPClient.output` prints `outputGroups.indent(args)` instead of the event's text, and nothing else in it changes.
- **Indentation:** each line of a group is indented 2 spaces per nesting level, as Node.js indents `console.group()` in a terminal. VS Code indents its tree in pixels, so it has no space count to copy.
- **`start` and `startCollapsed`:** the event's text is the group's header, on its own line at the current level. Then the level goes up.
- **`end`:** the level goes down, never below 0, and the end's text, if any, is printed at the outer level, as DAP and VS Code do.
- **Line starts:** the indent goes at the start of each line, not each chunk, so a line sent in pieces is indented once. An empty line gets no trailing spaces. A `\r` also counts as a line start, so a progress line that rewrites itself stays indented.
- **Groups on their own lines:** a group starts and ends on its own line. If the output so far stopped mid-line, a newline is added first.
- **Telemetry output never reaches the groups.** Since #2199, `DAPClient.output` drops it first, as VS Code does. `DAPOutputGroups` itself passes it through unchanged.
- **Docs:** the Output line in `docs/dap/DAPSupport.md` (merged with #2199's line about telemetry) describes the indentation, that each session has its own groups, and that folding isn't supported yet, so a `startCollapsed` group shows expanded.

Not in this PR:
- **Folding,** which IntelliJ's console doesn't offer for dynamic ranges.
- **Interleaved partial lines:** child sessions share the root's console, so if two sessions interleave partial lines, an indent can land in the wrong place. Getting that exact would mean indenting under the console's lock in `DAPDebugProcess.printText`.

## Tests

- New `DAPOutputGroupsTest` (JUnit 5, 14 tests):
  - nesting, `startCollapsed`, an `end` below 0, and the text of an `end`;
  - chunked lines, multi-line text with an empty line and CRLF, a multi-line header, and `\r`;
  - a group that starts or ends mid-line, an empty header, and telemetry.
- New `DAPOutputGroupsSessionTest` (2 tests, an in-process debug adapter on a loopback socket):
  - nested groups, chunks and multi-line output in the console's text;
  - a root and a child session started with `startDebugging` don't share their group levels.
- **Red-green:** without the `DAPClient` change, both session tests fail, since the block prints flat. With it, all 16 pass, also headless.
- The `dap.*` tests pass on IC 2024.2, 2025.3 and IU 2026.3: 473 each, with 0 failures or skipped.

## Behaviour change

| Before | After |
|---|---|
| The output of a group prints flat, with its header like any other line | Each line of a group is indented 2 spaces per nesting level. The header is at the level where the group starts, and the text of an `end` at the outer level. Each session has its own groups |
lagergren added a commit that referenced this pull request Nov 24, 2026
…e debug adapter's output, which it now asks for with supportsANSIStyling (#2200)

Fixes #2169

## What

The debug console of a DAP session printed `output` events as they came. ANSI escape sequences, which programs and debug adapters use for colours and bold, showed as raw codes such as `ESC[31mred ESC[0m`. LSP4IJ also didn't send the client capability `supportsANSIStyling` in `initialize`, so an adapter that honours it, such as vscode-js-debug, could leave styles out.

## Change

- **New `DAPOutputDecoder`** (`dap/console`) decodes an `output` event's text with IntelliJ's `AnsiEscapeDecoder`, as a `ColoredProcessHandler` console does. It returns chunks of text without the escape codes, each with its console content type:
  - **Unstyled text** keeps its category's content type, the same mapping as before: stderr red, important verbose, everything else info. The mapping moved here from `DAPClient`.
  - **Styled text** gets the content type that `AnsiEscapeDecoder` and `ColoredOutputTypeRegistry` give it, as in a process console.
  - **One decoder per category:** a missing or unknown category counts as console, as DAP says. stderr is decoded as STDERR and the other categories as STDOUT, since the decoder only handles those two. So a style, or a sequence split across events, continues into the next event of the same category, and doesn't leak into another one.
- **`DAPClient`:** each client has its own decoder, so each session of a `startDebugging` tree has its own. `output` prints the decoded chunks.
- **`DAPDebugProcess.printOutput(List<Chunk>)`** prints an event's chunks together under `consoleLock`, so that no other session's text lands between them. The existing `printOutput(String, ConsoleViewContentType)` is unchanged.
- **`DebugAdapterDescriptor.createInitializeRequestArguments`** sends `supportsANSIStyling: true`.
- **Docs:** the Output line of `docs/dap/DAPSupport.md` names the capability and the behaviour.

#2198 (output groups) and #2199 (telemetry) are merged, and this PR is rebased on them. `DAPOutputGroups`, its `outputGroups.indent(args)` and the telemetry check were already on main at the base. This PR passes the indented text through the decoder: `outputDecoder.decode(outputGroups.indent(args), args.getCategory())`.

Not in this PR:
- A bold-only span on stderr is bold in the default foreground, not bold red, as in a process console.
- If a session ends inside an escape sequence, the leftover is dropped.

## Tests

New `DAPOutputAnsiStylingSessionTest` (6 tests, a `HeavyPlatformTestCase` with an in-process debug adapter on a loopback socket). It reads the console text, and the content type of each character from the document's markup.
- `initialize` carries `supportsANSIStyling: true`.
- `\^[[31mred\^[[0m plain` shows `red plain`, with `red` in the scheme's red and ` plain` as info, and no escape character.
- The colour of a group's output shows where the group indents it (after the rebase on #2198).
- An escape sequence split over two events, whose colour runs into a third, shows `green done` in green.
- On stderr, bold text is bold, and unstyled text stays `LOG_ERROR_OUTPUT`.
- A stdout colour doesn't carry into console output.

Red-green:
- Without the change, the first 5 tests fail: `supportsANSIStyling` is null, and the console shows the raw codes. The group test was added later, with the rebase on #2198. With the change, all 6 pass, also headless.
- With one decoder shared by all categories, only the last test fails, so it guards the one-decoder-per-category rule.

The `dap.*` tests pass on IC 2024.2, 2025.3 and IU 2026.3: 462 each, with 0 failures or skipped. Rebased on main at d8c7551, they pass again, also headless: 518 tests, 0 failures.

## Behaviour change

| Before | After |
|---|---|
| The debug console shows ANSI escape codes as raw text, and `initialize` doesn't send `supportsANSIStyling` | It shows the colours and bold without the codes, keeping the category's colour for unstyled text, and `initialize` sends `supportsANSIStyling: true` |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAP: the debug console prints output events of the category telemetry, which DAP sends to telemetry instead

1 participant