You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the library! This has sped up telemetry work quite a bit on a new service I'm working on.
Can I use a single MetricsLogger in different threads of a service, with each thread using different dimensions?
E.g. can I use a single MetricsLogger bean in an ECS service, which is expected to handle multiple requests concurrently? I would use it to log metrics for downstream service calls and setting specific downstream APIs as the dimension for each call, like:
@AllArgsConstructor
@RestController
public class MyApiHandler {
private final MetricsLogger metricsLogger; // This is a singleton bean which is passed in through the constructor
private final OtherTeamServiceClient otherTeamServiceClient;
@GET
@Path("myApi")
public MyApiHandlerResponse handleRequest(final MyApiHandlerRequest request) {
// [...]
metricsLogger.setDimensions(DimensionSet.of("Endpoint", "GetSomeEntity");
metricsLogger.putMetric("Latency", Duration.between(getSomeEntityStart, getSomeEntityEnd).toMillis(), Unit.MILLISECONDS);
metricsLogger.flush()
// [...]
metricsLogger.setDimensions(DimensionSet.of("Endpoint", "PutSomeEntity");
metricsLogger.putMetric("Latency", Duration.between(putSomeEntityStart, putSomeEntityEnd).toMillis(), Unit.MILLISECONDS);
metricsLogger.flush()
// [...]
metricsLogger.setDimensions(DimensionSet.of("Endpoint", "PostSomeOperation");
metricsLogger.putMetric("Latency", Duration.between(postSomeOperationStart, postSomeOperationEnd).toMillis(), Unit.MILLISECONDS);
metricsLogger.flush()
}
}
...knowing that there will be potentially hundreds of concurrent requests to the same handler on the same ECS instance? Or would the multiple concurrent calls to .setDimension across the threads step on each other's toes?
The text was updated successfully, but these errors were encountered:
If the order of operations aren't guaranteed, then you may end up with mixed up dimensions.
For example if PutAPI starts, sets Put dimensions, does not flush yet. GetAPI starts, sets Get dimensions (effectively overwriting the Put dimensions). PutAPI flushes with Get dimensions and GetAPI follows and flushes with Get dimensions as well.
Hey all,
Thanks for the library! This has sped up telemetry work quite a bit on a new service I'm working on.
Can I use a single MetricsLogger in different threads of a service, with each thread using different dimensions?
E.g. can I use a single MetricsLogger bean in an ECS service, which is expected to handle multiple requests concurrently? I would use it to log metrics for downstream service calls and setting specific downstream APIs as the dimension for each call, like:
Can I use an implementation like...
...knowing that there will be potentially hundreds of concurrent requests to the same handler on the same ECS instance? Or would the multiple concurrent calls to
.setDimension
across the threads step on each other's toes?The text was updated successfully, but these errors were encountered: