generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Labels
questionFurther information is requestedFurther information is requested
Description
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:
- Namespace: OtherTeamService, Endpoint (dimension): GetSomeEntity, Latency (metric): 100ms
- Namespace: OtherTeamService, Endpoint (dimension): PutSomeEntity, Latency (metric): 500ms
- Namespace: OtherTeamService, Endpoint (dimension): PostSomeOperation, Latency (metric): 1000ms
Can I use an implementation 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?
bryce-carey
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested