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

Adding tracing to CycleDetectionCheckResolver #1388

Merged
merged 3 commits into from
Feb 28, 2024
Merged

Conversation

willvedd
Copy link
Contributor

@willvedd willvedd commented Feb 23, 2024

Description

Adding tracing to the CycleDetectionCheckResolver because we forgot to add it during its recent introduction into the codebase. This tracing provides important insight into the graph traversal algorithm during check resolution. Similar tracing is already implemented on the LocalChecker and CachedCheckResolver (see: #1331).

References

Original PR: #1375
Similar PR: #1331

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

@willvedd willvedd requested a review from a team as a code owner February 23, 2024 22:53
@jon-whit
Copy link
Member

jon-whit commented Feb 27, 2024

nit (non-blocking) - @willvedd should we add a test for this? WDYT?

// cycle_check_resolver_test.go

func TestResolveCheck_SpanCreation(t *testing.T) {
    	exporter := tracetest.NewInMemoryExporter()
	processor := trace.NewSimpleSpanProcessor(exporter)
	provider := trace.NewTracerProvider(
		trace.WithSampler(trace.AlwaysSample()),
		trace.WithSpanProcessor(processor),
	)

	otel.SetTracerProvider(provider)
	
	var cycleDetectionCheckResolver CheckResolver

        cycleDetectionCheckResolver.ResolveCheck(...)

        spans := exporter.GetSpans()
        for _, span := range spans {
            // ensure the CycleDetectionCheckResolver#ResolveCheck span is in the slice
        }

        ...
}

@willvedd
Copy link
Contributor Author

Re: a test for the spans, I think its too heavy-handed for what's being added. There isn't precedent for it anyway.

The whole intent of this PR is to bring consistency and observability to all our resolvers. This is something we forgot to do when we introduced the CycleDetectionCheckResolver.

@willvedd willvedd merged commit 52bf086 into main Feb 28, 2024
13 checks passed
@willvedd willvedd deleted the cycle-resolver-tracing branch February 28, 2024 14:01
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.

None yet

3 participants