Skip to content

Commit

Permalink
Fix #5
Browse files Browse the repository at this point in the history
  • Loading branch information
amarkelov committed Mar 7, 2018
1 parent 25bc363 commit 31eae4d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ru.andreymarkelov.atlas.plugins</groupId>
<artifactId>prom-bitbucket-exporter</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<packaging>atlassian-plugin</packaging>

<name>Prometheus Exporter For Bitbucket</name>
Expand Down Expand Up @@ -153,7 +153,7 @@
<properties>
<bitbucket.version>4.0.0-m27</bitbucket.version>
<bitbucket.data.version>${bitbucket.version}</bitbucket.data.version>
<amps.version>6.3.6</amps.version>
<amps.version>6.3.15</amps.version>
<prometheus.version>0.2.0</prometheus.version>
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.atlassian.bitbucket.event.auth.AuthenticationFailureEvent;
import com.atlassian.bitbucket.event.auth.AuthenticationSuccessEvent;
import com.atlassian.bitbucket.event.pull.PullRequestDeclinedEvent;
import com.atlassian.bitbucket.event.pull.PullRequestMergedEvent;
import com.atlassian.bitbucket.event.pull.PullRequestOpenedEvent;
import com.atlassian.bitbucket.event.repository.RepositoryPushEvent;
import com.atlassian.event.api.EventListener;
import ru.andreymarkelov.atlas.plugins.prombitbucketexporter.manager.MetricCollector;
Expand All @@ -18,11 +21,29 @@ public MetricListener(MetricCollector metricCollector) {
@EventListener
public void repositoryPushEvent(RepositoryPushEvent repositoryPushEvent) {
metricCollector.pushCounter(
repositoryPushEvent.getRepository().getProject().getKey(),
repositoryPushEvent.getRepository().getName(),
repositoryPushEvent.getUser() != null ? repositoryPushEvent.getUser().getName() : "unknown"
);
}

//--> Pull Requests

@EventListener
public void pullRequestOpenedEvent(PullRequestOpenedEvent pullRequestOpenedEvent) {

}

@EventListener
public void pullRequestMergedEvent(PullRequestMergedEvent pullRequestMergedEvent) {

}

@EventListener
public void pullRequestDeclinedEvent(PullRequestDeclinedEvent pullRequestDeclinedEvent) {

}

//--> Auth events

@EventListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public interface MetricCollector {
Collector getCollector();
void successAuthCounter(String username);
void failedAuthCounter(String username);
void pushCounter(String repository, String username);
void pushCounter(String project, String repository, String username);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public MetricCollectorImpl(
private final Counter pushCounter = Counter.build()
.name("bitbucket_repo_push_count")
.help("Repository Pushes Count")
.labelNames("repository", "username")
.labelNames("project", "repository", "username")
.create();

@Override
Expand All @@ -71,8 +71,8 @@ public void failedAuthCounter(String username) {
}

@Override
public void pushCounter(String repository, String username) {
pushCounter.labels(repository, username).inc();
public void pushCounter(String project, String repository, String username) {
pushCounter.labels(project, repository, username).inc();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
package ru.andreymarkelov.atlas.plugins.prombitbucketexporter.manager;

public class ScheduledMetricEvaluatorImpl implements ScheduledMetricEvaluator {
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class ScheduledMetricEvaluatorImpl implements ScheduledMetricEvaluator, DisposableBean, InitializingBean {
private static final Logger log = LoggerFactory.getLogger(ScheduledMetricEvaluator.class);

@Override
public void destroy() throws Exception {
log.info("Stop");
}

@Override
public void afterPropertiesSet() throws Exception {
log.info("Start");
}
}
3 changes: 3 additions & 0 deletions src/main/resources/atlassian-plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<component name="Security Token Data Manager" key="prom-for-bitbucket-exporter-data-manager" class="ru.andreymarkelov.atlas.plugins.prombitbucketexporter.manager.SecureTokenManagerImpl">
<interface>ru.andreymarkelov.atlas.plugins.prombitbucketexporter.manager.SecureTokenManager</interface>
</component>
<component name="Scheduled Metrics Evaluator" key="prom-for-bitbucket-exporter-evaluator" class="ru.andreymarkelov.atlas.plugins.prombitbucketexporter.manager.ScheduledMetricEvaluatorImpl">
<interface>ru.andreymarkelov.atlas.plugins.prombitbucketexporter.manager.ScheduledMetricEvaluator</interface>
</component>

<!-- Component Imports -->
<component-import key="pluginSettingsFactory" interface="com.atlassian.sal.api.pluginsettings.PluginSettingsFactory"/>
Expand Down

0 comments on commit 31eae4d

Please sign in to comment.