Skip to content

Simplify implementation of telementry's events (backport #7280)#7313

Closed
IvanGoncharov wants to merge 1 commit into1.xfrom
mergify/bp/1.x/pr-7280
Closed

Simplify implementation of telementry's events (backport #7280)#7313
IvanGoncharov wants to merge 1 commit into1.xfrom
mergify/bp/1.x/pr-7280

Conversation

@IvanGoncharov
Copy link
Contributor

I made a few attempts to make minimal fixes based on #7231. However, it was extremely hard to cover all edge cases, so I decided to do a separate refactoring PR first.

The core issue is that currently, some on_request/on_response functions exit earlier:

if self.request.level() != EventLevel::Off {
if let Some(condition) = self.request.condition() {
if condition.lock().evaluate_request(request) != Some(true) {
return;

And because of it, bypass response and custom events:

if self.response.level() != EventLevel::Off {
request
.context
.extensions()
.with_lock(|ext| ext.insert(DisplayRouterResponse(true)));
}
for custom_event in &self.custom {
custom_event.on_request(request);
}

Simply removing returns and implementing logic using ifs also doesn't work:
https://github.com/apollographql/router/pull/7231/files#diff-fab80b4af0ee70850af9ac42bf7990d09912b65f75b39456c6e47ca817d4a0d2R262-R269

It results in the standard event without the condition being ignored.
Trying to address it with a more complicated condition would work, but it would require adding it to more than a dozen places and also doesn't guarantee that we don't break some other edge cases.


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


This is an automatic backport of pull request #7280 done by [Mergify](https://mergify.com).

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.

(cherry picked from commit e7d8e7b)

# Conflicts:
#	apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap
#	apollo-router/src/plugins/connectors/handle_responses.rs
#	apollo-router/src/plugins/telemetry/config_new/connector/events.rs
#	apollo-router/src/plugins/telemetry/config_new/events.rs
#	apollo-router/src/plugins/telemetry/fmt_layer.rs
#	apollo-router/src/plugins/telemetry/mod.rs
#	apollo-router/src/services/connector/request_service.rs
@IvanGoncharov IvanGoncharov requested a review from a team April 18, 2025 08:00
@IvanGoncharov IvanGoncharov requested a review from a team as a code owner April 18, 2025 08:00
@mergify mergify bot added the conflicts label Apr 18, 2025
@mergify
Copy link
Contributor

mergify bot commented Apr 18, 2025

Cherry-pick of e7d8e7b has failed:

On branch mergify/bp/1.x/pr-7280
Your branch is up to date with 'origin/1.x'.

You are currently cherry-picking commit e7d8e7bb.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   apollo-router/src/services/subgraph_service.rs
	modified:   apollo-router/src/services/supergraph/service.rs
	modified:   apollo-router/tests/integration/telemetry/fixtures/trace_id_via_header.router.yaml
	modified:   apollo-router/tests/integration/telemetry/propagation.rs

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	both modified:   apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap
	deleted by us:   apollo-router/src/plugins/connectors/handle_responses.rs
	deleted by us:   apollo-router/src/plugins/telemetry/config_new/connector/events.rs
	both modified:   apollo-router/src/plugins/telemetry/config_new/events.rs
	both modified:   apollo-router/src/plugins/telemetry/fmt_layer.rs
	both modified:   apollo-router/src/plugins/telemetry/mod.rs
	deleted by us:   apollo-router/src/services/connector/request_service.rs

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Apr 18, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 763d2fd23660d79afc0c28b2

@router-perf
Copy link

router-perf bot commented Apr 20, 2025

CI performance tests

  • connectors-const - Connectors stress test that runs with a constant number of users
  • const - Basic stress test that runs with a constant number of users
  • demand-control-instrumented - A copy of the step test, but with demand control monitoring and metrics enabled
  • demand-control-uninstrumented - A copy of the step test, but with demand control monitoring enabled
  • enhanced-signature - Enhanced signature enabled
  • events - Stress test for events with a lot of users and deduplication ENABLED
  • events_big_cap_high_rate - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity
  • events_big_cap_high_rate_callback - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity using callback mode
  • events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
  • events_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
  • events_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
  • extended-reference-mode - Extended reference mode enabled
  • large-request - Stress test with a 1 MB request payload
  • no-tracing - Basic stress test, no tracing
  • reload - Reload test over a long period of time at a constant rate of users
  • step-jemalloc-tuning - Clone of the basic stress test for jemalloc tuning
  • step-local-metrics - Field stats that are generated from the router rather than FTV1
  • step-with-prometheus - A copy of the step test with the Prometheus metrics exporter enabled
  • step - Basic stress test that steps up the number of users over time
  • xlarge-request - Stress test with 10 MB request payload
  • xxlarge-request - Stress test with 100 MB request payload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments