@@ -91,26 +91,28 @@ public function send(Event $event): Result
9191 $ this ->logger ->info (\sprintf ('Sending %s to %s. ' , $ eventDescription , $ targetDescription ), ['event ' => $ event ]);
9292
9393 $ eventType = $ event ->getType ();
94- if ($ this ->rateLimiter ->isRateLimited ((string ) $ eventType )) {
95- $ this ->logger ->warning (
96- \sprintf ('Rate limit exceeded for sending requests of type "%s". ' , (string ) $ eventType ),
97- ['event ' => $ event ]
98- );
99-
100- return new Result (ResultStatus::rateLimit ());
101- }
102-
103- // Since profiles are attached to transaction we have to check separately if they are rate limited.
104- // We can do this after transactions have been checked because if transactions are rate limited,
105- // so are profiles but not the other way around.
106- if ($ event ->getSdkMetadata ('profile ' ) !== null ) {
107- if ($ this ->rateLimiter ->isRateLimited (RateLimiter::DATA_CATEGORY_PROFILE )) {
108- // Just remove profiling data so the normal transaction can be sent.
109- $ event ->setSdkMetadata ('profile ' , null );
94+ if ($ eventType ->requiresRateLimiting ()) {
95+ if ($ this ->rateLimiter ->isRateLimited ((string )$ eventType )) {
11096 $ this ->logger ->warning (
111- 'Rate limit exceeded for sending requests of type "profile". The profile has been dropped. ' ,
97+ \sprintf ( 'Rate limit exceeded for sending requests of type "%s". ' , ( string ) $ eventType ) ,
11298 ['event ' => $ event ]
11399 );
100+
101+ return new Result (ResultStatus::rateLimit ());
102+ }
103+
104+ // Since profiles are attached to transaction we have to check separately if they are rate limited.
105+ // We can do this after transactions have been checked because if transactions are rate limited,
106+ // so are profiles but not the other way around.
107+ if ($ event ->getSdkMetadata ('profile ' ) !== null ) {
108+ if ($ this ->rateLimiter ->isRateLimited (RateLimiter::DATA_CATEGORY_PROFILE )) {
109+ // Just remove profiling data so the normal transaction can be sent.
110+ $ event ->setSdkMetadata ('profile ' , null );
111+ $ this ->logger ->warning (
112+ 'Rate limit exceeded for sending requests of type "profile". The profile has been dropped. ' ,
113+ ['event ' => $ event ]
114+ );
115+ }
114116 }
115117 }
116118
0 commit comments