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

Add graphql instruments #5215

Merged
merged 69 commits into from
May 28, 2024
Merged

Add graphql instruments #5215

merged 69 commits into from
May 28, 2024

Conversation

BrynCooke
Copy link
Contributor

@BrynCooke BrynCooke commented May 22, 2024

This PR adds GraphQL instruments to telemetry as a commercial feature.

It makes the following possible:

telemetry:
  exporters:
    tracing:
      propagation:
        trace_context: true
    metrics:
      prometheus:
        enabled: true

  instrumentation:
    instruments:
      graphql:
        # The number of times a field was executed (counter)
        field.execution: true

        # The length of list fields (histogram)
        list.length: true

        # Custom counter of field execution where field name = name
        "custom_counter":
          description: "count of name field"
          type: counter
          unit: "unit"
          value: field_unit
          attributes:
            graphql.type.name: true
            graphql.field.type: true
            graphql.field.name: true
          condition:
            eq:
              - field_name: string
              - "name"

        # Custom histogram of list lengths for topProducts
        "custom_histogram":
          description: "histogram of review length"
          type: histogram
          unit: "unit"
          attributes:
            graphql.type.name: true
            graphql.field.type: true
            graphql.field.name: true
          value:
            field_custom:
              list_length: value
          condition:
            eq:
              - field_name: string
              - "topProducts"

This reuses the schema aware zipping that has been developed for cost control to visit response documents and create metrics.

New selectors are:

  • graphql.type.name
  • graphql.field.type
  • graphql.field.name
  • graphql.field.length

And new standard instruments are:

  • field.execution - The count of times a field was returned in responses by field name and containing type
  • list.length - A histogram of list lengths by field name and containing type

Follow ups:

  • documentation and changelog is not added as part of this PR and will be done separately.
  • Refactor some code to bring it out of the cost module as it is shared across cost and telemetry.

Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Tests added and passing3
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

This comment has been minimized.

@BrynCooke BrynCooke requested review from bnjjj and tninesling May 26, 2024 21:25
@BrynCooke BrynCooke merged commit 0d69429 into dev May 28, 2024
14 checks passed
@BrynCooke BrynCooke deleted the bryn/graphql-instriments-extended branch May 28, 2024 09:10
@Geal Geal mentioned this pull request May 29, 2024
lrlna pushed a commit that referenced this pull request Jun 3, 2024
Co-authored-by: Taylor Ninesling <taylor.ninesling@apollographql.com>
Co-authored-by: bryn <bryn@apollographql.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
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