Skip to content

Commit e11a72c

Browse files
committed
metrics
0 parents  commit e11a72c

17 files changed

+974
-0
lines changed

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/Tests export-ignore
2+
.gitattributes export-ignore
3+
.gitignore export-ignore
4+
.travis.yml export-ignore
5+
phpunit.xml.dist export-ignore

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*~
2+
/composer.lock
3+
/composer.phar
4+
/phpunit.xml
5+
/vendor/
6+
/.idea/

.travis.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
sudo: false
2+
3+
git:
4+
depth: 10
5+
6+
language: php
7+
8+
php:
9+
- '7.1'
10+
- '7.2'
11+
12+
cache:
13+
directories:
14+
- $HOME/.composer/cache
15+
16+
install:
17+
- composer self-update
18+
- composer install
19+
20+
script:
21+
- vendor/bin/phpunit --exclude-group=functional

ConsumerStarted.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Enqueue\Monitoring;
6+
7+
class ConsumerStarted extends Event
8+
{
9+
/**
10+
* @var string[]
11+
*/
12+
protected $queues;
13+
14+
public function __construct(
15+
string $consumerId,
16+
int $timestampMs,
17+
array $queues
18+
) {
19+
parent::__construct($consumerId, $timestampMs);
20+
21+
$this->queues = $queues;
22+
}
23+
}

ConsumerStats.php

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Enqueue\Monitoring;
6+
7+
class ConsumerStats extends Event
8+
{
9+
/**
10+
* @var string[]
11+
*/
12+
protected $queues;
13+
14+
/**
15+
* @var int
16+
*/
17+
protected $startedAtMs;
18+
19+
/**
20+
* @var int
21+
*/
22+
protected $received;
23+
24+
/**
25+
* @var int
26+
*/
27+
protected $acknowledged;
28+
29+
/**
30+
* @var int
31+
*/
32+
protected $rejected;
33+
34+
/**
35+
* @var int
36+
*/
37+
protected $requeued;
38+
39+
/**
40+
* @var int
41+
*/
42+
protected $memoryUsage;
43+
44+
/**
45+
* @var float
46+
*/
47+
protected $systemLoad;
48+
49+
public function __construct(
50+
string $consumerId,
51+
int $timestampMs,
52+
array $queues,
53+
int $startedAtMs,
54+
int $received,
55+
int $acknowledged,
56+
int $rejected,
57+
int $requeued,
58+
int $memoryUsage,
59+
float $systemLoad
60+
) {
61+
parent::__construct($consumerId, $timestampMs);
62+
63+
$this->queues = $queues;
64+
$this->startedAtMs = $startedAtMs;
65+
$this->received = $received;
66+
$this->acknowledged = $acknowledged;
67+
$this->rejected = $rejected;
68+
$this->requeued = $requeued;
69+
70+
$this->memoryUsage = $memoryUsage;
71+
$this->systemLoad = $systemLoad;
72+
}
73+
74+
public function getQueues(): array
75+
{
76+
return $this->queues;
77+
}
78+
79+
public function getStartedAtMs(): int
80+
{
81+
return $this->startedAtMs;
82+
}
83+
84+
public function getReceived(): int
85+
{
86+
return $this->received;
87+
}
88+
89+
public function getAcknowledged(): int
90+
{
91+
return $this->acknowledged;
92+
}
93+
94+
public function getRejected(): int
95+
{
96+
return $this->rejected;
97+
}
98+
99+
public function getRequeued(): int
100+
{
101+
return $this->requeued;
102+
}
103+
104+
public function getMemoryUsage(): int
105+
{
106+
return $this->memoryUsage;
107+
}
108+
109+
public function getSystemLoad(): float
110+
{
111+
return $this->systemLoad;
112+
}
113+
}

ConsumerStopped.php

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Enqueue\Monitoring;
6+
7+
class ConsumerStopped extends Event
8+
{
9+
/**
10+
* @var string[]
11+
*/
12+
protected $queues;
13+
14+
/**
15+
* @var int
16+
*/
17+
protected $startedAtMs;
18+
19+
/**
20+
* @var int
21+
*/
22+
protected $received;
23+
24+
/**
25+
* @var int
26+
*/
27+
protected $acknowledged;
28+
29+
/**
30+
* @var int
31+
*/
32+
protected $rejected;
33+
34+
/**
35+
* @var int
36+
*/
37+
protected $requeued;
38+
39+
/**
40+
* @var string
41+
*/
42+
protected $errorClass;
43+
44+
/**
45+
* @var string
46+
*/
47+
protected $errorMessage;
48+
49+
/**
50+
* @var int
51+
*/
52+
protected $errorCode;
53+
54+
/**
55+
* @var string
56+
*/
57+
protected $errorFile;
58+
59+
/**
60+
* @var int
61+
*/
62+
protected $errorLine;
63+
64+
/**
65+
* @var string
66+
*/
67+
protected $trance;
68+
69+
public function __construct(
70+
string $consumerId,
71+
int $timestampMs,
72+
array $queues,
73+
int $startedAtMs,
74+
int $received,
75+
int $acknowledged,
76+
int $rejected,
77+
int $requeued,
78+
string $errorClass = null,
79+
string $errorMessage = null,
80+
int $errorCode = null,
81+
string $errorFile = null,
82+
int $errorLine = null,
83+
string $trace = null
84+
) {
85+
parent::__construct($consumerId, $timestampMs);
86+
87+
$this->queues = $queues;
88+
$this->startedAtMs = $startedAtMs;
89+
$this->received = $received;
90+
$this->acknowledged = $acknowledged;
91+
$this->rejected = $rejected;
92+
$this->requeued = $requeued;
93+
94+
$this->errorClass = $errorClass;
95+
$this->errorMessage = $errorMessage;
96+
$this->errorCode = $errorCode;
97+
$this->errorFile = $errorFile;
98+
$this->errorLine = $errorLine;
99+
$this->trance = $trace;
100+
}
101+
102+
public function getQueues(): array
103+
{
104+
return $this->queues;
105+
}
106+
107+
public function getStartedAtMs(): int
108+
{
109+
return $this->startedAtMs;
110+
}
111+
112+
public function getReceived(): int
113+
{
114+
return $this->received;
115+
}
116+
117+
public function getAcknowledged(): int
118+
{
119+
return $this->acknowledged;
120+
}
121+
122+
public function getRejected(): int
123+
{
124+
return $this->rejected;
125+
}
126+
127+
public function getRequeued(): int
128+
{
129+
return $this->requeued;
130+
}
131+
132+
public function getErrorClass(): ?string
133+
{
134+
return $this->errorClass;
135+
}
136+
137+
public function getErrorMessage(): ?string
138+
{
139+
return $this->errorMessage;
140+
}
141+
142+
public function getErrorCode(): ?int
143+
{
144+
return $this->errorCode;
145+
}
146+
147+
public function getErrorFile(): ?string
148+
{
149+
return $this->errorFile;
150+
}
151+
152+
public function getErrorLine(): ?int
153+
{
154+
return $this->errorLine;
155+
}
156+
157+
public function getTrance(): ?string
158+
{
159+
return $this->trance;
160+
}
161+
}

Event.php

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Enqueue\Monitoring;
6+
7+
class Event
8+
{
9+
/**
10+
* @var string
11+
*/
12+
protected $consumerId;
13+
14+
/**
15+
* @var int
16+
*/
17+
protected $timestampMs;
18+
19+
public function __construct(string $consumerId, int $timestampMs)
20+
{
21+
$this->consumerId = $consumerId;
22+
$this->timestampMs = $timestampMs;
23+
}
24+
25+
public function getConsumerId(): string
26+
{
27+
return $this->consumerId;
28+
}
29+
30+
public function getTimestampMs(): int
31+
{
32+
return $this->timestampMs;
33+
}
34+
}

EventStorage.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Enqueue\Monitoring;
6+
7+
interface EventStorage
8+
{
9+
public function onConsumerStarted(ConsumerStarted $event);
10+
11+
public function onConsumerStopped(ConsumerStopped $event);
12+
13+
public function onConsumerStats(ConsumerStats $event);
14+
15+
public function onMessageStats(MessageStats $event);
16+
}

0 commit comments

Comments
 (0)