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

Instrument calls to GraphQL API and Flaps #2233

Merged
merged 3 commits into from
May 5, 2023
Merged

Conversation

haileys
Copy link
Contributor

@haileys haileys commented May 5, 2023

No description provided.

@haileys haileys force-pushed the rpc-instrumentation branch from a8c0ed9 to f31584a Compare May 5, 2023 01:28
@@ -0,0 +1,50 @@
package instrument
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to introduce this new package under internal to break what would have been a circular package dependency between api and internal/metrics. I think it's a nice result though.

}

func RecordCommandContext(ctx context.Context) {
mu.Lock()
defer mu.Unlock()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unrelated to this PR, but found we were missing mutex lock here. Unlikely to cause real problems, but strictly speaking, it is necessary.

@haileys
Copy link
Contributor Author

haileys commented May 5, 2023

The lint check is currently failing with:

github.com/superfly/flyctl/api imports
	github.com/superfly/flyctl/internal/instrument: module github.com/superfly/flyctl@latest found (v0.0.553), but does not contain package github.com/superfly/flyctl/internal/instrument

I don't understand Go modules well enough to know what the problem is here. Anyone have any tips for me?

api/client.go Outdated
@@ -12,6 +12,7 @@ import (
"strings"

genq "github.com/Khan/genqlient/graphql"
"github.com/superfly/flyctl/internal/instrument"
Copy link
Member

@kzys kzys May 5, 2023

Choose a reason for hiding this comment

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

In Go, packages (things you declare with package xxx) and modules (things on go.mod) are different. Module-wise, github.com/superfly/flyctl/api depends github.com/superfly/flyctl but the latter also depends the former.

If flyctl mostly calls RunWithContext() and few methods, you can define a wrapper struct like https://github.com/containerd/containerd/blob/6020903f2c2f0b6b148b02ca7bdd1cd9c6efac3d/pkg/cri/instrument/instrumented_service.go#L50 to call GraphQL.Begin/End. Another option may be defining an interface for instrumentation and pass its implementation, which may be something similar to https://github.com/open-telemetry/opentelemetry-go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh interesting. It looks like api is a special case here being mentioned in go.mod?

@haileys haileys force-pushed the rpc-instrumentation branch from 8b2910d to 5e447c4 Compare May 5, 2023 02:16
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