@Beta public final class ExecutionOrigin extends MDCEntry
An "Execution Origin" identifies the first (original) point of contact of an external event entering the system. That first event typically leads to numerous subsequent internal events in a system, and the point of such an ID is (only) to be able to correlate a series of such internal events among themselves and back to the original first external event. All log messages automatically include this ID.
In the case of OpenDaylight, such "origins" include HTTP requests (which are often from the nortbound APIs exposed by YANG RESTCONF, but not limited to), or something like an incoming Thrift request from a router, or an OVSDB notification, etc.
An Origin ID is "unique" within a certain given time span, which is typically "long enough" to correlate events. However it may "overflow" and repeat, at some point in time. This is dependent on the number of events (and thus the load of the system). This implementation issues an INFO level log indicating when such an overflow occurred.
Modifier and Type | Method and Description |
---|---|
static String |
currentID()
Returns the current origin ID.
|
boolean |
equals(Object obj) |
int |
hashCode() |
String |
mdcKeyString() |
String |
mdcValueString()
The exact internal implementation format of this ID may change over time, and
should not be relied upon.
|
static ExecutionOrigin |
next()
Returns the next origin ID.
|
public static ExecutionOrigin next()
This method does NOT put that next value into the MDC;
doing that, as well as (crucially) cleaning it up again at some point,
is the responsibility of the caller of this method, typically using
one of MDCs
' methods.
public static String currentID()
Normal application code will never have to invoke this. Do NOT explicitly use this in your Logger; the origin ID will already be automatically included in all ODL logs, always.
Typical usage of this method would only be in order to e.g. propagate the current origin ID onwards to another system during an RPC call; if that other system has it's own tracing facility similar to this, it will make it possible to correlate events.
This method is really just a convenience short-cut around MDC.get(MDC_KEY)
,
and can be used for more readable code. It also does throw a clear error message instead of returning null.
IllegalStateException
- if there is no Origin ID set in the MDCpublic String mdcKeyString()
mdcKeyString
in class MDCEntry
public String mdcValueString()
mdcValueString
in class MDCEntry
Copyright © 2019 OpenDaylight. All rights reserved.