Skip to content
Merged
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
12 changes: 7 additions & 5 deletions controller/getchangedtargets.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,11 @@ func (c *controller) cacheComparedTargets(logger *zap.Logger, request *pb.GetCha
// are re-mapped into a canonical per-call ID namespace so the response metadata
// only carries the names actually referenced. See internal/targetdiff for the
// classification and distance rules.
func (c *controller) compareTargetGraphs(ctx context.Context, e *metrics.Emitter, logger *zap.Logger, firstGraph, secondGraph []entity.GetTargetGraphResponse, maxDist int32) (_ []entity.GetChangedTargetsResponse, retErr error) {
op := metrics.Begin(e, opCompareTargetGraphs, metrics.SlowDurationBuckets)
defer func() { op.Complete(retErr) }()
func (c *controller) compareTargetGraphs(ctx context.Context, e *metrics.Emitter, logger *zap.Logger, firstGraph, secondGraph []entity.GetTargetGraphResponse, maxDist int32) ([]entity.GetChangedTargetsResponse, error) {
compareStart := time.Now()
defer func() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not using Begin/Complete cause the error retruned will be emitted in top controller.GetChangedTargets

e.DurationHistogram(opGetChangedTargets, "compare_duration", metrics.SlowDurationBuckets).RecordDuration(time.Since(compareStart))
}()
logger.Info("compareTargetGraphs: Computing differences between target graphs")

// 1) Decode each stream into a semantic graph keyed by canonical target name.
Expand Down Expand Up @@ -406,7 +408,7 @@ func (c *controller) compareTargetGraphs(ctx context.Context, e *metrics.Emitter
}
secondTargetsByID = nil
secondMetadata = nil
e.DurationHistogram(opCompareTargetGraphs, "decode_duration", metrics.FastDurationBuckets).RecordDuration(time.Since(decodeStart))
e.DurationHistogram(opGetChangedTargets, "decode_duration", metrics.FastDurationBuckets).RecordDuration(time.Since(decodeStart))

// 2) Compare the two semantic graphs.
diffStart := time.Now()
Expand All @@ -421,7 +423,7 @@ func (c *controller) compareTargetGraphs(ctx context.Context, e *metrics.Emitter
// Release the input graphs; only result is needed from here on.
before = nil
after = nil
e.DurationHistogram(opCompareTargetGraphs, "diff_duration", metrics.FastDurationBuckets).RecordDuration(time.Since(diffStart))
e.DurationHistogram(opGetChangedTargets, "diff_duration", metrics.FastDurationBuckets).RecordDuration(time.Since(diffStart))
e.ValueHistogram(opGetChangedTargets, "target_count", metrics.LargeCountBuckets).RecordValue(float64(len(result.ChangedTargets)))

if ctx.Err() != nil {
Expand Down
1 change: 0 additions & 1 deletion controller/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const (
opGetTargetGraph = "get_target_graph"
opGetChangedTargets = "get_changed_targets"
opGetChangedTargetGraph = "get_changed_target_graph"
opCompareTargetGraphs = "compare_target_graphs"
)

// Cache-lookup metric names. Each is emitted under its parent RPC op with a
Expand Down
Loading