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

Upcoming Release Changes #2333

Merged
merged 1 commit into from
Nov 26, 2024
Merged

Upcoming Release Changes #2333

merged 1 commit into from
Nov 26, 2024

Conversation

theguild-bot
Copy link
Collaborator

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@envelop/[email protected]

Minor Changes

  • #2326
    443fc15
    Thanks @EmrysMyrddin! - Allow to explicitly control which
    events and timing should be observe.

    Each metric can now be configured to observe events and timings only for certain GraphQL pipeline
    phases, or depending on the request context.

    Example: trace only execution and subscription errors

    import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
    import { envelop, useEngine } from '@envelop/core'
    import { usePrometheus } from '@envelop/prometheus'
    
    const TRACKED_OPERATION_NAMES = [
      // make a list of operation that you want to monitor
    ]
    
    const getEnveloped = envelop({
      plugins: [
        useEngine({ parse, validate, specifiedRules, execute, subscribe }),
        usePrometheus({
          metrics: {
            // Here, an array of phases can be provided to enable the metric only on certain phases.
            // In this example, only error happening during the execute and subscribe phases will tracked
            graphql_envelop_phase_error: ['execute', 'subscribe']
          }
        })
      ]
    })

    Example: Monitor timing only of a set of operations by name

    import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
    import { envelop, useEngine } from '@envelop/core'
    import { usePrometheus } from '@envelop/prometheus'
    
    const TRACKED_OPERATION_NAMES = [
      // make a list of operation that you want to monitor
    ]
    
    const getEnveloped = envelop({
      plugins: [
        useEngine({ parse, validate, specifiedRules, execute, subscribe }),
        usePrometheus({
          metrics: {
            graphql_yoga_http_duration: createHistogram({
              registry,
              histogram: {
                name: 'graphql_envelop_request_duration',
                help: 'Time spent on HTTP connection',
                labelNames: ['operationName']
              },
              fillLabelsFn: ({ operationName }, _rawContext) => ({ operationName }),
              phases: ['execute', 'subscribe'],
    
              // Here `shouldObserve` control if the request timing should be observed, based on context
              shouldObserve: ({ operationName }) => TRACKED_OPERATIONS.includes(operationName)
            })
          }
        })
      ]
    })

    Default Behavior Change

    A metric is enabled using true value in metrics options will observe in every phases available.

    Previously, which phase was observe was depending on which other metric were enabled. For example,
    this config would only trace validation error:

    usePrometheus({
      metrics: {
        graphql_envelop_phase_error: true,
        graphql_envelop_phase_validate: true
      }
    })

    This is no longer the case. If you were relying on this behavior, please use an array of string to
    restrict observed phases.

    usePrometheus({
      metrics: {
        graphql_envelop_phase_error: ['validate']
      }
    })

Copy link
Contributor

🚀 Snapshot Release (rc)

The latest changes of this PR are available as rc on npm (based on the declared changesets):

Package Version Info
@envelop/prometheus 11.1.0-rc-20241124151125-338b050d33d579aa9f708c1935e696f287223b48 npm ↗︎ unpkg ↗︎

Copy link
Contributor

💻 Website Preview

The latest changes are available as preview in: https://6f8f8a84.envelop.pages.dev

@theguild-bot
Copy link
Collaborator Author

✅ Benchmark Results

     ✓ no_errors
     ✓ expected_result

     checks.............................................: 100.00% ✓ 771442      ✗ 0     
     ✓ { mode:envelop-cache-and-no-internal-tracing }...: 100.00% ✓ 166582      ✗ 0     
     ✓ { mode:envelop-cache-jit }.......................: 100.00% ✓ 335162      ✗ 0     
     ✓ { mode:envelop-just-cache }......................: 100.00% ✓ 167932      ✗ 0     
     ✓ { mode:graphql-js }..............................: 100.00% ✓ 101766      ✗ 0     
     data_received......................................: 2.9 GB  25 MB/s
     data_sent..........................................: 168 MB  1.4 MB/s
     envelop_init.......................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     envelop_total......................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     event_loop_lag.....................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-and-no-internal-tracing }...: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     graphql_context....................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     graphql_execute....................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     graphql_parse......................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     graphql_validate...................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     http_req_blocked...................................: avg=2.91µs  min=1.22µs   med=2.6µs   max=6.3ms   p(90)=3.41µs  p(95)=3.78µs 
     http_req_connecting................................: avg=18ns    min=0s       med=0s      max=1.25ms  p(90)=0s      p(95)=0s     
     http_req_duration..................................: avg=2.82ms  min=165.48µs med=2.74ms  max=38.38ms p(90)=5.15ms  p(95)=6.02ms 
       { expected_response:true }.......................: avg=2.82ms  min=165.48µs med=2.74ms  max=38.38ms p(90)=5.15ms  p(95)=6.02ms 
     ✓ { mode:envelop-cache-and-no-internal-tracing }...: avg=3.33ms  min=483.05µs med=3ms     max=24.47ms p(90)=5.62ms  p(95)=6.14ms 
     ✓ { mode:envelop-cache-jit }.......................: avg=1.48ms  min=165.48µs med=1.23ms  max=18.91ms p(90)=2.48ms  p(95)=2.64ms 
     ✓ { mode:envelop-just-cache }......................: avg=3.3ms   min=415.86µs med=2.95ms  max=24.05ms p(90)=5.54ms  p(95)=6.07ms 
     ✓ { mode:graphql-js }..............................: avg=5.62ms  min=1.11ms   med=4.83ms  max=38.38ms p(90)=9.38ms  p(95)=10.15ms
     http_req_failed....................................: 0.00%   ✓ 0           ✗ 385721
     http_req_receiving.................................: avg=35.69µs min=12.39µs  med=30.98µs max=9.82ms  p(90)=47.29µs p(95)=50.65µs
     http_req_sending...................................: avg=12.75µs min=4.09µs   med=9.98µs  max=10.29ms p(90)=19.75µs p(95)=21.01µs
     http_req_tls_handshaking...........................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     http_req_waiting...................................: avg=2.77ms  min=138.16µs med=2.69ms  max=38.34ms p(90)=5.09ms  p(95)=5.97ms 
     http_reqs..........................................: 385721  3214.213018/s
     iteration_duration.................................: avg=3.1ms   min=367.21µs med=2.99ms  max=38.66ms p(90)=5.43ms  p(95)=6.31ms 
     iterations.........................................: 385721  3214.213018/s
     vus................................................: 10      min=10        max=10  
     vus_max............................................: 20      min=20        max=20  

@EmrysMyrddin EmrysMyrddin merged commit 40889ca into main Nov 26, 2024
18 checks passed
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.

2 participants