2020
2121package metrics
2222
23- // MetricName is the name of the metric
24- type MetricName string
25-
26- // MetricType is the type of the metric, which can be one of the 3 below
27- type MetricType int
28-
29- // MetricTypes which are supported
30- const (
31- Counter MetricType = iota
32- Timer
33- Gauge
34- )
35-
36- // Common tags for all services
37- const (
38- HostnameTagName = "hostname"
39- OperationTagName = "operation"
40- )
41-
42- // This package should hold all the metrics and tags for cherami
43- const (
44- UnknownDirectoryTagValue = "Unknown"
45- )
46-
47- // Common service base metrics
48- const (
49- RestartCount = "restarts"
50- NumGoRoutinesGauge = "num-goroutines"
51- GoMaxProcsGauge = "gomaxprocs"
52- MemoryAllocatedGauge = "memory.allocated"
53- MemoryHeapGauge = "memory.heap"
54- MemoryHeapIdleGauge = "memory.heapidle"
55- MemoryHeapInuseGauge = "memory.heapinuse"
56- MemoryStackGauge = "memory.stack"
57- NumGCCounter = "memory.num-gc"
58- GcPauseMsTimer = "memory.gc-pause-ms"
59- )
60-
6123// Workflow Creation metrics
6224const (
6325 WorkflowsStartTotalCounter = "workflows-start-total"
@@ -76,145 +38,3 @@ const (
7638 DecisionsResponseLatency = "decisions-response-latency"
7739 UnhandledSignalsTotalCounter = "unhandled-signals-total"
7840)
79-
80- // ServiceMetrics are types for common service base metrics
81- var ServiceMetrics = map [MetricName ]MetricType {
82- RestartCount : Counter ,
83- }
84-
85- // GoRuntimeMetrics represent the runtime stats from go runtime
86- var GoRuntimeMetrics = map [MetricName ]MetricType {
87- NumGoRoutinesGauge : Gauge ,
88- GoMaxProcsGauge : Gauge ,
89- MemoryAllocatedGauge : Gauge ,
90- MemoryHeapGauge : Gauge ,
91- MemoryHeapIdleGauge : Gauge ,
92- MemoryHeapInuseGauge : Gauge ,
93- MemoryStackGauge : Gauge ,
94- NumGCCounter : Counter ,
95- GcPauseMsTimer : Timer ,
96- }
97-
98- // Service names for all service who emit metric.
99- // Please keep them in sync with the {Counter,Timer,Gauge}Names below. Order matters
100- const (
101- Frontend = iota
102- NumServices
103- )
104-
105- // operation scopes for frontend
106- const (
107- CreateShardScope = iota
108- GetShardScope
109- UpdateShardScope
110- CreateWorkflowExecutionScope
111- GetWorkflowExecutionScope
112- UpdateWorkflowExecutionScope
113- DeleteWorkflowExecutionScope
114- GetTransferTasksScope
115- CompleteTransferTaskScope
116- CreateTaskScope
117- GetTasksScope
118- CompleteTaskScope
119- StartWorkflowExecutionScope
120- PollForDecisionTaskScope
121- PollForActivityTaskScope
122- RespondDecisionTaskCompletedScope
123- RespondActivityTaskCompletedScope
124- RespondActivityTaskFailedScope
125- GetWorkflowExecutionHistoryScope
126- )
127-
128- // ScopeToTags record the scope name for all services
129- var ScopeToTags = [NumServices ][]map [string ]string {
130- // frontend Scope Names
131- {
132- {OperationTagName : CreateShardOperationTagValue },
133- {OperationTagName : GetShardOperationTagValue },
134- {OperationTagName : UpdateShardOperationTagValue },
135- {OperationTagName : CreateWorkflowExecutionOperationTagValue },
136- {OperationTagName : GetWorkflowExecutionOperationTagValue },
137- {OperationTagName : UpdateWorkflowExecutionOperationTagValue },
138- {OperationTagName : DeleteWorkflowExecutionOperationTagValue },
139- {OperationTagName : GetTransferTasksOperationTagValue },
140- {OperationTagName : CompleteTransferTaskOperationTagValue },
141- {OperationTagName : CreateTaskOperationTagValue },
142- {OperationTagName : GetTasksOperationTagValue },
143- {OperationTagName : CompleteTaskOperationTagValue },
144- {OperationTagName : StartWorkflowExecutionOperationTagValue },
145- {OperationTagName : PollForDecisionTaskOperationTagValue },
146- {OperationTagName : PollForActivityTaskOperationTagValue },
147- {OperationTagName : RespondDecisionTaskCompletedOperationTagValue },
148- {OperationTagName : RespondActivityTaskCompletedOperationTagValue },
149- {OperationTagName : RespondActivityTaskFailedOperationTagValue },
150- {OperationTagName : GetWorkflowExecutionHistoryOperationTagValue },
151- },
152- }
153-
154- // Counter enums for frontend. Please keep them in sync with the Frontend Service counter names below.
155- // Order between the two also matters.
156- const (
157- WorkflowRequests = iota
158- WorkflowFailures
159- )
160-
161- // Timer enums for frontend. Please keep them in sync with the Workflow Service timers below. Order between the
162- // two also matters.
163- const (
164- WorkflowLatencyTimer = iota
165- )
166-
167- // CounterNames is counter names for metrics
168- var CounterNames = [NumServices ]map [int ]string {
169- // Frontend Counter Names
170- {
171- WorkflowRequests : "workflow.requests" ,
172- WorkflowFailures : "workflow.errors" ,
173- },
174- }
175-
176- // TimerNames is timer names for metrics
177- var TimerNames = [NumServices ]map [int ]string {
178- // Frontend Timer Names
179- {
180- WorkflowLatencyTimer : "workflow.latency" ,
181- },
182- }
183-
184- // GaugeNames is gauge names for metrics
185- var GaugeNames = [NumServices ]map [int ]string {}
186-
187- // Frontend operation tag values as seen by the metric backend
188- const (
189- CreateShardOperationTagValue = "CreateShard"
190- GetShardOperationTagValue = "GetShard"
191- UpdateShardOperationTagValue = "UpdateShard"
192- CreateWorkflowExecutionOperationTagValue = "CreateWorkflowExecution"
193- GetWorkflowExecutionOperationTagValue = "GetWorkflowExecution"
194- UpdateWorkflowExecutionOperationTagValue = "UpdateWorkflowExecution"
195- DeleteWorkflowExecutionOperationTagValue = "DeleteWorkflowExecution"
196- GetTransferTasksOperationTagValue = "GetTransferTasks"
197- CompleteTransferTaskOperationTagValue = "CompleteTransferTask"
198- CreateTaskOperationTagValue = "CreateTask"
199- GetTasksOperationTagValue = "GetTasks"
200- CompleteTaskOperationTagValue = "CompleteTask"
201- StartWorkflowExecutionOperationTagValue = "StartWorkflowExecution"
202- PollForDecisionTaskOperationTagValue = "PollForDecisionTask"
203- PollForActivityTaskOperationTagValue = "PollForActivityTask"
204- RespondDecisionTaskCompletedOperationTagValue = "RespondDecisionTaskCompleted"
205- RespondActivityTaskCompletedOperationTagValue = "RespondActivityTaskCompleted"
206- RespondActivityTaskFailedOperationTagValue = "RespondActivityTaskFailed"
207- GetWorkflowExecutionHistoryOperationTagValue = "GetWorkflowExecutionHistory"
208- )
209-
210- // ErrorClass is an enum to help with classifying SLA vs. non-SLA errors (SLA = "service level agreement")
211- type ErrorClass uint8
212-
213- const (
214- // NoError indicates that there is no error (error should be nil)
215- NoError = ErrorClass (iota )
216- // UserError indicates that this is NOT an SLA-reportable error
217- UserError
218- // InternalError indicates that this is an SLA-reportable error
219- InternalError
220- )
0 commit comments