-
Notifications
You must be signed in to change notification settings - Fork 1
Observability Package #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
6c90dee
PLAN
AlexAxthelm bcd6037
Extract observability package and call in services
AlexAxthelm 7c197ca
remove PLAN
AlexAxthelm fa8fc01
Improve structured logging
AlexAxthelm 6bea1ef
use structured logging in deployments
AlexAxthelm 5f89d85
Add py.typed
AlexAxthelm 8ee58ea
implify tracing setup for FastAPI
AlexAxthelm 0d1f5a2
Standardize sqlalchemy tracing setup
AlexAxthelm dbdcbd3
Btter truncation and remove transitive deps as explicit
AlexAxthelm 252c9b5
standardize truncation, and don't rebuild attributes
AlexAxthelm 9930e32
Standardize request tracing middleware
AlexAxthelm 972453c
update request header and wire up api with standard request timing
AlexAxthelm 27310de
Merge branch 'main' into feat/observability-package2
AlexAxthelm 856b38c
cleanup cruft
AlexAxthelm b9f72fa
more cleanup
AlexAxthelm 11a2b65
avoid context leaks
AlexAxthelm 11ee2aa
cleanups: JsonFormatter guard, docs
AlexAxthelm ec3c0eb
Add startup tests
AlexAxthelm 0cf5598
Merge branch 'main' into feat/observability-package2
AlexAxthelm 2e6bcb4
update docs
AlexAxthelm 56faba4
Merge branch 'main' into feat/observability-package2
AlexAxthelm 68f115e
Merge branch 'main' into feat/observability-package2
AlexAxthelm 268e2a5
Merge branch 'main' into feat/observability-package2
AlexAxthelm 6b2a101
Merge branch 'main' into feat/observability-package2
AlexAxthelm 3bb3c35
Merge branch 'main' into feat/observability-package2
AlexAxthelm 92aabb1
Add optional dependency on starlette (usually used)
AlexAxthelm 1ad4891
test error on missing dep
AlexAxthelm 45b496f
simplify ownership for middleware context variables
AlexAxthelm 09f0ae2
Merge branch 'main' into feat/observability-package2
AlexAxthelm db7cbdd
unify app creation: same in runtime and tests
AlexAxthelm 5defa8e
optimisically trace outbound calls
AlexAxthelm 39d3510
rm dead code
AlexAxthelm a9b3968
explicit checking of OTelSettings
AlexAxthelm 6b31c9d
attach tracer provider to app state for cleanup
AlexAxthelm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,24 @@ | ||
| """Performance instrumentation and tracing for the Stitch API. | ||
| """Performance instrumentation for the Stitch API. | ||
|
|
||
| Two complementary layers: | ||
| The generic machinery — tracing setup, structured logging, and the | ||
| ``RequestContextMiddleware`` that establishes per-request context and tags the | ||
| active span — lives in the shared ``stitch.observability`` package and is wired | ||
| up directly in :mod:`stitch.api.main` / :mod:`stitch.api.db.config`. This | ||
| subpackage holds the API-specific pieces layered on top: | ||
|
|
||
| * Structured-log timing — a SQLAlchemy event listener at the single engine | ||
| chokepoint (:mod:`query_timing`) and a request-timing middleware | ||
| (:mod:`request_logging`), both emitting through :mod:`sinks` to stdout, where | ||
| * Structured-log query timing — a SQLAlchemy event listener at the single engine | ||
| chokepoint (:mod:`query_timing`) emitting through :mod:`sinks` to stdout, where | ||
| Azure Container Apps forwards it to Log Analytics. Always on, independent of | ||
| trace sampling. | ||
| * OpenTelemetry tracing (:mod:`tracing`) — FastAPI / SQLAlchemy | ||
| auto-instrumentation producing spans, exported over OTLP to a collector or | ||
| logged to stdout (``OTEL_TRACES_EXPORTER``). The request middleware copies the | ||
| request id / scenario onto the active span so the two layers correlate. | ||
| * Per-request DB aggregates — :mod:`request_logging` extends the shared | ||
| ``RequestContextMiddleware`` to add this request's query count / time to the | ||
| request-summary log event. | ||
| """ | ||
|
|
||
| from .logging_config import configure_logging | ||
| from .query_timing import register_query_timing | ||
| from .request_logging import RequestTimingMiddleware | ||
| from .tracing import configure_tracing, instrument_fastapi, instrument_sqlalchemy | ||
|
|
||
| __all__ = [ | ||
| "configure_logging", | ||
| "register_query_timing", | ||
| "RequestTimingMiddleware", | ||
| "configure_tracing", | ||
| "instrument_fastapi", | ||
| "instrument_sqlalchemy", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.