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

feat: expand fsm instrumentation #2177

Merged
merged 11 commits into from
Jul 29, 2024
Merged

feat: expand fsm instrumentation #2177

merged 11 commits into from
Jul 29, 2024

Conversation

jonathanj-square
Copy link
Contributor

@jonathanj-square jonathanj-square commented Jul 26, 2024

  • extends the fsm_instances table scheme to help distinguish between insert and update.
  • track active fsm transitions
  • track fsm transition attempts

Issue: #2194

@jonathanj-square jonathanj-square requested review from a team and deniseli and removed request for a team July 26, 2024 00:12
…rmine whether the upsert operation is an update or an insert.

continued fsm instrumentation
@ftl-robot ftl-robot mentioned this pull request Jul 26, 2024
@@ -0,0 +1,6 @@
-- migrate:up

ALTER TABLE fsm_instances
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice.

@@ -15,6 +16,8 @@ import (
)

func TestSendFSMEvent(t *testing.T) {
_ = observability.InitControllerObservability()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wasn't sure it was a good idea, but I think that having to do this everywhere is a good argument for statically initialising observability at init() time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah totally agree. That would not be fun to have to remember this for every test that might have a metric. init() sounds good to me. Will probably clean up quite a bit of this plumbing too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

feedback adopted

Comment on lines 21 to 23
func FSM() *FSMMetrics {
return fsm
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can probably just expose the public var here vs. having a wrapper func. This is likely more true with an init() approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

feedback adopted

backend/controller/observability/fsm.go Show resolved Hide resolved
if result.instancesActive, err = result.meter.Int64UpDownCounter(
counter,
metric.WithDescription("counts the number of active FSM instances")); err != nil {
errs = errors.Join(errs, fmt.Errorf("%q counter init failed; falling back to noop: %w", counter, err))
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to dedup the repeated code, what do you think about something like:

    errs = joinInitErrors(errs, err, counter)
    ...
}

func joinInitErrors(...) error {
    return errors.Join(errs, fmt.Errorf("%q counter init failed; falling back to noop: %w", counter, err))
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adopted

fsmCounters.instancesActive, err = fsmMeter.Int64UpDownCounter(
fmt.Sprintf("%s.instances.active", fsmMeterName),
metric.WithDescription("counts the number of active FSM instances"))
result.meter = otel.Meter("ftl.fsm")
Copy link
Contributor

Choose a reason for hiding this comment

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

result.meter = otel.Meter(fsmMeterName)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adopted

@jonathanj-square jonathanj-square merged commit 4857e9c into main Jul 29, 2024
61 checks passed
@jonathanj-square jonathanj-square deleted the jonathanj/otel/fsm2 branch July 29, 2024 22:38
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.

4 participants