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

Add builtins tracing for ds calls #66

Merged
merged 4 commits into from
Mar 29, 2023
Merged

Add builtins tracing for ds calls #66

merged 4 commits into from
Mar 29, 2023

Conversation

carabasdaniel
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Mar 29, 2023

Pull Request Test Coverage Report for Build 4557094471

  • 30 of 62 (48.39%) changed or added relevant lines in 8 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.2%) to 38.524%

Changes Missing Coverage Covered Lines Changed/Added Lines %
builtins/edge/ds/graph.go 0 1 0.0%
builtins/edge/ds/identity.go 0 1 0.0%
builtins/edge/ds/object.go 0 1 0.0%
builtins/edge/ds/relation.go 0 1 0.0%
builtins/edge/ds/user.go 0 1 0.0%
builtins/edge/ds/check.go 0 2 0.0%
builtins/edge/ds/helper.go 0 8 0.0%
pkg/testing/assets.go 30 47 63.83%
Files with Coverage Reduction New Missed Lines %
builtins/edge/ds/identity.go 1 60.0%
Totals Coverage Status
Change from base Build 4369546645: 0.2%
Covered Lines: 1180
Relevant Lines: 3063

💛 - Coveralls

Copy link
Member

@gertd gertd left a comment

Choose a reason for hiding this comment

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

I suggest we extract the trace logic and use the fnName passed in for each built-in to make it reusable. Now that we have a mechanism we might want to explore if there is anything we want to trace for the argument parsing.

@@ -82,6 +85,14 @@ func RegisterCheckRelation(logger *zerolog.Logger, fnName string, dr resolvers.D
Trace: false,
})
if err != nil {
if bctx.TraceEnabled {
Copy link
Member

Choose a reason for hiding this comment

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

Can we extract this in to helper.go as

func traceError(bctx topdown.BuiltinContext, fnName string, err error) {
	if bctx.TraceEnabled {
		if len(bctx.QueryTracers) > 0 {
			bctx.QueryTracers[0].TraceEvent(topdown.Event{
				Op:      topdown.FailOp,
				Message: fmt.Sprintf("%s error:%s", fnName, err.Error()),
			})
		}
	}
}

This will make it reusable and leverage the function name as used in the code at all times.

Copy link
Member

Choose a reason for hiding this comment

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

Line 175 there is no trace added for the CheckPermission call

Copy link
Contributor Author

@carabasdaniel carabasdaniel left a comment

Choose a reason for hiding this comment

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

LGTM

@gertd gertd merged commit fa44c83 into main Mar 29, 2023
@gertd gertd deleted the builtins_trace branch March 29, 2023 19:25
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