-
Notifications
You must be signed in to change notification settings - Fork 58
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
Refactor frontend logging #926
Open
mbarnes
wants to merge
13
commits into
main
Choose a base branch
from
frontend-logging
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
mbarnes
force-pushed
the
frontend-logging
branch
2 times, most recently
from
December 4, 2024 17:02
dc243b6
to
b9ff0c4
Compare
mbarnes
force-pushed
the
frontend-logging
branch
from
December 6, 2024 13:49
b9ff0c4
to
0de128b
Compare
Please rebase pull request. |
Works for any document type now, and just stores a slice rather than the entire cache for that document type.
A new function NewQueryItemsSinglePageIterator alters the behavior of QueryItemsIterator to stop after the first "page" of items and record the Cosmos DB continuation token. The continuation token can be retrieved from the iterator with GetContinuationToken. A QueryItemsIterator created with NewQueryItemsIterator will never have a continuation token because it iterates until the last item. The in-memory cache also adds a GetContinuationToken method to its iterator implementation to fulfill the interface contract, but it always returns an empty string.
For CosmosDBClient, the maxItems argument controls the type of iterator returned. A positive maxItems returns a single- page iterator with a possible continuation token, otherwise the iterator continues until the last item. Since the in-memory cache does not have continuation tokens, the maxItems argument is ignored. This also drops the resourceType argument. Callers first need to parse the iterator items into resource documents before checking the resource type.
Add "externalID" and "internalID" parameters so the returned document is a minimum valid OperationDocument for writing.
The operation item must now be created in the database prior to calling ExposeOperation. ExposeOperation does all its processing in a database update callback. This is because there is an increasing number of cases where we create an implicit async operation with no visible status endpoint. Calling ExposeOperation makes an implicit async operation explicit, with a status endpoint for ARM to poll. Hence the rename. The tradeoff is explicit asyncrhonous operations now require two database operations (create and update) but it helps make the RP logic cleaner. This could possibly be mitigated in the future by using Cosmos DB's transactional batch operations, but it's gonna take some serious refactoring to get there.
CancelActiveOperation marks the status of any active operation on the resource as canceled.
Will be reusing DeleteResource for subscription deletion. Add database bookkeeping for the resource and any child resources. This includes creating implicit operations for each resource being deleted. The caller may then expose the returned operation ID.
By my read of the Subscription Lifecycle API Reference [1], we should favor 200 OK over 201 Created when creating or updating a subscription. [1] https://github.com/cloud-and-ai-microsoft/resource-provider-contract/blob/master/v1.0/subscription-lifecycle-api-reference.md#response
Called when a subscription is deleted. The method is idempotent in case of multiple subscription PUT requests.
Don't count on OperationID being set in OperationDocuments. Implicit async operations will not have this field set. Get the subscription ID from ExternalID instead.
LoggerFromContext will never fail now. Middleware functions were falling back to the default logger, but we do this from within LoggerFromContext now so the fallback logic doesn't have to be repeated everywhere.
Always retrieve the logger from the request context. This ensures we're using the correct logger in case middleware functions add a logging attribute.
Add a logger attribute for the request's "api-version" parameter from MiddlewareValidateAPIVersion. Also remove the "<api-version>: <function-name>" log messages from the HTTP handler methods. I added these messages when the handlers were no more than stubs to test request routing but they no longer add value to the frontend logs.
mbarnes
force-pushed
the
frontend-logging
branch
from
December 17, 2024 19:22
0de128b
to
b86ccac
Compare
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.
What this PR does
I wanted to make what I thought was a small change to the frontend logs (essentially the last commit here). But when I realized the logger attribute I added ("api_version") was not showing up in logs, the ensuing investigation led me down a rabbit hole that resulted in some major logging refactoring.
Note: This extends #920, which is still outstanding, so its commits are duplicated here until it's merged. Only the last 3 commits are unique to this pull request.