com.sap.cloud.yaas.servicesdk.authorization.DiagnosticContext Maven / Gradle / Ivy
/*
* © 2016 SAP SE or an SAP affiliate company.
* All rights reserved.
* Please see http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and
* notices.
*/
package com.sap.cloud.yaas.servicesdk.authorization;
/**
* Holds diagnostic data that YaaS services should pass-through when requesting backing-services.
*
* YaaS services receive and send such diagnostic data in HTTP headers.
*
* Instances of this class are immutable.
*
* @see https://api.yaas.io/patterns/v2/trait-yaas-aware.yaml
*/
public class DiagnosticContext
{
/** The name of the HTTP header used for the {@code requestId} field. */
public static final String HEADER_REQUEST_ID = "hybris-request-id";
/** The name of the HTTP header used for the {@code hop} field. */
public static final String HEADER_HOP = "hybris-hop";
private final String requestId;
private final Integer hop;
/**
* Creates a new instance based on the fields of this class.
*
* @param requestId the unique identifier of the current HTTP request chain
* @param hop the number identifying level of depth of the current HTTP request chain
*/
public DiagnosticContext(final String requestId, final Integer hop)
{
this.requestId = requestId;
this.hop = hop;
}
public String getRequestId()
{
return requestId;
}
public Integer getHop()
{
return hop;
}
@Override
public String toString()
{
return getClass().getSimpleName() + " [" + HEADER_REQUEST_ID + "=" + requestId + ", " + HEADER_HOP + "=" + hop + "]";
}
}