/** * Generates a child Id for dependencies. Dependencies are children of requests and, therefore, their ID's * reflect this. The generated ID is based on the current request scope (stored in TLS). * @return The child Id. */ public static String generateChildDependencyId() { try { RequestTelemetryContext context = ThreadContext.getRequestTelemetryContext(); //check if context is null - no correlation will happen if (context == null) { InternalLogger.INSTANCE.warn("No Correlation will happen, Thread context is null while generating child dependency"); return ""; } RequestTelemetry requestTelemetry = context.getHttpRequestTelemetry(); String parentId = requestTelemetry.getContext().getOperation().getParentId(); // if parentId is non-hierarchical, it means the incoming requestId // does not follow hierarchical convention, so we must not modify the children ID's. if (parentId != null && parentId.length() > 0 && !isHierarchicalId((parentId))) { return requestTelemetry.getContext().getOperation().getParentId(); } return requestTelemetry.getId() + context.incrementChildId() + "."; } catch (Exception ex) { InternalLogger.INSTANCE.error("Failed to generate child ID. Exception information: %s", ex.toString()); InternalLogger.INSTANCE.trace("Stack trace generated is %s", ExceptionUtils.getStackTrace(ex)); } return null; }
/** * Generates a child Id for dependencies. Dependencies are children of requests and, therefore, their ID's * reflect this. The generated ID is based on the current request scope (stored in TLS). * @return The child Id. */ public static String generateChildDependencyId() { try { RequestTelemetryContext context = ThreadContext.getRequestTelemetryContext(); //check if context is null - no correlation will happen if (context == null) { InternalLogger.INSTANCE.warn("No Correlation will happen, Thread context is null while generating child dependency"); return ""; } RequestTelemetry requestTelemetry = context.getHttpRequestTelemetry(); String parentId = requestTelemetry.getContext().getOperation().getParentId(); // if parentId is non-hierarchical, it means the incoming requestId // does not follow hierarchical convention, so we must not modify the children ID's. if (parentId != null && parentId.length() > 0 && !isHierarchicalId((parentId))) { return requestTelemetry.getContext().getOperation().getParentId(); } return requestTelemetry.getId() + context.incrementChildId() + "."; } catch (Exception ex) { InternalLogger.INSTANCE.error("Failed to generate child ID. Exception information: %s", ex.toString()); InternalLogger.INSTANCE.trace("Stack trace generated is %s", ExceptionUtils.getStackTrace(ex)); } return null; }