Skip to content

Commit

Permalink
construct the storage_v2 spanstore interface structure
Browse files Browse the repository at this point in the history
  • Loading branch information
james-ryans committed Apr 25, 2024
1 parent 43d529c commit cd16c67
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
18 changes: 18 additions & 0 deletions storage_v2/spanstore/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package spanstore

// Factory defines an interface for a factory that can create implementations of different storage components.
// Implementations are also encouraged to implement plugin.Configurable interface.
type Factory interface {
// Initialize performs internal initialization of the factory, such as opening connections to the backend store.
// It is called after all configuration of the factory itself has been done.
Initialize() error

// CreateSpanReader creates a spanstore.Reader.
CreateTraceReader() (Reader, error)

// CreateSpanWriter creates a spanstore.Writer.
CreateTraceWriter() (Writer, error)
}
65 changes: 65 additions & 0 deletions storage_v2/spanstore/reader.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package spanstore

import (
"context"
"time"

"github.com/jaegertracing/jaeger/model"
)

// Reader finds and loads traces and other data from storage.
type Reader interface {
// GetTrace retrieves the trace with a given id.
//
// If no spans are stored for this trace, it returns ErrTraceNotFound.
GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error)

// GetServices returns all service names known to the backend from spans
// within its retention period.
GetServices(ctx context.Context) ([]string, error)

// GetOperations returns all operation names for a given service
// known to the backend from spans within its retention period.
GetOperations(ctx context.Context, query OperationQueryParameters) ([]Operation, error)

// FindTraces returns all traces matching query parameters. There's currently
// an implementation-dependent abiguity whether all query filters (such as
// multiple tags) must apply to the same span within a trace, or can be satisfied
// by different spans.
//
// If no matching traces are found, the function returns (nil, nil).
FindTraces(ctx context.Context, query *TraceQueryParameters) ([]*model.Trace, error)

// FindTraceIDs does the same search as FindTraces, but returns only the list
// of matching trace IDs.
//
// If no matching traces are found, the function returns (nil, nil).
FindTraceIDs(ctx context.Context, query *TraceQueryParameters) ([]model.TraceID, error)
}

// TraceQueryParameters contains parameters of a trace query.
type TraceQueryParameters struct {
ServiceName string
OperationName string
Tags map[string]string
StartTimeMin time.Time
StartTimeMax time.Time
DurationMin time.Duration
DurationMax time.Duration
NumTraces int
}

// OperationQueryParameters contains parameters of query operations, empty spanKind means get operations for all kinds of span.
type OperationQueryParameters struct {
ServiceName string
SpanKind string
}

// Operation contains operation name and span kind
type Operation struct {
Name string
SpanKind string
}
17 changes: 17 additions & 0 deletions storage_v2/spanstore/writer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package spanstore

import (
"context"

"go.opentelemetry.io/collector/pdata/ptrace"
)

// Writer writes spans to storage.
type Writer interface {
// WriteTrace writes batches of spans at once and
// compatible with OTLP Exporter API.
WriteTraces(ctx context.Context, td ptrace.Traces) error
}

0 comments on commit cd16c67

Please sign in to comment.