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

Offer callback to set “current” span context? #26

Open
garthk opened this issue Jul 31, 2019 · 4 comments
Open

Offer callback to set “current” span context? #26

garthk opened this issue Jul 31, 2019 · 4 comments

Comments

@garthk
Copy link
Collaborator

garthk commented Jul 31, 2019

I need a configurable callback I can use to set the seq_trace label per path at the beginning of its resolution. It'll be brittle, but I've little other hope of tying outbound spans to the fields rather than the whole blueprint.

@garthk
Copy link
Collaborator Author

garthk commented Jul 31, 2019

From my poking around Absinthe so far, strikes me Absinthe.Phase.Document.Execution.Resolution will keep working on entries in res.middleware until it either finishes or gets %{state: :suspended} from one of the three async troublemakers. The good news is that we can set the “current” span context for the field/path at the beginning of res.middleware, and it'll be available whenever anything is kicked off during that first pass. The bad news is, I haven't yet found a way to put it back for any subsequent activity e.g. the post_batch_fun callback, nor to clear it at the end of the first pass.

@garthk
Copy link
Collaborator Author

garthk commented Jul 31, 2019

Might be wrong about the end of the first pass: the after_resolution callback will fire. And, then, again as long as any of the plugins' pipeline/2 callbacks insert another Absinthe.Phase.Document.Execution.Resolution.

@garthk
Copy link
Collaborator Author

garthk commented Jul 31, 2019

Would it be too intrusive to insert a phase to rewrite the blueprint to replace all the {Absinthe.Middleware.Batch, {batch_key, post_batch_fun}} tuples with something that'd call seq_trace first? I'd have to come last, somehow…

  def plugins do
    [Absinthe.Middleware.Dataloader] ++ AbsinthePlugin.defaults()
  end

… like putting myself at the end of that list, there.

@garthk
Copy link
Collaborator Author

garthk commented Jul 31, 2019

Ugh. Absinthe.Phase.Document.Execution.Resolution.run_callbacks/4 always runs the plugins in order. We'll need two to measure the whole loop: one first, and one last.

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

No branches or pull requests

1 participant