Skip to content

refactor(orchestrator): route metrics through observability/metrics Emitter#216

Merged
xytan0056 merged 2 commits into
mainfrom
pr3-orchestrator-metrics
Jul 21, 2026
Merged

refactor(orchestrator): route metrics through observability/metrics Emitter#216
xytan0056 merged 2 commits into
mainfrom
pr3-orchestrator-metrics

Conversation

@xytan0056

@xytan0056 xytan0056 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Ports native_orchestrator's GetTargetGraph off raw tally.Scope to *metrics.Emitter with the Begin/Complete helper.

  • Params keeps Scope tally.Scope; the orchestrator self-subscopes to orchestrator and builds its own emitter (still forwards the scope to the graph runner).
  • start + result-tagged finish (replaces calls/success/failure).
  • Per-step duration histograms under get_target_graph: lease_duration, checkout_duration, apply_requests_duration, cache_read_duration, compute_duration, cache_write_duration.

Stacked on #215.

@xytan0056
xytan0056 requested review from a team as code owners July 17, 2026 21:04
@xytan0056
xytan0056 force-pushed the pr3-orchestrator-metrics branch 3 times, most recently from 3b9c7e9 to 97b3839 Compare July 17, 2026 21:47
@xytan0056
xytan0056 force-pushed the pr2-controller-metrics branch from d62bb17 to 7a8d276 Compare July 17, 2026 23:10
@xytan0056
xytan0056 force-pushed the pr3-orchestrator-metrics branch from 97b3839 to 57d3c09 Compare July 17, 2026 23:10
@xytan0056 xytan0056 changed the title [WIP] refactor(orchestrator): route metrics through observability/metrics Emitter refactor(orchestrator): route metrics through observability/metrics Emitter Jul 17, 2026
@xytan0056
xytan0056 force-pushed the pr2-controller-metrics branch from 7a8d276 to e77a1cb Compare July 21, 2026 06:30
return nil, fmt.Errorf("no repository configuration found for remote %q", remote)
}
leaseStart := time.Now()
ws, err := b.repoManager.Lease(ctx, build)

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.

TODO: emit metrics before Lease error

Comment thread orchestrator/native_orchestrator.go Outdated
scope = tally.NoopScope
}
scope = scope.SubScope("orchestrator")
emitter, _ := metrics.New(scope)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we fallback on metrics.Nop()? Seems like we're always silently discarding the error. I think we should either return the error or fallback to Nop().

Comment thread orchestrator/native_orchestrator.go Outdated
scope.Counter("success").Inc(1)
}
}()
op := metrics.Begin(b.emitter, opGetTargetGraph, stepDurationBuckets)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we have the repo tagged in the emitter as well?

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.

should already be tagged in controller. but good piont, just in case NewNativeOrchestrator is called separately

Comment thread orchestrator/metrics.go Outdated
)

// opGetTargetGraph is snake_cased after the Orchestrator.GetTargetGraph method.
const opGetTargetGraph = "get_target_graph"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
const opGetTargetGraph = "get_target_graph"
const _opGetTargetGraph = "get_target_graph"

Comment thread orchestrator/metrics.go Outdated
// stepDurationBuckets covers whole-operation and individual pipeline steps
// (lease, checkout, apply, cache read/write, compute). A compute on a large
// repo can run for hours, so the range extends to ~4h: exponential 1ms..~4h.
var stepDurationBuckets = tally.MustMakeExponentialDurationBuckets(time.Millisecond, 3, 16)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
var stepDurationBuckets = tally.MustMakeExponentialDurationBuckets(time.Millisecond, 3, 16)
var _stepDurationBuckets = tally.MustMakeExponentialDurationBuckets(time.Millisecond, 3, 16)

@xytan0056
xytan0056 force-pushed the pr2-controller-metrics branch from e77a1cb to 2257789 Compare July 21, 2026 20:26
@xytan0056
xytan0056 force-pushed the pr3-orchestrator-metrics branch from 57d3c09 to a9b63ab Compare July 21, 2026 20:51
@xytan0056
xytan0056 changed the base branch from pr2-controller-metrics to main July 21, 2026 20:51
@xytan0056
xytan0056 force-pushed the pr3-orchestrator-metrics branch from a9b63ab to 56b4726 Compare July 21, 2026 20:59
…mitter

Port native_orchestrator's GetTargetGraph metrics off raw tally.Scope to the
Begin/Complete lifecycle helper.

- Params keeps Scope tally.Scope; the orchestrator self-subscopes to
  "orchestrator" and builds its own emitter (still forwards the scope to the
  graph runner).
- start + result-tagged finish (replaces calls/success/failure); recordFailure
  keeps the failure_type/failure_reason axis as a "failures" counter.
- Buckets are package-level in orchestrator/metrics.go.
@xytan0056
xytan0056 force-pushed the pr3-orchestrator-metrics branch from 56b4726 to 9a82429 Compare July 21, 2026 22:00
@xytan0056
xytan0056 merged commit 366ca31 into main Jul 21, 2026
10 checks passed
xytan0056 added a commit that referenced this pull request Jul 21, 2026
…itter (#217)

Ports the native graph runner off raw `tally.Scope` to
`*metrics.Emitter`.

- `Params` keeps `Scope tally.Scope`; the runner builds its own emitter
and emits under op `graph_runner` (nested beneath the orchestrator scope
it's handed).
- Three phase `Timer`s → `DurationHistogram` (`bazel_query_duration`,
`git_file_hashes_duration`, `target_hash_duration`); `target_count`
`Gauge` → `ValueHistogram`.
- Buckets package-level in `graphrunner/metrics.go`. `core/bazel`
intentionally left uninstrumented — the query is already timed here.

 1. #216.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants