Skip to content

Commit 5b62fd1

Browse files
committed
metrics
1 parent 207b472 commit 5b62fd1

12 files changed

+294
-322
lines changed

pkg/monitoring/ConsumerStarted.php

-23
This file was deleted.

pkg/monitoring/ConsumerStats.php

+152-8
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,48 @@
44

55
namespace Enqueue\Monitoring;
66

7-
class ConsumerStats extends Event
7+
class ConsumerStats implements Stats
88
{
99
/**
10-
* @var string[]
10+
* @var string
1111
*/
12-
protected $queues;
12+
protected $consumerId;
13+
14+
/**
15+
* @var int
16+
*/
17+
protected $timestampMs;
1318

1419
/**
1520
* @var int
1621
*/
1722
protected $startedAtMs;
1823

24+
/**
25+
* @var int
26+
*/
27+
protected $finishedAtMs;
28+
29+
/**
30+
* @var bool
31+
*/
32+
protected $started;
33+
34+
/**
35+
* @var bool
36+
*/
37+
protected $finished;
38+
39+
/**
40+
* @var bool
41+
*/
42+
protected $failed;
43+
44+
/**
45+
* @var string[]
46+
*/
47+
protected $queues;
48+
1949
/**
2050
* @var int
2151
*/
@@ -46,19 +76,66 @@ class ConsumerStats extends Event
4676
*/
4777
protected $systemLoad;
4878

79+
/**
80+
* @var string
81+
*/
82+
protected $errorClass;
83+
84+
/**
85+
* @var string
86+
*/
87+
protected $errorMessage;
88+
89+
/**
90+
* @var int
91+
*/
92+
protected $errorCode;
93+
94+
/**
95+
* @var string
96+
*/
97+
protected $errorFile;
98+
99+
/**
100+
* @var int
101+
*/
102+
protected $errorLine;
103+
104+
/**
105+
* @var string
106+
*/
107+
protected $trance;
108+
49109
public function __construct(
50110
string $consumerId,
51111
int $timestampMs,
52-
array $queues,
53112
int $startedAtMs,
113+
?int $finishedAtMs,
114+
bool $started,
115+
bool $finished,
116+
bool $failed,
117+
array $queues,
54118
int $received,
55119
int $acknowledged,
56120
int $rejected,
57121
int $requeued,
58122
int $memoryUsage,
59-
float $systemLoad
123+
float $systemLoad,
124+
string $errorClass = null,
125+
string $errorMessage = null,
126+
int $errorCode = null,
127+
string $errorFile = null,
128+
int $errorLine = null,
129+
string $trace = null
60130
) {
61-
parent::__construct($consumerId, $timestampMs);
131+
$this->consumerId = $consumerId;
132+
$this->timestampMs = $timestampMs;
133+
$this->startedAtMs = $startedAtMs;
134+
$this->finishedAtMs = $finishedAtMs;
135+
136+
$this->started = $started;
137+
$this->finished = $finished;
138+
$this->failed = $failed;
62139

63140
$this->queues = $queues;
64141
$this->startedAtMs = $startedAtMs;
@@ -69,18 +146,55 @@ public function __construct(
69146

70147
$this->memoryUsage = $memoryUsage;
71148
$this->systemLoad = $systemLoad;
149+
150+
$this->errorClass = $errorClass;
151+
$this->errorMessage = $errorMessage;
152+
$this->errorCode = $errorCode;
153+
$this->errorFile = $errorFile;
154+
$this->errorLine = $errorLine;
155+
$this->trance = $trace;
72156
}
73157

74-
public function getQueues(): array
158+
public function getConsumerId(): string
75159
{
76-
return $this->queues;
160+
return $this->consumerId;
161+
}
162+
163+
public function getTimestampMs(): int
164+
{
165+
return $this->timestampMs;
77166
}
78167

79168
public function getStartedAtMs(): int
80169
{
81170
return $this->startedAtMs;
82171
}
83172

173+
public function getFinishedAtMs(): ?int
174+
{
175+
return $this->finishedAtMs;
176+
}
177+
178+
public function isStarted(): bool
179+
{
180+
return $this->started;
181+
}
182+
183+
public function isFinished(): bool
184+
{
185+
return $this->finished;
186+
}
187+
188+
public function isFailed(): bool
189+
{
190+
return $this->failed;
191+
}
192+
193+
public function getQueues(): array
194+
{
195+
return $this->queues;
196+
}
197+
84198
public function getReceived(): int
85199
{
86200
return $this->received;
@@ -110,4 +224,34 @@ public function getSystemLoad(): float
110224
{
111225
return $this->systemLoad;
112226
}
227+
228+
public function getErrorClass(): ?string
229+
{
230+
return $this->errorClass;
231+
}
232+
233+
public function getErrorMessage(): ?string
234+
{
235+
return $this->errorMessage;
236+
}
237+
238+
public function getErrorCode(): ?int
239+
{
240+
return $this->errorCode;
241+
}
242+
243+
public function getErrorFile(): ?string
244+
{
245+
return $this->errorFile;
246+
}
247+
248+
public function getErrorLine(): ?int
249+
{
250+
return $this->errorLine;
251+
}
252+
253+
public function getTrance(): ?string
254+
{
255+
return $this->trance;
256+
}
113257
}

0 commit comments

Comments
 (0)