Repository navigation
fix: record status and error type for failed attempts #353
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ def __init__( | |
| fga_client_request_store_id: bool | None = None, | ||
| fga_client_response_model_id: bool | None = None, | ||
| fga_client_user: bool | None = None, | ||
| error_type: bool | None = None, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve the existing positional parameter order. Inserting Append
|
||
| http_client_request_duration: bool | None = None, | ||
| http_host: bool | None = None, | ||
| http_request_method: bool | None = None, | ||
|
|
@@ -44,6 +45,7 @@ def __init__( | |
| :param fga_client_request_store_id: The `fga-client.request.store_id` attribute includes the store ID that was sent as part of the request, if any. | ||
| :param fga_client_response_model_id: The `fga-client.response.model_id` attribute includes the authorization model ID that the FGA server used. | ||
| :param fga_client_user: The `fga-client.user` attribute includes the user associated with the request, if any. | ||
| :param error_type: The `error.type` attribute includes the type of error that ended a request without a response. | ||
| :param http_client_request_duration: The `http.client.request.duration` attribute includes the duration of the request from the client's perspective. | ||
| :param http_host: The `http.host` attribute includes the host name of the request. | ||
| :param http_request_method: The `http.request.method` attribute includes the HTTP method of the request. | ||
|
|
@@ -94,6 +96,9 @@ def __init__( | |
| if fga_client_user is not None: | ||
| self._state[TelemetryAttributes.fga_client_user] = fga_client_user | ||
|
|
||
| if error_type is not None: | ||
| self._state[TelemetryAttributes.error_type] = error_type | ||
|
|
||
| if http_client_request_duration is not None: | ||
| self._state[TelemetryAttributes.http_client_request_duration] = ( | ||
| http_client_request_duration | ||
|
|
@@ -276,6 +281,27 @@ def fga_client_user(self, value: bool): | |
| self._valid = None # Reset the validation state | ||
| self._state[TelemetryAttributes.fga_client_user] = value | ||
|
|
||
| @property | ||
| def error_type(self) -> bool: | ||
| """ | ||
| Get the configuration for the `error.type` attribute. | ||
|
|
||
| :return: The configuration for the `error.type` attribute. | ||
| """ | ||
|
|
||
| return self._state[TelemetryAttributes.error_type] | ||
|
|
||
| @error_type.setter | ||
| def error_type(self, value: bool): | ||
| """ | ||
| Set the configuration for the `error.type` attribute. | ||
|
|
||
| :param value: The configuration for the `error.type` attribute. | ||
| """ | ||
|
|
||
| self._valid = None # Reset the validation state | ||
| self._state[TelemetryAttributes.error_type] = value | ||
|
|
||
| @property | ||
| def http_client_request_duration(self) -> bool: | ||
| """ | ||
|
|
@@ -479,6 +505,7 @@ def clear(self) -> None: | |
| TelemetryAttributes.fga_client_request_store_id: False, | ||
| TelemetryAttributes.fga_client_response_model_id: False, | ||
| TelemetryAttributes.fga_client_user: False, | ||
| TelemetryAttributes.error_type: False, | ||
| TelemetryAttributes.http_client_request_duration: False, | ||
| TelemetryAttributes.http_host: False, | ||
| TelemetryAttributes.http_request_method: False, | ||
|
|
@@ -616,6 +643,7 @@ def getSdkDefaults() -> dict[TelemetryAttribute | str, bool]: | |
| TelemetryAttributes.fga_client_request_store_id: True, | ||
| TelemetryAttributes.fga_client_response_model_id: True, | ||
| TelemetryAttributes.fga_client_user: False, | ||
| TelemetryAttributes.error_type: True, | ||
| TelemetryAttributes.http_client_request_duration: False, | ||
| TelemetryAttributes.http_host: True, | ||
| TelemetryAttributes.http_request_method: True, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard an absent status before converting it.
ApiException()setsstatus=None. The first status check skips this value, but this branch still callsint(None)because the exception has astatusattribute. Thus,fromResponse(response=ApiException())raisesTypeError.Check that
response.statusis notNonehere too. Keep the existing status anderror.typehandling for HTTP responses.