use of org.apache.gobblin.metrics.broker.MetricContextKey in project incubator-gobblin by apache.
the class RestliLimiterFactory method createResource.
@Override
public SharedResourceFactoryResponse<RestliServiceBasedLimiter> createResource(SharedResourcesBroker<S> broker, ScopedConfigView<S, SharedLimiterKey> config) throws NotConfiguredException {
S scope = config.getScope();
if (scope != scope.rootScope()) {
return new ResourceCoordinate<>(this, config.getKey(), scope.rootScope());
}
String serviceIdentifier = config.getConfig().hasPath(SERVICE_IDENTIFIER_KEY) ? config.getConfig().getString(SERVICE_IDENTIFIER_KEY) : "UNKNOWN";
String resourceLimited = config.getKey().getResourceLimitedPath();
MetricContextKey metricContextKey = new SubTaggedMetricContextKey(RestliServiceBasedLimiter.class.getSimpleName() + "_" + resourceLimited, ImmutableMap.of("resourceLimited", resourceLimited));
return new ResourceInstance<>(RestliServiceBasedLimiter.builder().resourceLimited(resourceLimited).serviceIdentifier(serviceIdentifier).metricContext(broker.getSharedResource(new MetricContextFactory<S>(), metricContextKey)).requestSender(broker.getSharedResource(new RedirectAwareRestClientRequestSender.Factory<S>(), new SharedRestClientKey(RESTLI_SERVICE_NAME))).build());
}
Aggregations