postgrest icon indicating copy to clipboard operation
postgrest copied to clipboard

OpenTelemetry integration tracking issue

Open develop7 opened this issue 1 year ago • 4 comments

An umbrella issue for tracking of OpenTelemetry integration to PostgREST.

  • [x] Get familiar with OTel and terminology
    • [ ] Wrap meaningful and measurable actions with OTel spans
  • [ ] Get hands dirty by exposing Server-Timing metrics for collection (per the suggestion at https://github.com/PostgREST/postgrest/issues/1526#issuecomment-1854668454)
  • [ ] Collect metrics during loadtest and include these to reports
  • [ ] Collect & export memory stats
  • [x] Collect web request/response stats with hs-opentelemetry-instrumentation-wai
  • [ ] Wrap hasql to a stats-collecting middleware
  • [x] Handle and propagate trace ID

develop7 avatar Dec 15 '23 15:12 develop7

I have played with the idea some time ago and have a preliminary implementation. The main goal was to trace SQL statements so it required Hasql adjustments. I also wanted to play with https://hackage.haskell.org/package/effectful to make the whole thing extensible.

As Hasql is a family of projects I had to fork quite a bunch of Hasql repositories.

At the end of the day only minimal changes to Postgrest itself were needed as I was able to replace monomorphic usage of Hasql with polymorphic based on effectful by using Cabal mixins.

Not sure if there is anything interesting there to actually provide a pull request but maybe worth looking at and discussing.

https://github.com/PostgREST/postgrest/compare/main...mkleczek:postgrest:temp-opentelemetry

mkleczek avatar Dec 15 '23 19:12 mkleczek

@mkleczek whoa, you've got yourself a nice flake.nix too! Seems to be way ahead of https://github.com/PostgREST/postgrest/pull/3105 of mine (and working, I presume?). Do you mind us borrowing a thing here and there, or, better yet, you submit a PR with it?

develop7 avatar Dec 19 '23 14:12 develop7

It was working last time I tried :)

As mentioned in https://github.com/PostgREST/postgrest/pull/3105#issuecomment-1863025619 - static binary builds not tested.

mkleczek avatar Dec 19 '23 20:12 mkleczek

Could really do with otel tracing and it looks as though the basics are in https://github.com/PostgREST/postgrest/compare/main...mkleczek:postgrest:temp-opentelemetry

How can I help to get this over the line?

vxtra1973 avatar Jul 29 '24 14:07 vxtra1973