use of org.hypertrace.gateway.service.common.RequestContext in project gateway-service by hypertrace.
the class GatewayServiceImpl method getTraces.
@Override
public void getTraces(org.hypertrace.gateway.service.v1.trace.TracesRequest request, io.grpc.stub.StreamObserver<org.hypertrace.gateway.service.v1.trace.TracesResponse> responseObserver) {
Optional<String> tenantId = org.hypertrace.core.grpcutils.context.RequestContext.CURRENT.get().getTenantId();
if (tenantId.isEmpty()) {
responseObserver.onError(new ServiceException("Tenant id is missing in the request."));
return;
}
try {
RequestContext requestContext = new RequestContext(tenantId.get(), org.hypertrace.core.grpcutils.context.RequestContext.CURRENT.get().getRequestHeaders());
TracesResponse response = traceService.getTracesByFilter(requestContext, request);
responseObserver.onNext(response);
responseObserver.onCompleted();
} catch (Exception e) {
LOG.error("Error while handling traces request: {}", request, e);
responseObserver.onError(e);
}
}
use of org.hypertrace.gateway.service.common.RequestContext in project gateway-service by hypertrace.
the class GatewayServiceImpl method getSpans.
@Override
public void getSpans(org.hypertrace.gateway.service.v1.span.SpansRequest request, io.grpc.stub.StreamObserver<org.hypertrace.gateway.service.v1.span.SpansResponse> responseObserver) {
Optional<String> tenantId = org.hypertrace.core.grpcutils.context.RequestContext.CURRENT.get().getTenantId();
if (tenantId.isEmpty()) {
responseObserver.onError(new ServiceException("Tenant id is missing in the request."));
return;
}
try {
RequestContext context = new RequestContext(tenantId.get(), org.hypertrace.core.grpcutils.context.RequestContext.CURRENT.get().getRequestHeaders());
SpansResponse response = spanService.getSpansByFilter(context, request);
responseObserver.onNext(response);
responseObserver.onCompleted();
} catch (Exception e) {
LOG.error("Error while handling spans request: {}", request, e);
responseObserver.onError(e);
}
}
use of org.hypertrace.gateway.service.common.RequestContext in project gateway-service by hypertrace.
the class GatewayServiceImpl method getLogEvents.
@Override
public void getLogEvents(LogEventsRequest request, StreamObserver<LogEventsResponse> responseObserver) {
Optional<String> tenantId = org.hypertrace.core.grpcutils.context.RequestContext.CURRENT.get().getTenantId();
if (tenantId.isEmpty()) {
responseObserver.onError(new ServiceException("Tenant id is missing in the request."));
return;
}
try {
RequestContext context = new RequestContext(tenantId.get(), org.hypertrace.core.grpcutils.context.RequestContext.CURRENT.get().getRequestHeaders());
LogEventsResponse response = logEventsService.getLogEventsByFilter(context, request);
responseObserver.onNext(response);
responseObserver.onCompleted();
} catch (Exception e) {
LOG.error("Error while handling logEvents request: {}", request, e);
responseObserver.onError(e);
}
}
use of org.hypertrace.gateway.service.common.RequestContext in project gateway-service by hypertrace.
the class EntityService method updateEntity.
public UpdateEntityResponse updateEntity(String tenantId, UpdateEntityRequest request, Map<String, String> requestHeaders) {
Preconditions.checkArgument(StringUtils.isNotBlank(request.getEntityType()), "entity_type is mandatory in the request.");
RequestContext requestContext = new RequestContext(tenantId, requestHeaders);
Map<String, AttributeMetadata> attributeMetadataMap = metadataProvider.getAttributesMetadata(requestContext, request.getEntityType());
updateEntityRequestValidator.validate(request, attributeMetadataMap);
UpdateExecutionContext updateExecutionContext = new UpdateExecutionContext(requestHeaders, attributeMetadataMap);
// Validations have ensured that only EDS update operation is supported.
// If in the future we need more sophisticated update across data sources, we'll need
// to add the capability similar to what we have for querying.
UpdateEntityResponse.Builder responseBuilder = edsEntityUpdater.update(request, updateExecutionContext);
return responseBuilder.build();
}
use of org.hypertrace.gateway.service.common.RequestContext in project gateway-service by hypertrace.
the class EntityService method bulkUpdateEntities.
public BulkUpdateEntitiesResponse bulkUpdateEntities(String tenantId, BulkUpdateEntitiesRequest request, Map<String, String> requestHeaders) {
RequestContext requestContext = new RequestContext(tenantId, requestHeaders);
Map<String, AttributeMetadata> attributeMetadataMap = metadataProvider.getAttributesMetadata(requestContext, request.getEntityType());
Status status = BULK_UPDATE_ENTITIES_REQUEST_VALIDATOR.validate(request, attributeMetadataMap);
if (!status.isOk()) {
LOG.error("Bulk update entities request is not valid: {}", status.getDescription());
throw status.asRuntimeException();
}
UpdateExecutionContext updateExecutionContext = new UpdateExecutionContext(requestHeaders, attributeMetadataMap);
return edsEntityUpdater.bulkUpdateEntities(request, updateExecutionContext);
}
Aggregations