Skip to content

Commit

Permalink
remove IsIngestedBy spans for now (highlight#9640)
Browse files Browse the repository at this point in the history
## Summary
- lots of `IsIngestedBy` spans are getting created while ingesting a
large number of historical logs, disable these for now
<!--
Ideally, there is an attached GitHub issue that will describe the "why".

If relevant, use this section to call out any additional information
you'd like to _highlight_ to the reviewer.
-->

## How did you test this change?
- run unit tests in `sampling_test.go` to make sure nothing is affected
<!--
Frontend - Leave a screencast or a screenshot to visually describe the
changes.
-->

## Are there any deployment considerations?
- no
<!--
 Backend - Do we need to consider migrations or backfilling data?
-->

## Does this work require review from our design team?
- no
<!--
 Request review from julian-highlight / our design team 
-->
  • Loading branch information
mayberryzane authored and giraffekey committed Nov 21, 2024
1 parent 25b0e2c commit 5cd6951
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 76 deletions.
66 changes: 0 additions & 66 deletions backend/public-graph/graph/sampling.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"regexp"
"time"

trace2 "go.opentelemetry.io/otel/trace"

"github.com/aws/smithy-go/ptr"
"github.com/google/uuid"
e "github.com/pkg/errors"
Expand All @@ -20,34 +18,16 @@ import (
"github.com/highlight-run/highlight/backend/parser"
privateModel "github.com/highlight-run/highlight/backend/private-graph/graph/model"
modelInputs "github.com/highlight-run/highlight/backend/public-graph/graph/model"
"github.com/highlight-run/highlight/backend/util"
"github.com/highlight/highlight/sdk/highlight-go"
)

func (r *Resolver) IsTraceIngested(ctx context.Context, trace *clickhouse.TraceRow) bool {
span := util.StartSpan(
"IsIngestedBy", util.ResourceName("sampling"), util.WithHighlightTracingDisabled(true), util.WithSpanKind(trace2.SpanKindServer),
util.Tag(highlight.ProjectIDAttribute, trace.ProjectId),
util.Tag(highlight.TraceTypeAttribute, highlight.TraceTypeHighlightInternal),
util.Tag(highlight.TraceKeyAttribute, trace.UUID),
util.Tag("product", privateModel.ProductTypeTraces),
util.Tag("ingested", true),
)
defer span.Finish()

if !r.IsTraceIngestedByFilter(ctx, trace) {
span.SetAttribute("ingested", false)
span.SetAttribute("reason", privateModel.IngestReasonFilter)
return false
}
if !r.IsTraceIngestedBySample(ctx, trace) {
span.SetAttribute("ingested", false)
span.SetAttribute("reason", privateModel.IngestReasonSample)
return false
}
if !r.IsTraceIngestedByRateLimit(ctx, trace) {
span.SetAttribute("ingested", false)
span.SetAttribute("reason", privateModel.IngestReasonRate)
return false
}
return true
Expand All @@ -66,29 +46,13 @@ func (r *Resolver) IsTraceIngestedByFilter(ctx context.Context, trace *clickhous
}

func (r *Resolver) IsLogIngested(ctx context.Context, logRow *clickhouse.LogRow) bool {
span := util.StartSpan(
"IsIngestedBy", util.ResourceName("sampling"), util.WithSpanKind(trace2.SpanKindServer),
util.Tag(highlight.ProjectIDAttribute, logRow.ProjectId),
util.Tag(highlight.TraceTypeAttribute, highlight.TraceTypeHighlightInternal),
util.Tag(highlight.TraceKeyAttribute, logRow.UUID),
util.Tag("product", privateModel.ProductTypeLogs),
util.Tag("ingested", true),
)
defer span.Finish()

if !r.IsLogIngestedBySample(ctx, logRow) {
span.SetAttribute("ingested", false)
span.SetAttribute("reason", privateModel.IngestReasonSample)
return false
}
if !r.IsLogIngestedByFilter(ctx, logRow) {
span.SetAttribute("ingested", false)
span.SetAttribute("reason", privateModel.IngestReasonFilter)
return false
}
if !r.IsLogIngestedByRateLimit(ctx, logRow) {
span.SetAttribute("ingested", false)
span.SetAttribute("reason", privateModel.IngestReasonRate)
return false
}
return true
Expand Down Expand Up @@ -136,29 +100,13 @@ func (r *Resolver) IsFrontendErrorIngested(ctx context.Context, projectID int, s
}

func (r *Resolver) IsErrorIngested(ctx context.Context, projectID int, errorObject *modelInputs.BackendErrorObjectInput) bool {
span := util.StartSpan(
"IsIngestedBy", util.ResourceName("sampling"), util.WithSpanKind(trace2.SpanKindServer),
util.Tag(highlight.ProjectIDAttribute, projectID),
util.Tag(highlight.TraceTypeAttribute, highlight.TraceTypeHighlightInternal),
util.Tag(highlight.TraceKeyAttribute, getErrorObjectID(errorObject)),
util.Tag("product", privateModel.ProductTypeErrors),
util.Tag("ingested", true),
)
defer span.Finish()

if !r.IsErrorIngestedBySample(ctx, projectID, errorObject) {
span.SetAttribute("ingested", false)
span.SetAttribute("reason", privateModel.IngestReasonFilter)
return false
}
if !r.IsErrorIngestedByFilter(ctx, projectID, errorObject) {
span.SetAttribute("ingested", false)
span.SetAttribute("reason", privateModel.IngestReasonFilter)
return false
}
if !r.IsErrorIngestedByRateLimit(ctx, projectID, errorObject) {
span.SetAttribute("ingested", false)
span.SetAttribute("reason", privateModel.IngestReasonFilter)
return false
}
return true
Expand Down Expand Up @@ -198,16 +146,6 @@ func (r *Resolver) IsErrorIngestedByFilter(ctx context.Context, projectID int, e
}

func (r *Resolver) IsSessionExcluded(ctx context.Context, s *model.Session, sessionHasErrors bool) (bool, *privateModel.SessionExcludedReason) {
span := util.StartSpan(
"IsIngestedBy", util.ResourceName("sampling"), util.WithSpanKind(trace2.SpanKindServer),
util.Tag(highlight.ProjectIDAttribute, s.ProjectID),
util.Tag(highlight.TraceTypeAttribute, highlight.TraceTypeHighlightInternal),
util.Tag(highlight.TraceKeyAttribute, s.ID),
util.Tag("product", privateModel.ProductTypeSessions),
util.Tag("ingested", true),
)
defer span.Finish()

var excluded bool
var reason privateModel.SessionExcludedReason

Expand Down Expand Up @@ -247,10 +185,6 @@ func (r *Resolver) IsSessionExcluded(ctx context.Context, s *model.Session, sess
reason = privateModel.SessionExcludedReasonRateLimitMinute
}

if excluded {
span.SetAttribute("ingested", false)
span.SetAttribute("reason", reason)
}
return excluded, &reason
}

Expand Down
10 changes: 0 additions & 10 deletions backend/worker/kafka_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/highlight-run/highlight/backend/model"
privateModel "github.com/highlight-run/highlight/backend/private-graph/graph/model"
"github.com/highlight-run/highlight/backend/util"
"github.com/highlight/highlight/sdk/highlight-go"
hmetric "github.com/highlight/highlight/sdk/highlight-go/metric"
e "github.com/pkg/errors"
"github.com/samber/lo"
Expand Down Expand Up @@ -532,25 +531,16 @@ func (k *KafkaBatchWorker) flushDataSync(ctx context.Context, sessionIds []int,
session.Fields = lo.Map(sessionToFields[session.ID], func(sf *sessionField, _ int) *model.Field {
return fieldsById[sf.FieldID]
})
span := util.StartSpan(
"IsIngestedBy", util.ResourceName("sampling"),
util.Tag(highlight.ProjectIDAttribute, session.ProjectID),
util.Tag(highlight.TraceTypeAttribute, highlight.TraceTypeHighlightInternal),
util.Tag("product", privateModel.ProductTypeSessions),
)
// fields are populated, so calculate whether session is excluded
if k.Worker.PublicResolver.IsSessionExcludedByFilter(ctx, session) {
reason := privateModel.SessionExcludedReasonExclusionFilter
session.Excluded = true
session.ExcludedReason = &reason
span.SetAttribute("reason", session.ExcludedReason)
if err := k.Worker.PublicResolver.DB.WithContext(ctx).Model(&model.Session{Model: model.Model{ID: session.ID}}).
Select("Excluded", "ExcludedReason").Updates(&session).Error; err != nil {
return err
}
}
span.SetAttribute("ingested", !session.Excluded)
span.Finish()
}

allSessionObjs = append(allSessionObjs, sessionObjs...)
Expand Down

0 comments on commit 5cd6951

Please sign in to comment.