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

Telemetry-based Absinthe instrumentation #88

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andrewhr
Copy link
Contributor

Add instrumentation for Absinthe, the GraphQL Elixir-framwork. Relies on some new telemetry work on Absinthe:

Span names and attributes also follow the JavaScript impl, the closes to a future Semantic Attribute spec.

The "span tracker" used here is to connect traces in a shape that resembles the query shape instead of execution shape. One example is:

query {
  users {
    name
  }
}

In case name is an async resolver (for example), the execution will resembles a recursive function, and such our trace will be:

RootQueryType.users
  User.name
    User.name
      User.name

With the span tracker, the above trace will become:

RootQueryType.users
  User.name
  User.name
  User.name

That helps visually scan the traces, and it's friendly to folks who doesn't know much about Absinthe internals.

Add instrumentation for `Absinthe`, the GraphQL Elixir-framwork. Relies on
some new telemetry work on Absinthe:
* [Added telemetry for async helper][1], used to propagate traces
* [Improved telemetry for batch helper][2], used to propagate traces
* [Tweaked pipeline instrumentation][3], that splits parse/validate/execute
  phases, following the approach of [JavaScript libraries][4]

Span names and attributes also follow the [JavaScript impl][4], the
closes to a future [Semantic Attribute][5] spec.

The "span tracker" used here is to connect traces in a shape that
resembles the query shape instead of execution shape. One example is:

```
query {
  users {
    name
  }
}
```

In case `name` is an async resolver (for example), the execution will
resembles a recursive function, and such our trace will be:

```
RootQueryType.users
  User.name
    User.name
      User.name
```

With the span tracker, the above trace will become:

```
RootQueryType.users
  User.name
  User.name
  User.name
```

That helps visually scan the traces, and it's friendly to folks who
doesn't know much about Absinthe internals.

[1]: absinthe-graphql/absinthe#1169
[2]: absinthe-graphql/absinthe#1170
[3]: absinthe-graphql/absinthe#1172
[4]: https://www.npmjs.com/package/@opentelemetry/instrumentation-graphql
[5]: open-telemetry/opentelemetry-specification#2456
@andrewhr
Copy link
Contributor Author

@tsloughter this is the instrumentation we talked few weeks ago on EEF observability WG meeting.

It's posted as draft for two reasons:

  • First, it depends in unreleased and WIP work on Absinthe mainline to fully work. Tests are broken reflecting that.
  • The hex.pm library is already published from https://github.com/primait/opentelemetry_absinthe, though it follows different strategies. I see how we can coordinate to merge and/or re-release from here OR release under a different name.

@rewritten
Copy link

Hey @andrewhr could you make the absinthe WIP features you are relying on more explicit? I'm considering pulling in the code (until the PR can be merged and the package adopted from @primait) in our current project.

@andrewhr
Copy link
Contributor Author

andrewhr commented Aug 5, 2022

Hey @rewritten!

I linked all Absinthe issues in the description of this issue here.

The gist is, we need telemetry events for all kinds of helpers/middleware (async/batch), and they need to be fired from inside the internal Tasks created by those middleware (so span propagation works, as it tracks spans from parent processes).

There is one case which events exists, but they're not well located and propagation does work - this specific case is handled here absinthe-graphql/absinthe#1170.

@tsloughter
Copy link
Member

@andrewhr coming up on a year so I thought I'd check on if there was anything knew around absinthe integration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants