Skip to content
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

feat(telemetry): selectively transmit/redact subgraph ftv1 error messages to studio #3011

Merged
merged 9 commits into from
May 3, 2023

Conversation

bnjjj
Copy link
Contributor

@bnjjj bnjjj commented Apr 27, 2023

Add ability to transmit un-redacted errors from federated traces to Apollo Studio

When using subgraphs which are enabled with Apollo Federated Tracing, the error messages within those traces will be redacted by default.

New configuration (tracing.apollo.errors.subgraph.all.redact, which defaults to true) enables and disables the redaction mechanism. Similar configuration (tracing.apollo.errors.subgraph.all.send, which also defaults to true) enables and disables the entire transmission of the error to Studio.

The error messages returned to the clients are not changed or redacted from their previous behavior.

To enable sending subgraph's federated trace error messages to Studio without redaction, you can set the following configuration:

telemetry:
  apollo:
    errors:
      subgraph:
        all:
          send: true # (true = Send to Studio, false = Do not send; default: true)
          redact: false # (true = Redact full error message, false = Do not redact; default: true)

It is also possible to configure this per-subgraph using a subgraphs map at the same level as all in the configuration, much like other sections of the configuration which have subgraph-specific capabilities:

telemetry:
  apollo:
    errors:
      subgraph:
        all:
          send: true
          redact: false # Disable redaction as a default.  The `accounts` service enables it below.
        subgraphs:
          accounts: # Applies to the `accounts` subgraph, overriding the `all` global setting.
            redact: true # Redact messages from the `accounts` service.

By @bnjjj in #3011

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
@github-actions

This comment has been minimized.

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
@bnjjj bnjjj marked this pull request as ready for review May 2, 2023 10:16
@bnjjj bnjjj requested a review from StephenBarlow as a code owner May 2, 2023 10:16
@abernix abernix changed the title feat(telemetry): add a way to redact errors for studio feat(telemetry): selectively transmit/redact subgraph ftv1 error messages to studio May 2, 2023
@abernix abernix requested a review from BrynCooke May 3, 2023 07:20
Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me! Mostly a suggested change to the changeset entry.

apollo-router/src/plugins/telemetry/apollo.rs Outdated Show resolved Hide resolved
/// Enable field level instrumentation for subgraphs via ftv1. ftv1 tracing can cause performance issues as it is transmitted in band with subgraph responses.
/// 0.0 will result in no field level instrumentation. 1.0 will result in always instrumentation.
/// Value MUST be less than global sampling rate
/// Field level instrumentation for subgraphs via ftv1. ftv1 tracing can cause performance issues as it is transmitted in band with subgraph responses.
Copy link
Member

Choose a reason for hiding this comment

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

What was the motivation for this change in relation to this PR?

docs/source/configuration/apollo-telemetry.mdx Outdated Show resolved Hide resolved
.changesets/feat_bnjjj_add_apollo_redact_errors.md Outdated Show resolved Hide resolved
if let Some(mut t) = decode_ftv1_trace(s.as_str()) {
if error_config.redact || !error_config.send {
if let Some(root) = &mut t.root {
redact_node_errors(root, !error_config.send);
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel this code is confusing. The function is called redact_node_errors but takes the send config.
It'd be easier to get if it had the following signature preprocess_errors(root, redact, send)

Copy link
Member

Choose a reason for hiding this comment

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

Agree with this feedback, but let's follow-up on this in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done here #3030

Co-authored-by: Bryn Cooke <BrynCooke@gmail.com>
@abernix abernix enabled auto-merge (squash) May 3, 2023 11:41
Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks! (There's one follow-up comment within from @BrynCooke for another PR [maybe?])

@abernix abernix merged commit 10b7efa into dev May 3, 2023
@abernix abernix deleted the bnjjj/add_apollo_redact_errors branch May 3, 2023 12:36
@abernix abernix mentioned this pull request May 3, 2023
bnjjj added a commit that referenced this pull request May 10, 2023
…llo studio (#3030)

related to
#3011 (comment)

---------

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
garypen pushed a commit that referenced this pull request May 10, 2023
…ages to studio (#3011)

When using subgraphs which are enabled with [Apollo Federated
Tracing](https://www.apollographql.com/docs/router/configuration/apollo-telemetry/#enabling-field-level-instrumentation),
the error messages within those traces will be **redacted by default**.

New configuration (`tracing.apollo.errors.subgraph.all.redact`, which
defaults to `true`) enables and disables the redaction mechanism.
Similar configuration (`tracing.apollo.errors.subgraph.all.send`, which
also defaults to `true`) enables and disables the entire transmission of
the error to Studio.

The error messages returned to the clients are **not** changed or
redacted from their previous behavior.

To enable sending subgraph's federated trace error messages to Studio
**without redaction**, you can set the following configuration:

```yaml title="router.yaml"
telemetry:
  apollo:
    errors:
      subgraph:
        all:
          send: true # (true = Send to Studio, false = Do not send; default: true)
          redact: false # (true = Redact full error message, false = Do not redact; default: true)
```

It is also possible to configure this **per-subgraph** using a
`subgraphs` map at the same level as `all` in the configuration, much
like other sections of the configuration which have subgraph-specific
capabilities:

```yaml title="router.yaml"
telemetry:
  apollo:
    errors:
      subgraph:
        all:
          send: true
          redact: false # Disable redaction as a default.  The `accounts` service enables it below.
        subgraphs:
          accounts: # Applies to the `accounts` subgraph, overriding the `all` global setting.
            redact: true # Redact messages from the `accounts` service.
```

By [@bnjjj](https://github.com/bnjjj) in
#3011

---------

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Jesse Rosenberger <git@jro.cc>
Co-authored-by: Bryn Cooke <BrynCooke@gmail.com>
garypen pushed a commit that referenced this pull request May 10, 2023
…llo studio (#3030)

related to
#3011 (comment)

---------

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
@abernix abernix mentioned this pull request May 11, 2023
@Geal Geal mentioned this pull request May 26, 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.

3 participants