Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] Remove archive reader and writer from remote storage grpc handler #6611

Merged
merged 6 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions cmd/remote-storage/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ type storageFactory interface {
CreateSpanReader() (spanstore.Reader, error)
CreateSpanWriter() (spanstore.Writer, error)
CreateDependencyReader() (dependencystore.Reader, error)
InitArchiveStorage(logger *zap.Logger) (spanstore.Reader, spanstore.Writer)
}

// NewServer creates and initializes Server.
func NewServer(options *Options, storageFactory storageFactory, tm *tenancy.Manager, telset telemetry.Settings) (*Server, error) {
handler, err := createGRPCHandler(storageFactory, telset.Logger)
handler, err := createGRPCHandler(storageFactory)
if err != nil {
return nil, err
}
Expand All @@ -60,7 +59,7 @@ func NewServer(options *Options, storageFactory storageFactory, tm *tenancy.Mana
}, nil
}

func createGRPCHandler(f storageFactory, logger *zap.Logger) (*shared.GRPCHandler, error) {
func createGRPCHandler(f storageFactory) (*shared.GRPCHandler, error) {
reader, err := f.CreateSpanReader()
if err != nil {
return nil, err
Expand All @@ -81,10 +80,6 @@ func createGRPCHandler(f storageFactory, logger *zap.Logger) (*shared.GRPCHandle
StreamingSpanWriter: func() spanstore.Writer { return nil },
}

ar, aw := f.InitArchiveStorage(logger)
impl.ArchiveSpanReader = func() spanstore.Reader { return ar }
impl.ArchiveSpanWriter = func() spanstore.Writer { return aw }
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved

handler := shared.NewGRPCHandler(impl)
return handler, nil
}
Expand Down
40 changes: 4 additions & 36 deletions plugin/storage/grpc/shared/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
SpanWriter func() spanstore.Writer
DependencyReader func() dependencystore.Reader

ArchiveSpanReader func() spanstore.Reader
ArchiveSpanWriter func() spanstore.Writer

StreamingSpanWriter func() spanstore.Writer
}

Expand Down Expand Up @@ -244,45 +241,16 @@

func (s *GRPCHandler) Capabilities(context.Context, *storage_v1.CapabilitiesRequest) (*storage_v1.CapabilitiesResponse, error) {
return &storage_v1.CapabilitiesResponse{
ArchiveSpanReader: s.impl.ArchiveSpanReader() != nil,
ArchiveSpanWriter: s.impl.ArchiveSpanWriter() != nil,
ArchiveSpanReader: s.impl.SpanReader() != nil,
ArchiveSpanWriter: s.impl.SpanWriter() != nil,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro should we remove these from the capabilities response altogether?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can mark them deprecated in the .proto definition and return false here

StreamingSpanWriter: s.impl.StreamingSpanWriter() != nil,
}, nil
}

func (s *GRPCHandler) GetArchiveTrace(r *storage_v1.GetTraceRequest, stream storage_v1.ArchiveSpanReaderPlugin_GetArchiveTraceServer) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this return not-implemented error instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro are we okay with making that breaking change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will never be called by grpc-storage

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro is there a reason we can't just remove this then?

reader := s.impl.ArchiveSpanReader()
if reader == nil {
return status.Error(codes.Unimplemented, "not implemented")
}
trace, err := reader.GetTrace(stream.Context(), spanstore.GetTraceParameters{
TraceID: r.TraceID,
StartTime: r.StartTime,
EndTime: r.EndTime,
})
if errors.Is(err, spanstore.ErrTraceNotFound) {
return status.Error(codes.NotFound, spanstore.ErrTraceNotFound.Error())
}
if err != nil {
return err
}

err = s.sendSpans(trace.Spans, stream.Send)
if err != nil {
return err
}

return nil
return s.GetTrace(r, stream)

Check warning on line 251 in plugin/storage/grpc/shared/grpc_handler.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/grpc/shared/grpc_handler.go#L251

Added line #L251 was not covered by tests
}

func (s *GRPCHandler) WriteArchiveSpan(ctx context.Context, r *storage_v1.WriteSpanRequest) (*storage_v1.WriteSpanResponse, error) {
writer := s.impl.ArchiveSpanWriter()
if writer == nil {
return nil, status.Error(codes.Unimplemented, "not implemented")
}
err := writer.WriteSpan(ctx, r.Span)
if err != nil {
return nil, err
}
return &storage_v1.WriteSpanResponse{}, nil
return s.WriteSpan(ctx, r)

Check warning on line 255 in plugin/storage/grpc/shared/grpc_handler.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/grpc/shared/grpc_handler.go#L255

Added line #L255 was not covered by tests
}
Loading