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: metric integration for fsm #2155

Merged
merged 2 commits into from
Jul 25, 2024
Merged

feat: metric integration for fsm #2155

merged 2 commits into from
Jul 25, 2024

Conversation

jonathanj-square
Copy link
Contributor

No description provided.

@ftl-robot ftl-robot mentioned this pull request Jul 24, 2024
Copy link
Collaborator

@wesbillman wesbillman left a comment

Choose a reason for hiding this comment

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

Nice! I think the structure is getting there!

package observability

const (
fsmRefAttribute string = "ftl.fsm.ref"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given this is only used by fsm.go it could go there instead of this shared attributes file (unless there's plans to share it in the future).

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we don't currently have any shared attributes then we can leave this file off for now and add it back if needed in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved

Comment on lines 3 to 11
func Init() {
InitFSMMetrics()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this should be something like:

func InitControllerObservability(ctx context.Context) {
    err := internalobs.Init(ctx, .....)
    // check errors
    err := InitFSMMetrics(...)
    // check errors
}

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 that name

Comment on lines 68 to 69
observability.Init()

Copy link
Collaborator

Choose a reason for hiding this comment

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

The internal package should not depend on backend/controller/... things at all (or runner, etc.). This would create internal dependencies on controller and runner. Instead the backend stuff should use internal as needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to controller.go:New

@@ -1,18 +1,5 @@
package metrics
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this file should move up one level and be at the internal/observability level instead of internal/observability/metrics that way we can use shared attributes in traces as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved

Comment on lines 22 to 23
func InitFSMMetrics() {
fsmCounters.instancesActive, _ = fsmMeter.Int64UpDownCounter(
Copy link
Collaborator

Choose a reason for hiding this comment

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

func InitFSMMetrics() should return an error so it can be checked.

Copy link
Contributor Author

@jonathanj-square jonathanj-square Jul 24, 2024

Choose a reason for hiding this comment

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

agreed; just going for a quicker feedback turn around on other aspects of the PR by leaving that as a TODO comment, will return to it before exiting draft mode on this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the error handling

Copy link
Collaborator

@wesbillman wesbillman left a comment

Choose a reason for hiding this comment

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

Nice! This structure looks good to me!

Comment on lines +230 to +232
if err := observability.InitControllerObservability(); err != nil {
log.FromContext(ctx).Warnf("failed to initialize controller observability: %v", err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This works for now, but we might want to consider combining this and the observability.Init() that's currently in ftl-controller/main ftl-runner/main and cmd_serve files now. We can iterate on that in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will combine in a fast follow change that completes the fsm metric instrumentation

@safeer
Copy link
Contributor

safeer commented Jul 25, 2024

LGTM

I do like @wesbillman simplification to have observability's init also initialize the various metrics. Structurally, could still keep it clean and do something like
observability.FSM().InstanceCreated(ctx, fsm)

@jonathanj-square jonathanj-square marked this pull request as ready for review July 25, 2024 18:09
@jonathanj-square jonathanj-square requested review from a team and matt2e and removed request for a team July 25, 2024 18:09
@jonathanj-square jonathanj-square merged commit cbc4118 into main Jul 25, 2024
59 checks passed
@jonathanj-square jonathanj-square deleted the jonathanj/otel/fsm branch July 25, 2024 18:16
@deniseli
Copy link
Contributor

Linking issue: #2194

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