feat(audit): Internal audit API client for service-to-service communication#454
Merged
ngjunsiang merged 3 commits intoweeklyfrom Apr 10, 2026
Merged
feat(audit): Internal audit API client for service-to-service communication#454ngjunsiang merged 3 commits intoweeklyfrom
ngjunsiang merged 3 commits intoweeklyfrom
Conversation
Create campus.audit.client for service-to-service HTTP communication between campus.auth/campus.api and campus.audit deployments. Implements ResourceCollection pattern with nested classes following campus-api-python conventions: - Traces (ResourceCollection) with new(), list(), search() - Traces.Trace (Resource) with get_tree() - Traces.Spans (ResourceCollection) with list() - Traces.Spans.Span (Resource) with get() Uses bracket access for IDs and property access for named sub-resources. Uses campus.common.http.DefaultClient for HTTP. Related: #453, #428
20 tasks
11 tasks
- Fix AuditRoot to inherit from ResourceRoot - Fix params dict type annotation to use dict[str, Any] - Fix forward references for nested classes (Traces.Spans, Traces.Spans.Span) - Add trace_id attribute declaration to Spans class - Add type narrowing casts in end_span function - Fix response body extraction with proper type casts All type checks now pass (pyright). Related: #453
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds internal HTTP client
campus.audit.clientfor communication between campus.auth/campus.api deployments and the audit service. This enables the tracing middleware (issue #428) to send trace spans via HTTP.Changes
New Files
campus/audit/client/__init__.py-AuditCliententry point with environment-based URL resolutioncampus/audit/client/interface.py- Base classes:ResourceRoot,ResourceCollection,Resourcecampus/audit/client/v1/__init__.py- v1 API modulecampus/audit/client/v1/root.py-AuditRootresourcecampus/audit/client/v1/traces.py-Traces,Trace,Spans,SpanresourcesModified Files
campus/audit/middleware/tracing.py- Updated to use new client API (new()instead ofingest())API Design
Follows Campus API schema conventions matching
campus-api-python:path = "traces/")Traces.Trace,Traces.Spans.Span)new(),list(),search(),get()client.traces[trace_id]client.traces[trace_id].spansUsage Example
Related Issues