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 Logz.io support #74

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open

Add Logz.io support #74

wants to merge 57 commits into from

Conversation

idohalevi
Copy link

No description provided.

@idohalevi
Copy link
Author

Is it a must to support Java7 before merging?

@jakub-bochenski
Copy link

I'll do my best to merge #70 ASAP, in the meantime you can just rebase your branch over that one

@idohalevi
Copy link
Author

idohalevi commented Sep 12, 2018

@mwinter69 @jakub-bochenski Done. I did find a problem with Collections.synchronizedList when I tested with 2 parallel builds I got an exception java.util.ConcurrentModificationException. The cause for it is the iterator in the function sizeInBytes from the logzio sender. If it's ok I would like to use CopyOnWriteArrayList instead as it looks like it fixes the issue

@jakub-bochenski
Copy link

@idohalevi I don't think synchronizing on the list is enough
You can still get problems e.g if one thread calls send() while the other is in the middle of clear() we can get lost messages.

I see two approaches here:

  • make all mutating methods synchronized
  • use a new instance for each build

One more problem I see with reusing the instance is: if an un-sendable message (one that is causing an exception in sendToLogzio) gets into the list it will be stuck there permanently blocking all builds from sending data.

@idohalevi
Copy link
Author

@jakub-bochenski @mwinter69
I will work on making a shipper per build. One question, how will you suggest I should handle closing shippers? is there a way I can know that the build is over? maybe I can rely on the success/fail results?

@jakub-bochenski
Copy link

@idohalevi follow the changes here: https://github.com/jenkinsci/logstash-plugin/pull/71/files#diff-bddec744c0206f7f355a27d666bfda1f
in #71 the author has added a close() method to be able to finalize processing

HananEgbaria and others added 7 commits January 30, 2019 10:40
…into dev

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
update from upstream
@idohalevi
Copy link
Author

@jakub-bochenski Done:) --- sorry for taking the time to handle this...

@jakub-bochenski
Copy link

No worries, thanks for taking the time to finish it

pom.xml Outdated Show resolved Hide resolved
@jakub-bochenski
Copy link

This shouldn't include the whole of #71, please just add the part required for the close() method

@idohalevi
Copy link
Author

@jakub-bochenski
Thank you for the quick reply.
Will work on it and get back to you

* return any cached but non-sent data back for persisting.
* The return value of script is the payload to be persisted unless null.
*/
public class LogstashScriptProcessor implements LogstashPayloadProcessor{

Choose a reason for hiding this comment

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

I don't think you need this implmentation, just the interface

Choose a reason for hiding this comment

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

Even the interface is not needed. Actually the complete #71 should be taken out of here.

Choose a reason for hiding this comment

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

We need a close hook for the build. It's not available on master, so I suggested to use the same approach as #71

Choose a reason for hiding this comment

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

What helps an interface when there is no implementation?
The close is added to the LogstashWriter in order to properly terminate the LogstashPayloadProcessor.
#71 modifies the ConsoleLogFilter to add the PayloadProcessor to the LogstashWriter.
There is nothing comparable here.

Copy link
Author

Choose a reason for hiding this comment

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

How do you suggest we should continue with this?

Choose a reason for hiding this comment

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

Let me try to explain again.
This code needs to perform actions on build close as per #74 (comment)
AFAIK we have currently no way to notify an IndexerDao that a build has finished.
#71 added a way to do it, so I suggested to reuse the same approach.

Maybe at this point the best way to proceed is to forget about #71 and just add a way to notify the IndexerDao.
We can worry about the overlap with #71 when/if it's merged

Copy link

@mwinter69 mwinter69 Mar 27, 2019

Choose a reason for hiding this comment

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

#71 added a feature to close the LogstashWriter, which is specific to a build but it is not interacting with the Dao as the scriptprocessor is only used in the writer.
The dao is a kind of a singleton in Jenkins. We only create a new Dao, when we have a configuration change and the new will only be used for new builds.
If I understand it right the shipper has to be used in the dao. So when the writer calls dao.push which does the actual writing to the indexer, how does the dao know which shipper to use? I don't see any nice solution here other than having a dao per build. But this would be a change in concept how this plugin is working. The writer would hold the reference to the dao and can be easily closed.
This is a bigger change in how the plugin works.
But even then one will need synchronization as in pipeline jobs you also have parallel execution within a single build and thus concurrent calls to the list.

Choose a reason for hiding this comment

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

Sorry, I think I meant the LogstashWriter instead of IndexerDao
The idea is to create a new shipper instance per build to avoid concurrency issues. Not sure if that would work for parallel stages in pipeline though.

On a different note: I'm rather busy lately and don't want to block it. I would be happy to accept whatever solution you and @idohalevi can agree on

Copy link
Author

Choose a reason for hiding this comment

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

@jakub-bochenski @mwinter69
How do you suggest to continue?

* @param payload the JSON payload that has been constructed so far.
* @return The formatted JSON object, can be null to ignore this payload.
*/
JSONObject process(JSONObject payload) throws Exception;

Choose a reason for hiding this comment

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

I think we actually only need the finish() method, not process().

Copy link
Author

Choose a reason for hiding this comment

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

@jakub-bochenski
Currently, finish() uses process(). How would you like it to be instead?

Choose a reason for hiding this comment

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

AFAIR finish only uses process to call it with null arg. Anyhow check the comment above (#74 (comment)) it might make this point moot

@jakub-bochenski
Copy link

I think it's still pulling in too much. Maybe an easier approach would be to take your original version and try to pick the needed changes onto it from scratch instead of trying to modify current state.
Let me know if you need help here

}
}

Choose a reason for hiding this comment

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

Please revert the complete file to its original state. You just changed indentation.

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.

5 participants