/** * Create a new log entry for client requests. Log entry objects may be reused to minimize * the number of allocations so they should only be modified in the context of a single * request. */ public IpcLogEntry createClientEntry() { return newEntry() .withRegistry(registry) .withLogger(this) .withMarker(CLIENT); }
/** * Set the protocol used for this request. See {@link IpcProtocol} for more information. */ public IpcLogEntry withProtocol(IpcProtocol protocol) { return withProtocol(protocol.value()); }
/** * Set the attempt number for the request. */ public IpcLogEntry withAttempt(int attempt) { return withAttempt(IpcAttempt.forAttemptNumber(attempt)); }
/** Create a new instance for the specified URI. */ public HttpRequestBuilder(IpcLogger logger, URI uri) { this.uri = uri; this.entry = logger.createClientEntry() .withOwner("spectator") .withUri(uri) .withHttpMethod(method); this.reqHeaders.putAll(NETFLIX_HEADERS); }
/** Set the request method (GET, PUT, POST, DELETE). */ public HttpRequestBuilder withMethod(String m) { this.method = m; entry.withHttpMethod(method); return this; }
private IpcAttempt getAttempt() { if (attempt == null) { attempt = IpcAttempt.forAttemptNumber(1); } return attempt; }
/** * Set whether or not this is the final attempt for the request. */ public IpcLogEntry withAttemptFinal(boolean isFinal) { this.attemptFinal = IpcAttemptFinal.forValue(isFinal); return this; }
/** Create a new instance. */ IpcLogEntry(Clock clock) { this.clock = clock; reset(); }
/** * Set the server zone for the request. In the case of the client side this will be * automatically filled in if the {@link NetflixHeader#Zone} is specified on the server * response. */ public IpcLogEntry withServerZone(String zone) { this.serverZone = zone; if (serverRegion == null) { serverRegion = extractRegionFromZone(zone); } return this; }
/** * Validate all of the common IPC metrics contained within the specified registry. * * @param registry * Registry to query for IPC metrics. */ public static void validate(Registry registry) { validateIpcMeter(registry, IpcMetric.clientCall, Timer.class); validateIpcMeter(registry, IpcMetric.serverCall, Timer.class); validateIpcMeter(registry, IpcMetric.clientInflight, DistributionSummary.class); validateIpcMeter(registry, IpcMetric.serverInflight, DistributionSummary.class); }
private IpcResult getResult() { if (result == null) { result = status == null ? IpcResult.success : status.result(); } return result; }
/** * Extract common Netflix headers from environment variables on the system. */ public static Map<String, String> extractFromEnvironment() { return extractFrom(System::getenv); } }
/** * Create a new log entry for server requests. Log entry objects may be reused to minimize * the number of allocations so they should only be modified in the context of a single * request. */ public IpcLogEntry createServerEntry() { return newEntry() .withRegistry(registry) .withLogger(this) .withMarker(SERVER); }
/** * Set the protocol used for this request. See {@link IpcProtocol} for more information. */ public IpcLogEntry withProtocol(IpcProtocol protocol) { return withProtocol(protocol.value()); }
/** * Set the attempt number for the request. */ public IpcLogEntry withAttempt(int attempt) { return withAttempt(IpcAttempt.forAttemptNumber(attempt)); }
private IpcAttempt getAttempt() { if (attempt == null) { attempt = IpcAttempt.forAttemptNumber(1); } return attempt; }
/** * Set the client zone for the request. In the case of the server side this will be * automatically filled in if the {@link NetflixHeader#Zone} is specified on the client * request. */ public IpcLogEntry withClientZone(String zone) { this.clientZone = zone; if (clientRegion == null) { clientRegion = extractRegionFromZone(zone); } return this; }
/** * Validate all of the common IPC metrics contained within the specified registry. * * @param registry * Registry to query for IPC metrics. */ public static void validate(Registry registry) { validateIpcMeter(registry, IpcMetric.clientCall, Timer.class); validateIpcMeter(registry, IpcMetric.serverCall, Timer.class); validateIpcMeter(registry, IpcMetric.clientInflight, DistributionSummary.class); validateIpcMeter(registry, IpcMetric.serverInflight, DistributionSummary.class); }
/** * Create a new log entry for server requests. Log entry objects may be reused to minimize * the number of allocations so they should only be modified in the context of a single * request. */ public IpcLogEntry createServerEntry() { return newEntry() .withRegistry(registry) .withLogger(this) .withMarker(SERVER); }
/** * Create a new log entry for client requests. Log entry objects may be reused to minimize * the number of allocations so they should only be modified in the context of a single * request. */ public IpcLogEntry createClientEntry() { return newEntry() .withRegistry(registry) .withLogger(this) .withMarker(CLIENT); }