GithubHelp home page GithubHelp logo

lucaprete / gerrit-counter Goto Github PK

View Code? Open in Web Editor NEW
0.0 4.0 0.0 44 KB

Gerrit clones counter enables you to publish number of clones from a certain repository

License: Apache License 2.0

Java 100.00%

gerrit-counter's Introduction

Gerrit-counter Gerrit plugin

Description

The plugin allows to track the number of clones, fetches and pulls operations for one or more Gerrit repositories on a PostreSQL database.

The user can activate the plugin either for all the Gerrit repositories or for just for few of them. The user can also choose custom DB name and table structures.

Supported Gerrit versions

Database requirements

The database needs to be a PostgreSQL database, version 9.X. It's required a table made of three or more columns, depending on what the user want to keep track of. Here is the list of the columns needed:

  • date (mandatory): to register the date for a certain action. The column must be of type date.
  • repository (mandatory): to keep track of the specific repository name. It must be of type varchar.
  • clones-counter (optional): in case the user want to keep track of the number of repositories clones. It must be of type integer.
  • updates-counter (optional): in case the user want to keep track of the number of repositories updates (fetches, pull operations). The column must be of type integer.

It's strongly suggested to use as the primary key the date and the repository fields.

Plugin configuration

In order to configure the plugin, the user should create a dedicated subsection in the gerrit.config configuration file. Each time the configuration is modified, either Gerrit need to be restarted or the plugin must be reloaded in order for it to parse the new configuration.

To start the plugin configuration block create a line in gerrit.config like the following:

[plugin "gerrit counter"]

Following parameters must be inserted below the specific plugin section in the gerrit.config.

  • Timezone. Specify the timezone you want to use to save the entries in the database. The default value is GMT.

    timezone = America/Los_Angeles
    
  • Active Trackers. The parameter is mandatory. It allow you to specify what behavior a user want to monitor. It's a comma separated values list. For example, if you want to monitor the number of clones repositories specify clone, if you want to monitor also the number of fetches and pulls specify update. You can also specify both, as in the example below.

    activeTrackers = clone,update
    
  • Active Repos. The user can specifiy a list of repository to be tracked. If no repositories are specified, by default all the repositories will be tracked. Please, provide a comma separated value of repository names. For example,

    activeRepos = repoOne,repoTwo,repoThree
    
  • Database address:

    dbUrl = db.example.com
    
  • Database port:

    dbPort = 5432
    
  • Database user:

    dbUser = admin
    
  • Database password.

    dbPass = pass
    
  • Application table. The table used in SQL by the application. For example,

    dbTable = my-db-table
    
  • Date field name. Name of the column used in the SQL table to keep track of the dates. For example,

    dbDateCol = date
    
  • Clones Counter DB column name. Name of the column used in the SQL table to keep track of the number of clones. For example,

dbClonesCounterCol = clones
  • Updates Counter DB column name. Name of the column used in the SQL table to keep track of the number of updates. (fetches and pulls). For example,
dbUpdatesCounterCol = updates
  • Repository field name. Name of the column used in the SQL table to keep track of the repository name. For example,

    dbRepoCol = repo
    

Configuration example

Below it's reported an example of a typical plugin configuration. The example uses all the parameters currently supported. Please, refer to the guide above to see what are the default values and behaviors if a parameter is not specified.

[plugin "gerrit-counter"]
        timzone = America/LosAngeles
        dbUrl = db.example.com
        dbPort = 5432
        dbUser = admin
        dbPass = mypass
        dbName = gerrit-counter-db
        dbTable = counter-table
        dbDateCol = date
        dbClonesCounterCol = clones
        dbUpdatesCounterCol = upadtes
        dbRepoCol = repo

Default values

Providing a configuration it's not necessarily need. If not parameters are found, by default the application use the following values/behaviors. Even if it's not mentioned below, by default all the repositories are tracked if no parameters are specified in activeRepos, and no operations are tracked if no parameters are specified under activeTrackers.

[plugin "gerrit-counter"]
        dbUrl = 127.0.0.1
        dbPort = 5432
        dbUser = admin
        dbPass = pass
        dbName = default-db
        dbTable = default-table
        dbDateCol = date
        dbClonesCounterCol = clones
        dbUpdatesCounterCol = updates
        dbRepoCol = repos

gerrit-counter's People

Contributors

bocon13 avatar lucaprete avatar

Watchers

 avatar  avatar  avatar  avatar

gerrit-counter's Issues

Plugin throws exception blocking pulls/clones

[2015-03-16 09:26:48,050] WARN / : Internal error during upload-pack
java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 30001/30000 ms
at org.eclipse.jetty.util.SharedBlockingCallback$Blocker.block(SharedBlockingCallback.java:216)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:128)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:370)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122)
at org.eclipse.jgit.util.TemporaryBuffer.write(TemporaryBuffer.java:138)
at org.eclipse.jgit.transport.SideBandOutputStream.writeBuffer(SideBandOutputStream.java:171)
at org.eclipse.jgit.transport.SideBandOutputStream.write(SideBandOutputStream.java:151)
at org.eclipse.jgit.internal.storage.pack.PackOutputStream.write(PackOutputStream.java:126)
at org.eclipse.jgit.internal.storage.file.PackFile.copyAsIs2(PackFile.java:519)
at org.eclipse.jgit.internal.storage.file.PackFile.copyAsIs(PackFile.java:357)
at org.eclipse.jgit.internal.storage.file.WindowCursor.copyObjectAsIs(WindowCursor.java:190)
at org.eclipse.jgit.internal.storage.pack.PackWriter.writeObjectImpl(PackWriter.java:1515)
at org.eclipse.jgit.internal.storage.pack.PackWriter.writeBase(PackWriter.java:1557)
at org.eclipse.jgit.internal.storage.pack.PackWriter.writeObjectImpl(PackWriter.java:1508)
at org.eclipse.jgit.internal.storage.pack.PackWriter.writeObject(PackWriter.java:1492)
at org.eclipse.jgit.internal.storage.pack.PackOutputStream.writeObject(PackOutputStream.java:164)
at org.eclipse.jgit.internal.storage.file.WindowCursor.writeObjects(WindowCursor.java:196)
at org.eclipse.jgit.internal.storage.pack.PackWriter.writeObjects(PackWriter.java:1480)
at org.eclipse.jgit.internal.storage.pack.PackWriter.writeObjects(PackWriter.java:1468)
at org.eclipse.jgit.internal.storage.pack.PackWriter.writePack(PackWriter.java:1036)
at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1417)
at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1271)
at org.eclipse.jgit.transport.UploadPack.service(UploadPack.java:717)
at org.eclipse.jgit.transport.UploadPack.upload(UploadPack.java:628)
at org.eclipse.jgit.http.server.UploadPackServlet.doPost(UploadPackServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.eclipse.jgit.http.server.glue.UrlPipeline$Chain.doFilter(UrlPipeline.java:237)
at com.google.gerrit.httpd.GitOverHttpServlet$UploadFilter.doFilter(GitOverHttpServlet.java:253)
at org.eclipse.jgit.http.server.glue.UrlPipeline$Chain.doFilter(UrlPipeline.java:235)
at org.eclipse.jgit.http.server.UploadPackServlet$Factory.doFilter(UploadPackServlet.java:145)
at org.eclipse.jgit.http.server.glue.UrlPipeline$Chain.doFilter(UrlPipeline.java:235)
at org.eclipse.jgit.http.server.RepositoryFilter.doFilter(RepositoryFilter.java:151)
at org.eclipse.jgit.http.server.glue.UrlPipeline$Chain.doFilter(UrlPipeline.java:235)
at org.eclipse.jgit.http.server.NoCacheFilter.doFilter(NoCacheFilter.java:80)
at org.eclipse.jgit.http.server.glue.UrlPipeline$Chain.doFilter(UrlPipeline.java:235)
at org.eclipse.jgit.http.server.glue.UrlPipeline.service(UrlPipeline.java:215)
at org.eclipse.jgit.http.server.glue.SuffixPipeline.service(SuffixPipeline.java:101)
at org.eclipse.jgit.http.server.glue.MetaFilter.doFilter(MetaFilter.java:175)
at org.eclipse.jgit.http.server.glue.MetaServlet.service(MetaServlet.java:133)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:279)
at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:269)
at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:180)
at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:85)
at com.google.gwtexpui.server.CacheControlFilter.doFilter(CacheControlFilter.java:70)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.google.gerrit.httpd.RunAsFilter.doFilter(RunAsFilter.java:113)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.google.gerrit.httpd.RequireSslFilter.doFilter(RequireSslFilter.java:68)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.google.gerrit.httpd.ProjectDigestFilter.doFilter(ProjectDigestFilter.java:107)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.google.gerrit.httpd.AllRequestFilter$FilterProxy$1.doFilter(AllRequestFilter.java:64)
at com.google.gerrit.httpd.AllRequestFilter$FilterProxy.doFilter(AllRequestFilter.java:57)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.google.gerrit.httpd.RequestContextFilter.doFilter(RequestContextFilter.java:75)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.google.gerrit.pgm.http.jetty.ProjectQoSFilter.doFilter(ProjectQoSFilter.java:132)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:119)
at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:133)
at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:130)
at com.google.inject.servlet.GuiceFilter$Context.call(GuiceFilter.java:203)
at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:130)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1636)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:564)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:219)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1111)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:498)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1045)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:98)
at org.eclipse.jetty.server.Server.handleAsync(Server.java:518)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:291)
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:241)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.TimeoutException: Idle timeout expired: 30001/30000 ms
at org.eclipse.jetty.io.IdleTimeout.checkIdleTimeout(IdleTimeout.java:154)
at org.eclipse.jetty.io.IdleTimeout$1.run(IdleTimeout.java:50)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
... 1 more
[2015-03-16 10:11:16,659] ERROR com.googlesource.gerrit.plugins.gerritcounter.DBConnection : ERROR: null value in column "clones" violates not-null constraint
Detail: Failing row contains (2015-03-16, null, spring-open, 1).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.