refactor(users/Profpatsch/whatcd-resolver): use builder for otel

This makes `addAttribute` a little nicer to handle, because we can now
just put a `(builder, value)` tuple (yay, orphan instances!)

Change-Id: I145a0d2b764d44755fb3c548a40188f13ee4ed83
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12956
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
Profpatsch 2025-01-05 04:05:23 +01:00
parent 444b67b010
commit 77aadfa46c
7 changed files with 62 additions and 29 deletions

View file

@ -5,6 +5,7 @@ module WhatcdResolver where
import AppT
import Arg
import Builder
import Comparison
import Control.Category qualified as Cat
import Control.Monad.Catch.Pure (runCatch)
@ -562,7 +563,7 @@ getBestTorrentsData ::
Maybe (Label "artistRedactedId" Natural) ->
Transaction m [TorrentData (Label "percentDone" Percentage)]
getBestTorrentsData artistFilter = inSpan' "get torrents table data" $ \span -> do
artistFilter & doIfJust (\a -> addAttribute span "artist-filter.redacted-id" (a.artistRedactedId & showToText & Otel.toAttribute))
artistFilter & doIfJust (\a -> addAttribute span "artist-filter.redacted-id" (a.artistRedactedId, naturalDecimalT))
let getBest = getBestTorrents GetBestTorrentsFilter {onlyArtist = artistFilter, onlyDownloaded = False}
bestStale :: [TorrentData ()] <- getBest
(statusInfo, transmissionStatus) <-