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

Add a ServiceTalk debugging utilities example #1459

Merged
merged 5 commits into from
Mar 29, 2021

Conversation

bondolo
Copy link
Contributor

@bondolo bondolo commented Mar 25, 2021

Motivation:
ServiceTalk has purpose-built features for improving the debugging
experience for both applications and for ServiceTalk itself. An example
with explanatory comments would improve exposure of these features.

Modifications:
A new HTTP debugging example is provided demonstrating wire logging,
disabling offloading, disabling async context.

Result:
ServiceTalk debugging features are more visible.

@bondolo bondolo self-assigned this Mar 25, 2021
Motivation:
HttpExecutionStrategies.noOffloadsStrategy() does not disable all
offloading.

Modifications:
Improve the description of HttpExecutionStrategies.noOffloadsStrategy()
to better explain where the default offloading executor will still be
used. A recipe is provided to completely disable offloading.

Result:
Behaviour of HttpExecutionStrategies.noOffloadsStrategy() is clarified.
Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

Good idea to demonstrate this features! Have a few suggestions to improve the focus:


dependencies {
implementation project(":servicetalk-annotations")
implementation project(":servicetalk-encoding-netty")
Copy link
Member

Choose a reason for hiding this comment

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

This dependency is not used in this example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there an IntelliJ detector for this? I used to use one in Netbeans with Maven and would like to turn it on for Gradle if I could.

Copy link
Member

Choose a reason for hiding this comment

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

Not that I'm aware of 🤷‍♂️

// Enables visibility for all wire log messages
System.setProperty("servicetalk.logger.wireLogLevel", "TRACE");
// Disables the context associated with individual request/responses to simplify execution tracing
AsyncContext.disable();
Copy link
Member

@idelpivnitskiy idelpivnitskiy Mar 27, 2021

Choose a reason for hiding this comment

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

Not sure, but something to discuss and consider: because it's easy to forget to remove this statement after the debugging we may demonstrate it can be protected by the system property. Something like:

static {
    if (Boolean.getBoolean("debuggingMode")) {
        AsyncContext.disable();
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be good to standardize how we use system properties and/or environment variables for configuration and control of debugging features. It is definitely a useful tool. In other orgs I have used

(public|private) static final boolean SOMETHING_DEBUG = Boolean.getBoolean("package.name.Feature.debug");`

and then triggered all use off of the boolean. One advantage is that it lets the JIT remove dead code and also makes it easy to find all the references.

bondolo added 2 commits March 29, 2021 11:19
Motivation:
ServiceTalk has purpose-built features for improving the debugging
experience for both applications and for ServiceTalk itself. An example
with explanatory comments would improve exposure of these features.

Modifications:
A new HTTP debugging example is provided demonstrating wire logging,
disabling offloading, disabling async context.

Result:
ServiceTalk debugging features are more visible.
provide (very verbose) samples of the output
@bondolo bondolo force-pushed the debugging-example branch from 847e548 to e50b16d Compare March 29, 2021 18:19
@bondolo bondolo merged commit d7ecc59 into apple:main Mar 29, 2021
@bondolo bondolo deleted the debugging-example branch March 29, 2021 20:18
@bondolo
Copy link
Contributor Author

bondolo commented Mar 29, 2021

Thank you for the feedback. I think this will be a really useful example.

idelpivnitskiy added a commit to idelpivnitskiy/servicetalk that referenced this pull request Mar 30, 2021
Motivation:

Fixing a few typos, adding links to appropriate features in javadoc,
clarifying difference between wire-logger and h2-frame-logger.

Modifications:

- Fix typos in `index.adoc` and `log4j2.xml` name;
- Add links in javadoc for all demonstrated features;
- Use a different name for h2 frame logger;
- Use another comment style to highlight comments for demonstrated
features;
- Add `CLOSE/INACTIVE/UNREGISTERED` wire logger events;

Result:

More details in the example.
idelpivnitskiy added a commit that referenced this pull request Mar 31, 2021
Motivation:

Fixing a few typos, adding links to appropriate features in javadoc,
clarifying the difference between wire-logger and h2-frame-logger.

Modifications:

- Fix typos in `index.adoc` and `log4j2.xml` name;
- Add links in javadoc for all demonstrated features;
- Use a different name for h2 frame logger;
- Use another comment style to highlight comments for demonstrated
features and let IDE use shortcut to uncomment the code line;
- Add `CLOSE/INACTIVE/UNREGISTERED` wire logger events;

Result:

More details in the example.
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.

3 participants