|
| 1 | +// Copyright (c) 2024 The Jaeger Authors. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +package spanstore |
| 5 | + |
| 6 | +import ( |
| 7 | + "context" |
| 8 | + "time" |
| 9 | + |
| 10 | + "go.opentelemetry.io/collector/pdata/pcommon" |
| 11 | + "go.opentelemetry.io/collector/pdata/ptrace" |
| 12 | + |
| 13 | + spanstore_v1 "github.com/jaegertracing/jaeger/storage/spanstore" |
| 14 | +) |
| 15 | + |
| 16 | +// ErrTraceNotFound is returned by Reader's GetTrace if no data is found for given trace ID. |
| 17 | +var ErrTraceNotFound = spanstore_v1.ErrTraceNotFound |
| 18 | + |
| 19 | +// Reader finds and loads traces and other data from storage. |
| 20 | +type Reader interface { |
| 21 | + // GetTrace retrieves the trace with a given id. |
| 22 | + // |
| 23 | + // If no spans are stored for this trace, it returns ErrTraceNotFound. |
| 24 | + GetTrace(ctx context.Context, traceID pcommon.TraceID) (ptrace.Traces, error) |
| 25 | + |
| 26 | + // GetServices returns all service names known to the backend from spans |
| 27 | + // within its retention period. |
| 28 | + GetServices(ctx context.Context) ([]string, error) |
| 29 | + |
| 30 | + // GetOperations returns all operation names for a given service |
| 31 | + // known to the backend from spans within its retention period. |
| 32 | + GetOperations(ctx context.Context, query OperationQueryParameters) ([]Operation, error) |
| 33 | + |
| 34 | + // FindTraces returns all traces matching query parameters. There's currently |
| 35 | + // an implementation-dependent ambiguity whether all query filters (such as |
| 36 | + // multiple tags) must apply to the same span within a trace, or can be satisfied |
| 37 | + // by different spans. |
| 38 | + // |
| 39 | + // If no matching traces are found, the function returns (nil, nil). |
| 40 | + FindTraces(ctx context.Context, query TraceQueryParameters) ([]ptrace.Traces, error) |
| 41 | + |
| 42 | + // FindTraceIDs does the same search as FindTraces, but returns only the list |
| 43 | + // of matching trace IDs. |
| 44 | + // |
| 45 | + // If no matching traces are found, the function returns (nil, nil). |
| 46 | + FindTraceIDs(ctx context.Context, query TraceQueryParameters) ([]pcommon.TraceID, error) |
| 47 | +} |
| 48 | + |
| 49 | +// TraceQueryParameters contains parameters of a trace query. |
| 50 | +type TraceQueryParameters struct { |
| 51 | + ServiceName string |
| 52 | + OperationName string |
| 53 | + Tags map[string]string |
| 54 | + StartTimeMin time.Time |
| 55 | + StartTimeMax time.Time |
| 56 | + DurationMin time.Duration |
| 57 | + DurationMax time.Duration |
| 58 | + NumTraces int |
| 59 | +} |
| 60 | + |
| 61 | +// OperationQueryParameters contains parameters of query operations, empty spanKind means get operations for all kinds of span. |
| 62 | +type OperationQueryParameters struct { |
| 63 | + ServiceName string |
| 64 | + SpanKind string |
| 65 | +} |
| 66 | + |
| 67 | +// Operation contains operation name and span kind |
| 68 | +type Operation struct { |
| 69 | + Name string |
| 70 | + SpanKind string |
| 71 | +} |
0 commit comments