Skip to content

Conversation

@bisgaard-itis
Copy link
Contributor

@bisgaard-itis bisgaard-itis commented Jun 3, 2025

What do these changes do?

  • Propagate the trace id corresponding to a request to outside the platform in the api-server and webserver via a x-osparc-trace-id header. I have investigated online at it seems there is no standardized approach to propagating this info to the outside world within opentelemetry (see links in Add osparc trace id in response headers outside the platform #7795). In some AWS services they have a X-Amzn-Trace-Id and I have copied that approach.
  • With the trace id at hand one can directly find the logs emitted by the platform while handling a request or look at the trace in tempo/jaeger.
    Here's what this looks like in the api-server
    image

And here's what it looks like in the frontend (webserver)

image

🚨 @matusdrobuliak66 don't worry, I will not merge this until after the release.

Related issue/s

How to test

Dev-ops

@codecov
Copy link

codecov bot commented Jun 3, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 7 lines in your changes missing coverage. Please review.

Project coverage is 87.86%. Comparing base (ddc3e74) to head (b002ff7).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7796      +/-   ##
==========================================
- Coverage   87.97%   87.86%   -0.11%     
==========================================
  Files        1844     1428     -416     
  Lines       70996    59256   -11740     
  Branches     1213      618     -595     
==========================================
- Hits        62460    52068   -10392     
+ Misses       8193     6983    -1210     
+ Partials      343      205     -138     
Flag Coverage Δ
integrationtests 64.23% <ø> (-0.12%) ⬇️
unittests 86.18% <85.71%> (-0.37%) ⬇️
Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration ∅ <ø> (∅)
pkg_service_library 72.40% <87.50%> (+0.08%) ⬆️
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 85.05% <ø> (ø)
agent 96.29% <ø> (ø)
api_server 91.76% <0.00%> (ø)
autoscaling 96.03% <ø> (ø)
catalog 92.29% <ø> (ø)
clusters_keeper 99.13% <ø> (ø)
dask_sidecar 91.79% <ø> (ø)
datcore_adapter 97.94% <ø> (ø)
director 76.73% <ø> (ø)
director_v2 91.07% <ø> (-0.13%) ⬇️
dynamic_scheduler 96.69% <ø> (ø)
dynamic_sidecar 90.09% <ø> (ø)
efs_guardian 89.65% <ø> (ø)
invitations 93.00% <ø> (ø)
payments 92.57% <ø> (ø)
resource_usage_tracker 89.09% <ø> (ø)
storage 87.53% <ø> (ø)
webclient ∅ <ø> (∅)
webserver 87.62% <ø> (-0.03%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddc3e74...b002ff7. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bisgaard-itis bisgaard-itis self-assigned this Jun 3, 2025
@bisgaard-itis bisgaard-itis added this to the Bazinga! milestone Jun 3, 2025
@bisgaard-itis bisgaard-itis marked this pull request as ready for review June 3, 2025 13:17
@bisgaard-itis bisgaard-itis changed the title ✨ Add osparc-trace-id to response headers to requests hitting webserver and api-server ✨ Add x-osparc-trace-id to response headers to requests hitting webserver and api-server Jun 3, 2025
@bisgaard-itis bisgaard-itis changed the title ✨ Add x-osparc-trace-id to response headers to requests hitting webserver and api-server ✨ Add x-osparc-trace-id to response headers for requests hitting webserver and api-server Jun 3, 2025
@bisgaard-itis bisgaard-itis requested a review from wvangeit June 3, 2025 14:03
@bisgaard-itis
Copy link
Contributor Author

bisgaard-itis commented Jun 3, 2025

@odeimaiz, @mguidon and @wvangeit I request a review from you guys mainly to notify you about these changes. This should be very useful to you when working on the "client side" of the api-server. Note that Jaeger is available in the local deployment, so there you can investigate traces. Let me know if you want me to show you how this is useful to you.

@bisgaard-itis bisgaard-itis requested a review from mguidon June 3, 2025 14:10
@pcrespov pcrespov requested a review from Copilot June 3, 2025 14:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new feature that propagates a trace identifier (x-osparc-trace-id) in response headers for both the API server and webserver, enabling easier log association and trace inspection.

  • Propagates the trace id header by updating tracing setup functions in both the webserver and API server.
  • Introduces new middleware for FastAPI and aiohttp to attach the trace id header on responses.
  • Updates and adds tests to cover the new header behavior.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
services/web/server/src/simcore_service_webserver/tracing.py Enables trace id header propagation in webserver tracing configuration.
services/api-server/src/simcore_service_api_server/core/application.py Updates tracing initialization to pass the header propagation flag.
packages/service-library/tests/fastapi/test_tracing.py Adds tests to ensure the trace id header is present in responses.
packages/service-library/tests/fastapi/conftest.py Adjusts fixtures to support the updated tracing behavior.
packages/service-library/tests/aiohttp/test_tracing.py Adds similar tests for aiohttp server responses.
packages/service-library/tests/aiohttp/conftest.py Provides a fixture for in-memory span exporter used in aiohttp tests.
packages/service-library/src/servicelib/tracing.py Defines the trace id header constant and helper to generate it.
packages/service-library/src/servicelib/fastapi/tracing.py Introduces middleware to attach the trace id header in FastAPI responses.
packages/service-library/src/servicelib/aiohttp/tracing.py Adds middleware logic for injecting the trace id header in aiohttp responses.

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

Copy link
Contributor

@wvangeit wvangeit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, thanks.

@bisgaard-itis bisgaard-itis requested a review from odeimaiz June 4, 2025 07:48
Copy link
Contributor

@YuryHrytsuk YuryHrytsuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@bisgaard-itis bisgaard-itis enabled auto-merge (squash) June 12, 2025 06:55
@sonarqubecloud
Copy link

@bisgaard-itis bisgaard-itis merged commit a5e90f2 into ITISFoundation:master Jun 13, 2025
93 of 95 checks passed
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request Aug 5, 2025
88 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add osparc trace id in response headers outside the platform

7 participants