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

Try removing sync stack context flag #34184

Merged
merged 8 commits into from
Mar 28, 2023

Conversation

lmolkova
Copy link
Member

No description provided.

@ghost ghost added the Azure.Core azure-core label Mar 23, 2023
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@lmolkova
Copy link
Member Author

/azp run java - containerregistry - tests

@lmolkova
Copy link
Member Author

/azp run java - monitor - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lmolkova lmolkova requested review from alzimmermsft, g2vinay and samvaity and removed request for alzimmermsft, srnagar, ki1729 and g2vinay March 24, 2023 19:42
@g2vinay
Copy link
Member

g2vinay commented Mar 24, 2023

/azp run java - keyvault - ci

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@g2vinay
Copy link
Member

g2vinay commented Mar 24, 2023

/azp run java - keyvault - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Override
public BinaryData getBodyAsBinaryData() {
BinaryData content = actualResponse.getBodyAsBinaryData();
doLog(content.toString());
Copy link
Member

Choose a reason for hiding this comment

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

Why is this API override logging?

Copy link
Member Author

Choose a reason for hiding this comment

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

To make body logging synchronous: getBodyAsBinaryData is the only sync way to get the response body and default implementation is async

public BinaryData getBodyAsBinaryData() {
Flux<ByteBuffer> body = getBody();
if (body != null) {
return BinaryDataHelper.createBinaryData(new FluxByteBufferContent(body));

Copy link
Member

Choose a reason for hiding this comment

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

Should we eagerly call content.toString() here? Instead we should consider passing the content to doLog() method and there, we can use the supplier methods ClientLogger provides to log if logging is enabled - logBuilder.addKeyValue(BODY_KEY, () -> content.toString()).

Copy link
Member Author

@lmolkova lmolkova Mar 27, 2023

Choose a reason for hiding this comment

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

LoggingHttpResponse is created only if logging at that level is enabled, body logging is enabled and content type is not a stream, so there is no need to do lazy toString - there are no checks in doLog method.

if (!logger.canLogAtLevel(logLevel)) {
return response;
}
LoggingEventBuilder logBuilder = getLogBuilder(logLevel, logger);
logContentLength(response, logBuilder);
logUrl(loggingOptions, response, logBuilder);
logHeaders(logger, response, logBuilder);
if (httpLogDetailLevel.shouldLogBody()) {
String contentTypeHeader = response.getHeaderValue("Content-Type");
long contentLength = getContentLength(logger, response.getHeaders());
if (shouldBodyBeLogged(contentTypeHeader, contentLength)) {
return new LoggingHttpResponse(response, logBuilder, logger,

@lmolkova
Copy link
Member Author

/azp run java - keyvault - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@samvaity samvaity left a comment

Choose a reason for hiding this comment

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

Changes lgtm!

@Override
public BinaryData getBodyAsBinaryData() {
BinaryData content = actualResponse.getBodyAsBinaryData();
doLog(content.toString());
Copy link
Member

Choose a reason for hiding this comment

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

Should we eagerly call content.toString() here? Instead we should consider passing the content to doLog() method and there, we can use the supplier methods ClientLogger provides to log if logging is enabled - logBuilder.addKeyValue(BODY_KEY, () -> content.toString()).

@lmolkova lmolkova enabled auto-merge (squash) March 27, 2023 21:52
@lmolkova lmolkova merged commit e930335 into Azure:main Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core azure-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants