Skip to content

[SHIP-832] Request ID python plumbing#529

Merged
douglas-reid merged 5 commits intomainfrom
dave/ship-832-request-id-python-plumbing
Sep 15, 2023
Merged

[SHIP-832] Request ID python plumbing#529
douglas-reid merged 5 commits intomainfrom
dave/ship-832-request-id-python-plumbing

Conversation

@dkolas
Copy link
Copy Markdown
Contributor

@dkolas dkolas commented Aug 24, 2023

Receive a requestId in lambda handler and attach it to the client object.

This requestId is then passed in all engine api calls to create traceability throughout the system.

Relies on PR: https://github.com/nludb/nludb/pull/621, so will not pass tests until that is deployed.

@dkolas dkolas requested review from GitOnUp and eob August 24, 2023 16:51
eob
eob previously approved these changes Aug 24, 2023
Copy link
Copy Markdown
Contributor

@eob eob left a comment

Choose a reason for hiding this comment

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

LGTM!

One small idea for a powerup, and it looks like a test is failing, but the design & testing strategy are awesome

) # invoke_later tasks get stored b64 encoded
return InvocableResponse(
json={
"packageRequestId": self.client.config.request_id,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a clever testing strategy

_,
):
result = instance.invoke("requestids", plugin_handle=plugin.handle)
package_request_id = result.get("packageRequestId")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not necessary in this PR, but an awesome addition would be to have the Proxy stamp a header on all requests that contained the requestId.

Then in addition to assert package_requestId is not None we could check against the Proxy's opinion of events.

I guess that would require us to use a raw HTTP post instead of instance.invoke to test though

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a good idea; should be very easy to add to the engine PR

GitOnUp
GitOnUp previously approved these changes Aug 24, 2023
Copy link
Copy Markdown
Contributor

@GitOnUp GitOnUp left a comment

Choose a reason for hiding this comment

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

One point of discussion here but LGTM

profile: Optional[str] = None

# For use in deployed packages and plugins for tracing. Do not set manually
request_id: Optional[str] = None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not blocking: Do not set manually is a surprising thing to read without being as ingrained in the context here yet; it also feels at first blush to me like this is Request-Scoped rather than Client-Scoped.

e.g. in the RequestIdGenerator in tests the PluginRequest seems like a natural place this would be, but I'm blanking on a request-scoped place to do this in e.g. a PackageService.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, you're right of course...

The reason I tucked it into the client config object specifically and not the InvocationContext was that the client object would need it to send back with every single request to the Engine. So putting it there allowed me to do it without the package or plugin author ever having to know it existed.

The comment, then, is to say "hey, don't mess with this" since AFAIK there isn't a particularly good Pythonic way of actively preventing someone from changing 'internal' member vars.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_ is usually the shorthand for "don't mess with this", but if you don't mind if they're making decisions by reading it, you could expose a getter without the _

@dkolas
Copy link
Copy Markdown
Contributor Author

dkolas commented Aug 25, 2023

LGTM!

One small idea for a powerup, and it looks like a test is failing, but the design & testing strategy are awesome

Good idea!

Test won't pass until the engine PR is deployed :)

@dkolas dkolas dismissed stale reviews from GitOnUp and eob via 4075fe0 August 28, 2023 15:43
@dkolas dkolas added this pull request to the merge queue Sep 15, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 15, 2023
@douglas-reid douglas-reid added this pull request to the merge queue Sep 15, 2023
Merged via the queue into main with commit d0e1e96 Sep 15, 2023
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.

4 participants