-
Notifications
You must be signed in to change notification settings - Fork 884
CASSJAVA-97: Let users inject an ID for each request and write to the custom payload #2037
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
base: 4.x
Are you sure you want to change the base?
Changes from 9 commits
b774dff
5b12695
6660c04
15d0396
c075c0f
ce2ae9a
5cfcbc2
5f95b14
2f40b1e
457d582
05159d8
3505d7a
4fa88a0
e2a2482
6368097
f30baf7
69d0666
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
import com.datastax.oss.driver.api.core.specex.SpeculativeExecutionPolicy; | ||
import com.datastax.oss.driver.api.core.ssl.SslEngineFactory; | ||
import com.datastax.oss.driver.api.core.time.TimestampGenerator; | ||
import com.datastax.oss.driver.api.core.tracker.RequestIdGenerator; | ||
import com.datastax.oss.driver.api.core.tracker.RequestTracker; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import java.util.Map; | ||
|
@@ -139,6 +140,10 @@ default SpeculativeExecutionPolicy getSpeculativeExecutionPolicy(@NonNull String | |
@NonNull | ||
RequestTracker getRequestTracker(); | ||
|
||
/** @return The driver's request ID generator; never {@code null}. */ | ||
@NonNull | ||
RequestIdGenerator getRequestIdGenerator(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm going to argue this should actually return |
||
|
||
/** @return The driver's request throttler; never {@code null}. */ | ||
@NonNull | ||
RequestThrottler getRequestThrottler(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.datastax.oss.driver.api.core.tracker; | ||
|
||
import com.datastax.oss.driver.api.core.session.Request; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
|
||
public interface RequestIdGenerator { | ||
/** | ||
* Generates a unique identifier for the session request. This will be the identifier for the | ||
* entire `session.execute()` call. This identifier will be added to logs, and propagated to | ||
* request trackers. | ||
* | ||
* @param statement the statement to be executed | ||
* @param sessionName the name of the session | ||
* @param hashCode the hashcode of the CqlRequestHandler | ||
* @return a unique identifier for the session request | ||
*/ | ||
String getSessionRequestId(@NonNull Request statement, @NonNull String sessionName, int hashCode); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This interface seems a bit too connected to the default impl of RequestIdGenerator. It makes sense to pass the hash code of the relevant CqlRequestHandler given that implementation but is that parameter going to be generally usable? I'd almost prefer to see the complete CqlRequestHandler passed here rather than just a hash code. That way if other implementers want to pull other values out of the handler (or even provider their own custom handlers with additional info available) they have an easy way to do so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can rename the parameter to |
||
|
||
/** | ||
* Generates a unique identifier for the node request. This will be the identifier for the CQL | ||
* request against a particular node. There can be one or more node requests for a single session | ||
* request, due to retries or speculative executions. This identifier will be added to logs, and | ||
* propagated to request trackers. | ||
* | ||
* @param statement the statement to be executed | ||
* @param sessionRequestId the session request identifier | ||
* @param executionCount the number of previous node requests for this session request, due to | ||
* retries or speculative executions | ||
* @return a unique identifier for the node request | ||
*/ | ||
String getNodeRequestId( | ||
@NonNull Request statement, @NonNull String sessionRequestId, int executionCount); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here I guess; execution count feels very tied to how the default request ID generator works. Is there a way we can generalize this a bit? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that this parameter makes sense. Within one session, we can retry sending the same request due to retry policy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, but that doesn't mean execution count is relevant to all implementations. It also begs the question of whether other things can/should be included for all implementations. More generally, I'd argue it's inclusion here is primarily a function of the necessity of implementing the current log prefix as a request ID generator... which I'm not sure is a good idea (more on that elsewhere). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In related news: how do we not include the node in question when we're generating a node request ID? Requests/Statements can have a node set as state but that's an optional thing a user can set in order to target a specific node; that's not automatically set for every request. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) naming: I find "custom-payload-key" clearer, you're already using that naming elsewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the enum name, or the typesafe config path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe @aratno is referring to the TypeSafe name @SiyaoIsHiding ... "custom-payload-key" rather than "custom-payload-with-key". Assuming that's correct I think he's on to something there.