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

PAYARA-931 Payara Micro Request Tracing #1107

Merged

Conversation

Pandrex247
Copy link
Member

@Pandrex247 Pandrex247 commented Sep 23, 2016

Adds in command line options to enable and configure request tracing in Payara Micro.
Also turns on the Notification service by default.

The new options are:

  • --enableRequestTracing - Just a flag; you don't need to add true or false afterwards.
  • --requestTracingThresholdUnit - Accepts a String value determining the time unit, defaulting to seconds if no value is given. The accepted strings are (case insensitive): NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS, and DAYS.
  • --requestTracingThresholdValue - Accepts a long to determine the threshold value before a request is traced, defaulting to 30 if no value is entered.

As an example of usage:
java -jar payaramicro.jar --enableRequestTracing --requestTracingThresholdUnit NANOSECONDS --requestTracingThresholdValue 7

@payara-ci
Copy link
Contributor

Can one of the admins verify this patch?

1 similar comment
@payara-ci
Copy link
Contributor

Can one of the admins verify this patch?

case "--enableRequestTracing":
enableRequestTracing = true;
break;
case "--requestTracingThresholdUnit":
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be some validation on the the units passed in on the command line to ensure they are valid units.

@@ -155,6 +155,12 @@ Portions Copyright [2016] [Payara Foundation and/or its affiliates]
</transaction-service>
Copy link
Contributor

Choose a reason for hiding this comment

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

microdomain nocluster also need configuring correctly

@Pandrex247
Copy link
Member Author

Updated with required changes.
I've also made it so it accepts lowercase characters for the requestTracingThresholdUnit.

@smillidge
Copy link
Contributor

jenkins test please

1 similar comment
@smillidge
Copy link
Contributor

jenkins test please

@payara-ci
Copy link
Contributor

One or more tests have failed

@michaelranaldo
Copy link
Contributor

jenkins test please

@payara-ci
Copy link
Contributor

All tests have passed

case "--requestTracingThresholdValue":
try {
requestTracingThresholdValue =
Long.parseLong(args[i + 1]);
Copy link
Contributor

Choose a reason for hiding this comment

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

this smells like ArrayIndexOutOfBoundsException when a user forgets to include the actual units.

@jerrinot
Copy link
Contributor

jerrinot commented Oct 7, 2016

Two parameters for a single thing look a bit awkward.

Why not
--requestTracingThreshold 2 <-- defaults to seconds = common case

+parsing units from the value itself when needed?
--requestTracingThreshold 500ms

From the other hand It could become somewhat clumsy with microseconds (us or μs ?) or with days (1 days?)

@Pandrex247
Copy link
Member Author

I like the idea of a single option, we could even go full hog and combine all 3 into one (enable, time, and units) - though in either situation I'm fond of keeping the discrete options for flexibility. I'll have a play and see what I can cobble together.

I'll check for any obvious OutOfBounds cases, but I believe several of the configuration options for Payara Micro can fall afoul of this, so is probably worth its own PR to fix it rather than tacking it onto this one.

@@ -1410,6 +1431,112 @@ private void scanArgs(String[] args) {
case "--disablePhoneHome":
disablePhoneHome = true;
break;
case "--requestTracing":
Copy link
Contributor

Choose a reason for hiding this comment

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

this is screaming for refactoring.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. I've just noticed that this option makes the --enableRequestTracing one completely obsolete, so I'll rename it to that.

@Pandrex247
Copy link
Member Author

Pandrex247 commented Oct 11, 2016

Heavily modified the --enableRequestTracing option.

The option now enables the request tracing service, and optionally configures the threshold unit and value. I've also added extra unit validation (to both this option, and the original one), allowing you to now enter:

  • Nanoseconds (case-insensitive), Nanosecond (case-insensitive), ns
  • Microseconds (case-insensitive), Microsecond (case-insensitive), us, μs
  • Milliseconds (case-insensitive), Millisecond (case-insensitive), ms
  • Seconds (case-insensitive), Second (case-insensitive), s
  • Minutes (case-insensitive), Minute (case-insensitive), Mins (case-insensitive), Min (case-insensitive), m
  • Hours (case-insensitive), Hour (case-insensitive), h
  • Days (case-insensitive), Day (case-insensitive), d

I decided against enforcing proper grammar and refusing options such as "3day", as not everyone cares as much as I do.

Example usages:

  • Enable request tracing - java -jar payara-micro.jar --enableRequestTracing
  • Enable request tracing and set threshold unit to nanoseconds (value defaults to 30) - java -jar payara-micro.jar --enableRequestTracing ns
  • Enable request tracing and set threshold value to 2 (unit defaults to seconds) - java -jar payara-micro.jar --enableRequestTracing 2
  • Enable request tracing and set threshold to 4 microseconds - java -jar payara-micro.jar --enableRequestTracing 4ms

In its current state, entering something like --enableRequestTracing 4 minutes will have the minutes ignored. If this is particularly wanted though, it can be done.

I've elected to not fix the potential Array index out of bounds issues in this PR, as we're looking at spinning the scanArgs method out into a proper parsing class.

Note, these options override each other without warning (like most others) - the last one entered will override the previous. For example:

  • java -jar payara-micro.jar --requestTracingThresholdUnit DAYS --enableRequestTracing 1ns will enable request tracing, and set the threshold to 1 Nanosecond.
  • java -jar payara-micro.jar --enableRequestTracing 1ns --requestTracingThresholdUnit DAYS will enable request tracing, and set the threshold to 1 Day.

@smillidge
Copy link
Contributor

jenkins test please

@payara-ci
Copy link
Contributor

One or more tests have failed

@smillidge
Copy link
Contributor

jenkins test please

@payara-ci
Copy link
Contributor

All tests have passed

@smillidge smillidge merged commit deb2bd6 into payara:master Oct 24, 2016
@Pandrex247 Pandrex247 deleted the PAYARA-931-Payara-Micro-Request-tracing branch November 17, 2016 09:20
@OndroMih OndroMih added this to the Payara 4.1.1.164 milestone Nov 21, 2016
lprimak pushed a commit to flowlogix/Payara that referenced this pull request Jul 5, 2017
* PAYARA-931 Add in non-persistent request tracing to Payara Micro

* PAYARA-931 Rework to work with UberJar option

* PAYARA-931 Missed Help options

* PAYARA-931 Add in validation and allow lowercase. Also adds in required
entries to microdomain-nocluster.xml

* PAYARA-931 Correct message

* PAYARA-931 Add in extra unit validation, and add in convenience option

* PAYARA-931 Add help text

* PAYARA-931 Formatting

* PAYARA-931 Missed milliseconds

* PAYARA-931 Missed minutes!

* PAYARA-931 Shorthand minute

* PAYARA-931 Remove obsolete option, and rename new option in place.

* PAYARA-931 Formatting
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.

7 participants