Skip to content

Conversation

@jesuswr
Copy link
Contributor

@jesuswr jesuswr commented Dec 9, 2025

Summary

Resolves #237140

Adds space ID to the execution context for both browser and server environments to improve observability and traceability of operations across different Kibana spaces.

Browser Implementation

  • Modified the spaces plugin to subscribe to the active space observable and append the space ID to the execution context whenever it changes

Server Implementation

  • Added append() method to ExecutionContextSetup API that allows safely appending the space ID to the current execution context without replacing the entire object
  • Use the append() method in the request interceptor that already has the space.

The only thing to consider is that this doesn't work for the task manager tasks since they use withContext directly, so there's no way for us to set the space for them.

const ctx = {
type: 'task manager',
name: `run ${this.instance.task.taskType}`,
id: this.instance.task.id,
description: 'run task',
};
const result = await this.executionContext.withContext(ctx, () =>
withSpan({ name: 'run', type: 'task manager' }, () => this.task!.run())
);

This is how it looks like in the server:
image

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

@jesuswr jesuswr self-assigned this Dec 9, 2025
@jesuswr jesuswr added Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Dec 9, 2025
@jesuswr
Copy link
Contributor Author

jesuswr commented Dec 9, 2025

/ci

@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!

@jesuswr
Copy link
Contributor Author

jesuswr commented Dec 10, 2025

/ci

2 similar comments
@jesuswr
Copy link
Contributor Author

jesuswr commented Dec 10, 2025

/ci

@jesuswr
Copy link
Contributor Author

jesuswr commented Dec 11, 2025

/ci

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #64 / discover Discover CSV Export Generate CSV: sparse data handles field formatting for a field that doesn't exist initially
  • [job] [logs] FTR Configs #61 / Visualizations - Group 2 lens app - Agg based Vis Open in Lens Heatmap should convert to Lens if Y-axis is defined, but X-axis is not

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/core-execution-context-server 8 10 +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
spaces 27.2KB 27.6KB +344.0B
Unknown metric groups

API count

id before after diff
@kbn/core-execution-context-server 9 12 +3

History

cc @jesuswr

@jesuswr jesuswr force-pushed the add-space-id-to-execution-context branch from 591e8de to dedbb9e Compare December 11, 2025 17:06
@jesuswr
Copy link
Contributor Author

jesuswr commented Dec 11, 2025

/ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t//

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core] Execution context should include current space

2 participants