public final class InMemoryStorage extends StorageComponent implements SpanStore, SpanConsumer
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 )
Modifier and Type | Class and Description |
---|---|
static class |
InMemoryStorage.Builder |
Modifier and Type | Method and Description |
---|---|
Call<Void> |
accept(List<Span> spans) |
int |
acceptedSpanCount() |
void |
clear() |
void |
close()
Closes any network resources created implicitly by the component.
|
List<DependencyLink> |
getDependencies()
Used for testing.
|
Call<List<DependencyLink>> |
getDependencies(long endTs,
long lookback)
Returns dependency links derived from spans in an interval contained by (endTs - lookback) or
empty if none are found.
|
Call<List<String>> |
getServiceNames()
|
Call<List<String>> |
getSpanNames(String service)
Retrieves all
span names recorded by a service , sorted lexicographically. |
Call<List<Span>> |
getTrace(String traceId)
Retrieves spans that share a 128-bit trace id with no ordering expectation or empty if none are
found.
|
List<List<Span>> |
getTraces()
Used for testing.
|
Call<List<List<Span>>> |
getTraces(QueryRequest request)
Retrieves spans grouped by trace ID from the storage system with no ordering expectation.
|
static InMemoryStorage.Builder |
newBuilder() |
SpanConsumer |
spanConsumer() |
InMemoryStorage |
spanStore() |
public static InMemoryStorage.Builder newBuilder()
public int acceptedSpanCount()
public void clear()
public Call<List<List<Span>>> getTraces(QueryRequest request)
SpanStore
When strict trace ID is disabled, spans are grouped by the right-most 16 characters of the trace ID.
public List<DependencyLink> getDependencies()
public Call<List<Span>> getTrace(String traceId)
SpanStore
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.
public Call<List<String>> getServiceNames()
SpanStore
getServiceNames
in interface SpanStore
public Call<List<String>> getSpanNames(String service)
SpanStore
span names
recorded by a service
, sorted lexicographically.getSpanNames
in interface SpanStore
public Call<List<DependencyLink>> getDependencies(long endTs, long lookback)
SpanStore
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.
getDependencies
in interface SpanStore
endTs
- only return links from spans where Span.timestamp
are at or before this
time in epoch milliseconds.lookback
- only return links from spans where Span.timestamp
are at or after
(endTs - lookback) in milliseconds.public InMemoryStorage spanStore()
spanStore
in class StorageComponent
public SpanConsumer spanConsumer()
spanConsumer
in class StorageComponent
public void close()
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.
Copyright © 2015–2018 OpenZipkin. All rights reserved.