-
Notifications
You must be signed in to change notification settings - Fork 272
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
Logging configuration to enable/disable specific logs #1998
Comments
Maybe let's start with something smaller, less features (like level and redact). And add them in the future if needed. telemetry:
logging:
format: pretty # Could be json or pretty
router:
request:
enabled: true
response:
# on_error includes http_error and graphql_error
mode: on_error # on_error | always
subgraphs:
all:
request:
enabled: true
response:
# on_error includes http_error and graphql_error
mode: on_error # on_error | always
my_subgraph:
request:
enabled: true
response:
# on_error includes http_error and graphql_error
mode: on_error # on_error | always |
Previous proposal with attributes (to keep history): telemetry:
logging:
format: json # By default it's "pretty" if you are in an interactive shell session
display_filename: true # Display filename where the log is coming from. Default: true
display_line_number: false # Display line number in the file where the log is coming from. Default: true
supergraph:
contains_attributes: # Available attributes are request|response_body|response_headers|operation_name
- request # Display the request at the supergraph level
subgraph:
all: # Display logs that contains these attributes
contains_attributes: # Available attributes are request|response_body|response_headers|operation_name
- response_body # Display the response_body for all the subgraph calls
subgraphs:
accounts: # Display logs that contains these attributes
contains_attributes: # Available attributes are request|response_body|response_headers|operation_name
- response_headers # Display the response_headers for the subgraph "accounts" |
Ok after feedback and some requirements I reshaped a new configuration: telemetry:
experimental_logging:
request:
# If one of these headers matches
when_header:
- name: apollo-router-log-request
value: my_client
headers: true # default: false
body: true # default: false
# log request for all requests coming from Iphones
- name: user-agent
match: ^Mozilla/5.0 (iPhone*
headers: true
response:
when_header:
- name: apollo-router-log-response
value: my_client
body: true Here are different scenarios covered:
Pros:
Cons:
|
Decision was to remove telemetry:
experimental_logging:
# If one of these headers matches we will log supergraph and subgraphs requests/responses
when_header:
- name: apollo-router-log-request
value: my_client
headers: true # default: false
body: true # default: false
# log request for all requests coming from Iphones
- name: user-agent
match: ^Mozilla/5.0 (iPhone*
headers: true We do not need to specify request or response and we still can play with |
close #1998 ## Basic configuration By default some logs containing sensible data (like request body, response body, headers) are not displayed even if we set the right log level. For example if you need to display raw responses from one of your subgraph it won't be displayed by default. To enable them you have to configure it thanks to the `when_header` setting in the new section `experimental_logging`. It let's you set different headers to enable more logs (request/response headers/body for supergraph and subgraphs) when the request contains these headers with corresponding values/regex. Here is an example how you can configure it: ```yaml title="router.yaml" telemetry: experimental_logging: format: json # By default it's "pretty" if you are in an interactive shell session display_filename: true # Display filename where the log is coming from. Default: true display_line_number: false # Display line number in the file where the log is coming from. Default: true # If one of these headers matches we will log supergraph and subgraphs requests/responses when_header: - name: apollo-router-log-request value: my_client headers: true # default: false body: true # default: false # log request for all requests coming from Iphones - name: user-agent match: ^Mozilla/5.0 (iPhone* headers: true ``` /!\ This PR also upgrade `tracing` (not to the latest version) because I needed a fix. Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
close #1998 ## Basic configuration By default some logs containing sensible data (like request body, response body, headers) are not displayed even if we set the right log level. For example if you need to display raw responses from one of your subgraph it won't be displayed by default. To enable them you have to configure it thanks to the `when_header` setting in the new section `experimental_logging`. It let's you set different headers to enable more logs (request/response headers/body for supergraph and subgraphs) when the request contains these headers with corresponding values/regex. Here is an example how you can configure it: ```yaml title="router.yaml" telemetry: experimental_logging: format: json # By default it's "pretty" if you are in an interactive shell session display_filename: true # Display filename where the log is coming from. Default: true display_line_number: false # Display line number in the file where the log is coming from. Default: true # If one of these headers matches we will log supergraph and subgraphs requests/responses when_header: - name: apollo-router-log-request value: my_client headers: true # default: false body: true # default: false # log request for all requests coming from Iphones - name: user-agent match: ^Mozilla/5.0 (iPhone* headers: true ``` /!\ This PR also upgrade `tracing` (not to the latest version) because I needed a fix. Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Subtask of #1840
Here are different versions I have in mind to enable/disable different logs:
or with a mode:
The text was updated successfully, but these errors were encountered: