Skip to content

Conversation

@davidradl
Copy link
Contributor

Remove http header and responses from logging HTTP connector.

@davidradl
Copy link
Contributor Author

@ferenc-csaky Hi there - could you process this one please?

…HTTP connector

Signed-off-by: davidradl <david_radley@uk.ibm.com>
Signed-off-by: davidradl <david_radley@uk.ibm.com>
@davidradl
Copy link
Contributor Author

@ferenc-csaky here is the new version with the config to review.

@davidradl
Copy link
Contributor Author

I will add another commit for the docs

Signed-off-by: davidradl <david_radley@uk.ibm.com>
Copy link
Contributor

@ferenc-csaky ferenc-csaky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, added a couple comments.

| format | required | Flink's format name that should be used to decode REST response, Use `json` for a typical REST endpoint. |
| url | required | The base URL that should be use for GET requests. For example _http://localhost:8080/client_ |
| asyncPolling | optional | true/false - determines whether Async Polling should be used. Mechanism is based on Flink's Async I/O. |
| http.logging.level | optional | Logging levels for HTTP content. Valid values are `MIN` (the default), `REQRESPONSE` and `MAX`. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: How about keeping this with the other http. prefixed config options? To me it's more confusing to put things into a non-trivial order. Same for the sink option table.

/** Defines the level of http content that will be logged. */
public enum HttpLoggingLevelType {
MIN,
REQRESPONSE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about REQ_RES?

MAX;

public static HttpLoggingLevelType valueOfStr(String code) {
if (code == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ternary if

a new one is requested. There is a property `http.security.oidc.token.expiry.reduction`, that defaults to 1 second; new tokens will
be requested if the current time is later than the cached token expiry time minus `http.security.oidc.token.expiry.reduction`.

## Logging the http content
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: http -> HTTP

log.debug(createStringForExceptionResponse(request, e));
}

private HttpLogger(Properties properties) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move the ctor to the top, following field definitions which is mostly the rule of thumb in class ordering. IMO it's more confusing to have it in the middle of the class, even if the order goes from public to private.

Comment on lines +30 to +44
public void logRequest(HttpRequest httpRequest) {
log.debug(createStringForRequest(httpRequest));
}

public void logResponse(HttpResponse<String> response) {
log.debug(createStringForResponse(response));
}

public void logRequestBody(String body) {
log.debug(createStringForBody(body));
}

public void logExceptionResponse(HttpLookupSourceRequestEntry request, Exception e) {
log.debug(createStringForExceptionResponse(request, e));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should guard every log.debug call with a debug enabled check:

    if (log.isDebugEnabled()) {
        log.debug(...);
    }

With the current impl, the createString... methods will be called no matter what and processing every req/res and create strings of them for nothing will be costly.

var sinkRequestEntry = response.getHttpRequest();
var optResponse = response.getResponse();

HttpLogger.getHttpLogger(properties).logResponse(response.getResponse().get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why construct a new logger for every log event? Since the props won't change, we should instantiate 1 HTTP logger in the ctor and store that on the class level instead of the props. Same applies to BodyBasedRequestFactory.

.stringType()
.defaultValue(String.valueOf(HttpLoggingLevelType.MIN))
.withDescription(
"VALID values are "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: Since the Flink doc site cannot integrate the connector code level config option details, this description will not be shown anywhere.

Because of that I may synthesize this desc into http.md.

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