-
Notifications
You must be signed in to change notification settings - Fork 860
WIP: new metrics emitter and histogram strategy #7201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,10 @@ type ( | |
ServiceIdx int | ||
) | ||
|
||
func (s scopeDefinition) GetOperationString() string { | ||
return s.operation | ||
} | ||
|
||
// MetricTypes which are supported | ||
const ( | ||
Counter MetricType = iota | ||
|
@@ -1068,7 +1072,7 @@ const ( | |
// -- Operation scopes for History service -- | ||
const ( | ||
// HistoryStartWorkflowExecutionScope tracks StartWorkflowExecution API calls received by service | ||
HistoryStartWorkflowExecutionScope = iota + NumCommonScopes | ||
HistoryStartWorkflowExecutionScope = iota + NumFrontendScopes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. urgh.. yeah, this is way better. |
||
// HistoryRecordActivityTaskHeartbeatScope tracks RecordActivityTaskHeartbeat API calls received by service | ||
HistoryRecordActivityTaskHeartbeatScope | ||
// HistoryRespondDecisionTaskCompletedScope tracks RespondDecisionTaskCompleted API calls received by service | ||
|
@@ -1356,7 +1360,7 @@ const ( | |
// -- Operation scopes for Matching service -- | ||
const ( | ||
// PollForDecisionTaskScope tracks PollForDecisionTask API calls received by service | ||
MatchingPollForDecisionTaskScope = iota + NumCommonScopes | ||
MatchingPollForDecisionTaskScope = iota + NumHistoryScopes | ||
// PollForActivityTaskScope tracks PollForActivityTask API calls received by service | ||
MatchingPollForActivityTaskScope | ||
// MatchingAddActivityTaskScope tracks AddActivityTask API calls received by service | ||
|
@@ -1392,7 +1396,7 @@ const ( | |
// -- Operation scopes for Worker service -- | ||
const ( | ||
// ReplicationScope is the scope used by all metric emitted by replicator | ||
ReplicatorScope = iota + NumCommonScopes | ||
ReplicatorScope = iota + NumMatchingScopes | ||
// DomainReplicationTaskScope is the scope used by domain task replication processing | ||
DomainReplicationTaskScope | ||
// ESProcessorScope is scope used by all metric emitted by esProcessor | ||
|
@@ -1440,7 +1444,7 @@ const ( | |
// -- Operation scopes for ShardDistributor service -- | ||
const ( | ||
// ShardDistributorGetShardOwnerScope tracks GetShardOwner API calls received by service | ||
ShardDistributorGetShardOwnerScope = iota + NumCommonScopes | ||
ShardDistributorGetShardOwnerScope = iota + NumWorkerScopes | ||
ShardDistributorHeartbeatScope | ||
ShardDistributorAssignLoopScope | ||
|
||
|
@@ -2700,12 +2704,13 @@ const ( | |
VirtualQueueCountGauge | ||
VirtualQueuePausedGauge | ||
VirtualQueueRunningGauge | ||
|
||
NumHistoryMetrics | ||
) | ||
|
||
// Matching metrics enum | ||
const ( | ||
PollSuccessPerTaskListCounter = iota + NumCommonMetrics | ||
PollSuccessPerTaskListCounter = iota + NumHistoryMetrics | ||
PollTimeoutPerTaskListCounter | ||
PollSuccessWithSyncPerTaskListCounter | ||
LeaseRequestPerTaskListCounter | ||
|
@@ -2783,12 +2788,13 @@ const ( | |
IsolationGroupUpscale | ||
IsolationGroupDownscale | ||
PartitionDrained | ||
|
||
NumMatchingMetrics | ||
) | ||
|
||
// Worker metrics enum | ||
const ( | ||
ReplicatorMessages = iota + NumCommonMetrics | ||
ReplicatorMessages = iota + NumMatchingMetrics | ||
ReplicatorFailures | ||
ReplicatorMessagesDropped | ||
ReplicatorLatency | ||
|
@@ -2872,12 +2878,13 @@ const ( | |
DiagnosticsWorkflowStartedCount | ||
DiagnosticsWorkflowSuccess | ||
DiagnosticsWorkflowExecutionLatency | ||
|
||
NumWorkerMetrics | ||
) | ||
|
||
// ShardDistributor metrics enum | ||
const ( | ||
ShardDistributorRequests = iota + NumCommonMetrics | ||
ShardDistributorRequests = iota + NumWorkerMetrics | ||
ShardDistributorFailures | ||
ShardDistributorLatency | ||
ShardDistributorErrContextTimeoutCounter | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,39 @@ func TestMetricDefs(t *testing.T) { | |
} | ||
} | ||
|
||
// "index -> operation" must be unique for structured.DynamicOperationTags' int lookup to work consistently. | ||
// Duplicate indexes with the same operation name are technically fine, but there doesn't seem to be any benefit in allowing it, | ||
// and it trivially ensures that all indexes have only one operation name. | ||
Comment on lines
+132
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could change this operation-lookup to also require a |
||
func TestOperationIndexesAreUnique(t *testing.T) { | ||
seen := make(map[int]bool) | ||
for serviceIdx, serviceOps := range ScopeDefs { | ||
for idx := range serviceOps { | ||
if seen[idx] { | ||
t.Error("duplicate operation index:", idx, "with name:", serviceOps[idx].operation, "in service:", serviceIdx) | ||
} | ||
seen[idx] = true | ||
} | ||
} | ||
} | ||
|
||
func TestMetricsAreUnique(t *testing.T) { | ||
// Duplicate indexes is arguably fine, but there doesn't seem to be any benefit in allowing it. | ||
// | ||
// Duplicate names are also linted, but they're done via an analyzer (metricslint) instead, to | ||
// allow checking across multiple formats. | ||
t.Run("indexes", func(t *testing.T) { | ||
seen := make(map[int]bool) | ||
for _, serviceMetrics := range MetricDefs { | ||
for idx := range serviceMetrics { | ||
if seen[idx] { | ||
t.Error("duplicate metric index:", idx, "with name:", serviceMetrics[idx].metricName) | ||
} | ||
seen[idx] = true | ||
} | ||
} | ||
}) | ||
} | ||
|
||
func TestExponentialDurationBuckets(t *testing.T) { | ||
factor := math.Pow(2, 0.25) | ||
assert.Equal(t, 80, len(ExponentialDurationBuckets)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mild nit: should this just be
String
? I thought that was a somewhat-commonly used go interface