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

modified: reader getting operations by spanKind #5243

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions plugin/storage/es/spanstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (s *SpanReader) GetOperations(
defer span.End()
currentTime := time.Now()
jaegerIndices := s.timeRangeIndices(s.serviceIndexPrefix, s.serviceIndexDateLayout, currentTime.Add(-s.maxSpanAge), currentTime, s.serviceIndexRolloverFrequency)
operations, err := s.serviceOperationStorage.getOperations(ctx, jaegerIndices, query.ServiceName, s.maxDocCount)
operations, err := s.serviceOperationStorage.getOperations(ctx, jaegerIndices, query, s.maxDocCount)
if err != nil {
return nil, err
}
Expand All @@ -312,7 +312,8 @@ func (s *SpanReader) GetOperations(
var result []spanstore.Operation
for _, operation := range operations {
result = append(result, spanstore.Operation{
Name: operation,
Name: operation,
SpanKind: query.SpanKind,
})
}
return result, err
Expand Down
18 changes: 15 additions & 3 deletions plugin/storage/es/spanstore/service_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"hash/fnv"
"strings"
"time"

"github.com/olivere/elastic"
Expand All @@ -28,6 +29,7 @@ import (
"github.com/jaegertracing/jaeger/pkg/cache"
"github.com/jaegertracing/jaeger/pkg/es"
"github.com/jaegertracing/jaeger/plugin/storage/es/spanstore/dbmodel"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

const (
Expand Down Expand Up @@ -106,8 +108,8 @@ func getServicesAggregation(maxDocCount int) elastic.Query {
Size(maxDocCount) // ES deprecated size omission for aggregating all. https://github.com/elastic/elasticsearch/issues/18838
}

func (s *ServiceOperationStorage) getOperations(context context.Context, indices []string, service string, maxDocCount int) ([]string, error) {
serviceQuery := elastic.NewTermQuery(serviceName, service)
func (s *ServiceOperationStorage) getOperations(context context.Context, indices []string, service spanstore.OperationQueryParameters, maxDocCount int) ([]string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (s *ServiceOperationStorage) getOperations(context context.Context, indices []string, service spanstore.OperationQueryParameters, maxDocCount int) ([]string, error) {
func (s *ServiceOperationStorage) getOperations(
context context.Context,
indices []string,
query spanstore.OperationQueryParameters,
maxDocCount int,
) ([]string, error) {

serviceQuery := elastic.NewTermQuery(serviceName, service.ServiceName)
serviceFilter := getOperationsAggregation(maxDocCount)

searchService := s.client().Search(indices...).
Expand All @@ -127,7 +129,17 @@ func (s *ServiceOperationStorage) getOperations(context context.Context, indices
if !found {
return nil, errors.New("could not find aggregation of " + operationsAggregation)
}
operationNamesBucket := bucket.Buckets

var operationNamesBucket []*elastic.AggregationBucketKeyItem
if service.SpanKind != "" {
for _, bucket := range bucket.Buckets {
if strings.Contains(bucket.Key.(string), service.SpanKind) {
operationNamesBucket = append(operationNamesBucket, bucket)
}
}
} else {
operationNamesBucket = bucket.Buckets
}
return bucketToStringArray(operationNamesBucket)
}

Expand Down