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

[JENKINS-48344] Lightweight timestamp annotations #25

Merged
merged 16 commits into from
Feb 7, 2019

Conversation

jglick
Copy link
Member

@jglick jglick commented Sep 28, 2018

JENKINS-48344

Uses jenkinsci/workflow-job-plugin#105 (and its upstreams) to implement much cheaper timestamping for Pipeline builds. Produces log file output like

…
[2018-09-28T22:49:03.570Z] ^[[8mha:////etc.etc.^[[0m[Pipeline] sh
[2018-09-28T22:49:03.895Z] [p] Running shell script
[2018-09-28T22:49:04.427Z] + sleep 1
[2018-09-28T22:49:05.249Z] + sleep 1
[2018-09-28T22:49:06.262Z] + sleep 1
[2018-09-28T22:49:07.281Z] + sleep 1
[2018-09-28T22:49:08.298Z] + sleep 1
…

which gets rendered like

screenshot

No ConsoleNotes needed.

@jglick
Copy link
Member Author

jglick commented Sep 28, 2018

BTW this does not need #24. It could benefit from jenkinsci/jenkins#3662.

@jglick
Copy link
Member Author

jglick commented Sep 28, 2018

Some LogFileReaderTest regressions, probably just caused by updating some dep. Can look at it later.

Copy link
Member Author

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Oh and have not yet checked impact on

  • per-step logs
  • Blue Ocean

long buildStartTime = build.getStartTimeInMillis();
String html = text.toString(true);
int start;
if (html.startsWith("<span class=\"pipeline-new-node\" ")) { // cf. LogStorage.startStep
Copy link
Member Author

Choose a reason for hiding this comment

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

Unpleasant that this is necessary. Not sure if it is solvable upstream. You would probably expect that the MarkupText is what is produced before this span is added by FileLogStorage.

@jglick jglick changed the title [JENKINS-48344] Lightweight timestamp annotations [WiP] [JENKINS-48344] Lightweight timestamp annotations Sep 28, 2018
@jglick jglick changed the title [WiP] [JENKINS-48344] Lightweight timestamp annotations [JENKINS-48344] Lightweight timestamp annotations Oct 16, 2018
@jglick jglick changed the title [JENKINS-48344] Lightweight timestamp annotations [WiP] [JENKINS-48344] Lightweight timestamp annotations Oct 16, 2018
@jglick
Copy link
Member Author

jglick commented Oct 16, 2018

Per-step display in BO shows timestamps, since BO completely ignores ConsoleAnnotator and ConsoleNotes, but at least they are sort of human-readable:

screenshot

@jglick jglick changed the title [WiP] [JENKINS-48344] Lightweight timestamp annotations [JENKINS-48344] Lightweight timestamp annotations Oct 16, 2018
Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

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

Overall approach looks good to me, just added some java.time suggestions. The Blue Ocean view seems kind of awkward, do you think there is any easy way to clean it up? CC @vivek to see what he thinks of how it looks in Blue Ocean.

<java.level>7</java.level>
<revision>1.8.11</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.121.1</jenkins.version>
Copy link
Member

@dwnusbaum dwnusbaum Oct 22, 2018

Choose a reason for hiding this comment

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

Quite a jump, although required for the JEP-210 updates. Here are stats for the plugin's usage by Jenkins core version: http://stats.jenkins.io/pluginversions/timestamper.html. According to those stats, 89.63% of users of timestamper-1.8.10 are on Jenkins 2.121.1 or newer, so this looks reasonable to me.

@jglick
Copy link
Member Author

jglick commented Oct 24, 2018

The Blue Ocean view seems kind of awkward, do you think there is any easy way to clean it up?

Only by having Blue Ocean implement a custom display hook, like it did for ANSI coloration. Since BO ignores ConsoleNote and ConsoleAnnotatorFactory, without this patch there is no display of timestamps—so presumably BO-focused installations would not have been using this plugin to begin with. To my knowledge the BO rendering system is simply not extensible via plugins the way the classic UI is.

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

@StevenGBrown Would you be able to take a look at this please?

Copy link
Member

@olamy olamy left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@jetersen jetersen left a comment

Choose a reason for hiding this comment

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

LGTM

@jglick
Copy link
Member Author

jglick commented Jan 28, 2019

I have requested comaintainership of this plugin. According to policy, there is a two-week waiting period.

@jglick jglick merged commit 0e2fe42 into jenkinsci:master Feb 7, 2019
@jglick jglick deleted the lightweight-annotator-JENKINS-48344 branch February 7, 2019 20:26
jglick added a commit to jglick/workflow-job-plugin that referenced this pull request Feb 7, 2019
@jglick
Copy link
Member Author

jglick commented Feb 7, 2019

Possible casualty (untested): TimestamperAPI.read, used by at least aws-cloudwatch-logs-publisher (though that now has an alternative in pipeline-cloudwatch-logs anyway).

@dankirkd
Copy link

dankirkd commented Feb 8, 2019

@jglick Can you indicate how to use the plugin in a Jenkinsfile via the "global option", as opposed to having to wrap blocks within each of the "steps"? I can't find any example of that, and have tried to get an answer from @StevenGBrown on https://wiki.jenkins.io/pages/viewpage.action?pageId=46334448 with no success.

@jglick
Copy link
Member Author

jglick commented Feb 8, 2019

how to use the plugin in a Jenkinsfile via the "global option"

You do not—it is global configuration (whether specified in the UI or configuration-as-code or whatever).

@dankirkd
Copy link

dankirkd commented Feb 8, 2019

What is the default setting on the "all pipelines" config? Is it set by default?

@jglick
Copy link
Member Author

jglick commented Feb 8, 2019

What is the default setting on the "all pipelines" config? Is it set by default?

No, it is off by default, to minimize the behavioral change caused by merely updating the plugin.

@alde
Copy link

alde commented Feb 18, 2019

It seems to me that hitting /timestamps/?time=%27HH:mm:ss%27&appendLog no longer has any effect, as the result is identical to hitting /consoleText.

Could this be a side-effect of this change?

@jglick
Copy link
Member Author

jglick commented Feb 18, 2019

@alde quite possibly. I am unaware of that URL pattern or what it is supposed to do.

@dankirkd
Copy link

@alde Try /timestamps/?time=HH:mm:ss&appendLog as that seems to work fine for me with version 1.8

@jglick It is just outputs the timestamp and with appendLog appends the text that goes with it - effectively looks like consoleText with a timestamp.

@alde
Copy link

alde commented Feb 19, 2019

With version 1.9 nothing I put in time={} has any effect anymore. I'll look at whether downgrading to 1.8 will have an effect. Anyhow, this may be an indication of a regression.
In 1.9 both /timestamps/?time=HH:mm:ss&appendLog and /consoleText output lines like

[2019-02-18T11:40:12.626Z] [WS-CLEANUP] Deleting project workspace...

@jglick
Copy link
Member Author

jglick commented Feb 19, 2019

I see, there are some scripting URLs which apparently have no test coverage. As noted in #25 (comment) there is also a Java API which I think has no test coverage. Probably needs some follow-up work to write proper test cases for all these things and make any adjustments needed for them to work with the new architecture.

@j3p0uk
Copy link

j3p0uk commented Apr 29, 2020

@jglick I think this has had a pretty serious side-effect on folks using timestamped, where the consoleText url now has timestamps, whereas before the raw text api url was timestamps.

I was using the consoleText for multi-line parsing for numerous elements, which has been broken by this change.

Is there a way to get the raw console text without the timestamps from the API?

@jglick
Copy link
Member Author

jglick commented Apr 29, 2020

Is there a way to get the raw console text without the timestamps from the API?

Not currently. IIRC there is a filed RFE for it.

@basil
Copy link
Member

basil commented Apr 29, 2020

A cheap workaround could be to set the format to the empty string (id est, /timestamps/?time=&appendLog). That will still print the separator at the beginning of each line, but it might be better than nothing.

@j3p0uk
Copy link

j3p0uk commented Apr 29, 2020

A cheap workaround could be to set the format to the empty string (id est, /timestamps/?time=&appendLog). That will still print the separator at the beginning of each line, but it might be better than nothing.

Unfortunately that doesn't work, as the timestamps are now persisted in the on-disk log:

  [Pipeline] { (Checkout Build Sources)
  [Pipeline] checkout
  [2020-04-29T13:03:20.725Z] using credential ---
  [2020-04-29T13:03:20.738Z] Cloning the remote Git repository

@basil
Copy link
Member

basil commented Apr 29, 2020

That should be fixed as of 1.11.1 (see JENKINS-60007).

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.

10 participants