package com.atlassian.bitbucket.mesh.request;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.time.Duration;
import java.util.SortedSet;

/**
 * Provides details about an in-flight request.
 */
public interface RequestContext extends RequestDescriptor {

    /**
     * Applies the provided label(s) to the request. Labels can be used to include "hints" in the access logs that
     * provide additional insight into the processing a request performed.
     *
     * @param label  the first label to apply, handled separately to require at least one label
     * @param labels zero or more additional labels to apply
     */
    void addLabels(@Nonnull String label, @Nullable String... labels);

    /**
     * @return the <i>current</i> duration of the request
     */
    @Nonnull
    Duration getDuration();

    /**
     * @return the <i>local</i> ID assigned to the request
     * @see #getCorrelationId()
     */
    @Nonnull
    String getId();

    /**
     * @return the currently-applied labels, if any, <i>sorted alphabetically</i>
     */
    @Nonnull
    SortedSet<String> getLabels();
}
