/** * If current span is null, service is in wrong context, and IllegalStateException is thrown */ public static void assertWithinContext() { if(TraceContextHolder.getCurrentSpan() ==null) { throw new IllegalStateException("Request out of context boundaries, check configuration"); } } }
/** * Defines whether this call is part of process or its separate operation * @return true if service is called within process started in other service, false otherwise */ @Override public boolean isProcess() { ContextVerifier.assertWithinContext(); return !TraceContextHolder.getCurrentSpan().getParents().isEmpty(); }
/** * Operation id is id of service call itself, its always presents and always unique for this service call * @return operation id */ @Override public UUID getOperationId() { ContextVerifier.assertWithinContext(); return UUID.fromString(TraceContextHolder.getCurrentSpan().getSpanId()); }
/** * Operation id is id of service call itself, its always presents and always unique for this service call * @return operation id */ @Override public UUID getOperationId() { ContextVerifier.assertWithinContext(); return UUID.fromString(TraceContextHolder.getCurrentSpan().getSpanId()); }
/** * Process id is id of process uniting several operations, logically defining some complete execution * including several service calls * @return id of process */ @Override public UUID getProcessId() { ContextVerifier.assertWithinContext(); return UUID.fromString(TraceContextHolder.getCurrentSpan().getTraceId()); }
/** * Process id is id of process uniting several operations, logically defining some complete execution * including several service calls * @return id of process if operation is part of process, null otherwise */ @Override public UUID getProcessId() { ContextVerifier.assertWithinContext(); if(!isProcess()) { return null; } return UUID.fromString(TraceContextHolder.getCurrentSpan().getTraceId()); }