Class InMemoryStorage
- All Implemented Interfaces:
Closeable
,AutoCloseable
,AutocompleteTags
,ServiceAndSpanNames
,SpanConsumer
,SpanStore
,Traces
Internally, spans are indexed on 64-bit trace ID
Here's an example of some traces in memory:
spansByTraceIdTimeStamp:
<aaaa,July 4> --> ( spanA(time:July 4, traceId:aaaa, service:foo, name:GET),
spanB(time:July 4, traceId:aaaa, service:bar, name:GET) )
<cccc,July 4> --> ( spanC(time:July 4, traceId:aaaa, service:foo, name:GET) )
<bbbb,July 5> --> ( spanD(time:July 5, traceId:bbbb, service:biz, name:GET) )
<bbbb,July 6> --> ( spanE(time:July 6, traceId:bbbb) service:foo, name:POST )
traceIdToTraceIdTimeStamps:
aaaa --> [ <aaaa,July 4> ]
bbbb --> [ <bbbb,July 5>, <bbbb,July 6> ]
cccc --> [ <cccc,July 4> ]
serviceToTraceIds:
foo --> [ <aaaa>, <cccc>, <bbbb> ]
bar --> [ <aaaa> ]
biz --> [ <bbbb> ]
serviceToSpanNames:
bar --> ( GET )
biz --> ( GET )
foo --> ( GET, POST )
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
void
clear()
void
close()
Closes any network resources created implicitly by the component.Used for testing.getDependencies
(long endTs, long lookback) Returns dependency links derived from spans in an interval contained by (endTs - lookback) or empty if none are found.getKeys()
Retrieves the list of tag getKeys whose values may be returned byAutocompleteTags.getValues(String)
.getRemoteServiceNames
(String service) getSpanNames
(String service) Retrieves allspan names
recorded by aservice
, sorted lexicographically.Retrieves spans that share a 128-bit trace id with no ordering expectation or empty if none are found.Used for testing.Retrieves any traces with the specified IDs.getTraces
(QueryRequest request) Retrieves spans grouped by trace ID from the storage system with no ordering expectation.Retrieves the list of values, if the input is configured for autocompletion.static InMemoryStorage.Builder
toString()
traces()
Methods inherited from class zipkin2.storage.StorageComponent
isOverCapacity
-
Method Details
-
newBuilder
-
acceptedSpanCount
public int acceptedSpanCount() -
clear
public void clear() -
accept
- Specified by:
accept
in interfaceSpanConsumer
-
getTraces
Description copied from interface:SpanStore
Retrieves spans grouped by trace ID from the storage system with no ordering expectation.When strict trace ID is disabled, spans are grouped by the right-most 16 characters of the trace ID.
-
getTraces
Used for testing. Returns all traces unconditionally. -
getDependencies
Used for testing. Returns all dependency links unconditionally. -
getTrace
Description copied from interface:SpanStore
Retrieves spans that share a 128-bit trace id with no ordering expectation or empty if none are found.When strict trace ID is disabled, spans with the same right-most 16 characters are returned even if the characters to the left are not.
Implementations should use
Span.normalizeTraceId(String)
to ensure consistency. -
getTraces
Description copied from interface:Traces
Retrieves any traces with the specified IDs. Results return in any order, and can be empty.When strict trace ID is disabled, spans with the same right-most 16 characters are returned even if the characters to the left are not.
Implementations should use
Span.normalizeTraceId(String)
on each input trace ID to ensure consistency. -
getServiceNames
Description copied from interface:SpanStore
- Specified by:
getServiceNames
in interfaceServiceAndSpanNames
- Specified by:
getServiceNames
in interfaceSpanStore
-
getRemoteServiceNames
Description copied from interface:ServiceAndSpanNames
- Specified by:
getRemoteServiceNames
in interfaceServiceAndSpanNames
-
getSpanNames
Description copied from interface:SpanStore
Retrieves allspan names
recorded by aservice
, sorted lexicographically.- Specified by:
getSpanNames
in interfaceServiceAndSpanNames
- Specified by:
getSpanNames
in interfaceSpanStore
-
getDependencies
Description copied from interface:SpanStore
Returns dependency links derived from spans in an interval contained by (endTs - lookback) or empty if none are found.Implementations may bucket aggregated data, for example daily. When this is the case, endTs may be floored to align with that bucket, for example midnight if daily. lookback applies to the original endTs, even when bucketed. Using the daily example, if endTs was 11pm and lookback was 25 hours, the implementation would query against 2 buckets.
Some implementations parse spans from storage and call
DependencyLinker
to aggregate links. The reason is certain graph logic, such as skipping up the tree is difficult to implement as a storage query.Spans are grouped by the right-most 16 characters of the trace ID. This ensures call counts are not incremented twice due to one hop downgrading from 128 to 64-bit trace IDs.
- Specified by:
getDependencies
in interfaceSpanStore
- Parameters:
endTs
- only return links from spans whereSpan.timestamp()
are at or before this time in epoch milliseconds.lookback
- only return links from spans whereSpan.timestamp()
are at or after (endTs - lookback) in milliseconds.
-
getKeys
Description copied from interface:AutocompleteTags
Retrieves the list of tag getKeys whose values may be returned byAutocompleteTags.getValues(String)
.- Specified by:
getKeys
in interfaceAutocompleteTags
- See Also:
-
getValues
Description copied from interface:AutocompleteTags
Retrieves the list of values, if the input is configured for autocompletion. If a key is not configured, or there are no values available, an empty result will be returned.- Specified by:
getValues
in interfaceAutocompleteTags
- See Also:
-
traces
- Overrides:
traces
in classStorageComponent
-
spanStore
- Specified by:
spanStore
in classStorageComponent
-
autocompleteTags
- Overrides:
autocompleteTags
in classStorageComponent
-
serviceAndSpanNames
- Overrides:
serviceAndSpanNames
in classStorageComponent
-
spanConsumer
- Specified by:
spanConsumer
in classStorageComponent
-
close
public void close()Description copied from class:Component
Closes any network resources created implicitly by the component.For example, if this created a connection, it would close it. If it was provided one, this would close any sessions, but leave the connection open.
-
toString
-