Skip to content

Commit

Permalink
Add API metrics enums
Browse files Browse the repository at this point in the history
  • Loading branch information
annieyang committed Nov 13, 2024
1 parent 7f434dc commit 1fdadb3
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ public enum IpcMetric {
IpcTagKey.status
),
EnumSet.of(
IpcTagKey.source,
IpcTagKey.endpoint,
IpcTagKey.method,
IpcTagKey.failureInjected,
IpcTagKey.httpMethod,
IpcTagKey.httpStatus,
Expand All @@ -76,9 +74,7 @@ public enum IpcMetric {
IpcTagKey.status
),
EnumSet.of(
IpcTagKey.source,
IpcTagKey.endpoint,
IpcTagKey.method,
IpcTagKey.clientApp,
IpcTagKey.clientCluster,
IpcTagKey.clientAsg,
Expand Down Expand Up @@ -232,7 +228,74 @@ public enum IpcMetric {
IpcTagKey.protocol,
IpcTagKey.vip
)
);
),

/**
* V2 - Timer recording the number and latency of outbound requests.
*/
apiClientCall(
"api.client.call",
EnumSet.of(
IpcTagKey.vip,
IpcTagKey.method,
IpcTagKey.endpoint,
IpcTagKey.owner,
IpcTagKey.id,
IpcTagKey.source,
IpcTagKey.result,
IpcTagKey.status,
IpcTagKey.statusDetail
),
EnumSet.noneOf(IpcTagKey.class)
),

/**
* V2 - Timer recording the number and latency of inbound requests.
*/
apiServerCall(
"api.server.call",
EnumSet.of(
IpcTagKey.method,
IpcTagKey.endpoint,
IpcTagKey.owner,
IpcTagKey.id,
IpcTagKey.source,
IpcTagKey.result,
IpcTagKey.status,
IpcTagKey.statusDetail
),
EnumSet.noneOf(IpcTagKey.class)
),

/**
* V2 - Number of outbound requests that are currently in flight.
*/
apiClientInflight(
"api.client.inflight",
EnumSet.of(
IpcTagKey.vip,
IpcTagKey.method,
IpcTagKey.endpoint,
IpcTagKey.owner,
IpcTagKey.id
),
EnumSet.noneOf(IpcTagKey.class)
),

/**
* V2 - Number of inbound requests that are currently in flight.
*/
apiServerInflight(
"api.server.inflight",
EnumSet.of(
IpcTagKey.method,
IpcTagKey.endpoint,
IpcTagKey.owner,
IpcTagKey.id
),
EnumSet.noneOf(IpcTagKey.class)
),
;

private final String metricName;
private final EnumSet<IpcTagKey> requiredDimensions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,54 @@ public void validateFailureInjectionInvalid() {
IpcMetric.clientCall.validate(id);
});
}

@Test
public void validateApiIdOk() {
Id id = registry.createId(IpcMetric.apiClientCall.metricName())
.withTag(IpcTagKey.owner.tag("test"))
.withTag(IpcTagKey.vip.tag("localhost"))
.withTag(IpcMethod.get)
.withTag(IpcTagKey.endpoint.tag("hello"))
.withTag(IpcTagKey.id.tag("HelloEndpoint"))
.withTag(IpcSource.direct)
.withTag(IpcResult.success)
.withTag(IpcStatus.success)
.withTag(IpcTagKey.statusDetail.tag("200"));
IpcMetric.apiClientCall.validate(id, true);
}

@Test
public void validateApiInflightOk() {
Id id = registry.createId(IpcMetric.apiClientInflight.metricName())
.withTag(IpcTagKey.owner.tag("test"))
.withTag(IpcTagKey.vip.tag("localhost"))
.withTag(IpcMethod.get)
.withTag(IpcTagKey.endpoint.tag("hello"))
.withTag(IpcTagKey.id.tag("HelloEndpoint"));
IpcMetric.apiClientInflight.validate(id, true);
}

@Test
public void validateApiServerIdOk() {
Id id = registry.createId(IpcMetric.apiServerCall.metricName())
.withTag(IpcTagKey.owner.tag("test"))
.withTag(IpcMethod.get)
.withTag(IpcTagKey.endpoint.tag("hello"))
.withTag(IpcTagKey.id.tag("HelloEndpoint"))
.withTag(IpcSource.direct)
.withTag(IpcResult.success)
.withTag(IpcStatus.success)
.withTag(IpcTagKey.statusDetail.tag("200"));
IpcMetric.apiServerCall.validate(id, true);
}

@Test
public void validateApiServerInflightOk() {
Id id = registry.createId(IpcMetric.apiServerInflight.metricName())
.withTag(IpcTagKey.owner.tag("test"))
.withTag(IpcMethod.get)
.withTag(IpcTagKey.endpoint.tag("hello"))
.withTag(IpcTagKey.id.tag("HelloEndpoint"));
IpcMetric.apiServerInflight.validate(id, true);
}
}

0 comments on commit 1fdadb3

Please sign in to comment.