-
Hello. I'm using In the My problem is from an observability point of view. To get the spans linked to the API request I am propagating the context and then it is shown in DataDog in the same trace. However, the
Is there any alternative/suggestion to achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I'm not sure of a good way to do this... but I can think of a way... You could have a global |
Beta Was this translation helpful? Give feedback.
-
Since v5, the main db methods require context to actually send a statement to pg. My use case is in Is there something else I should be doing? I don't need any of the data on the context, I just need a context to pass to the |
Beta Was this translation helpful? Give feedback.
AfterRelease
doesn't take a context because it is called asynchronously afterRelease
which is itself cannot block. i.e. It's not clear what cancelling aRelease
would even mean. I hadn't considered needing to pass arbitrary extra data.I'm not sure of a good way to do this... but I can think of a way...
You could have a global
map[*pgx.Conn]context.Context
. You would need to guard access with a mutex, but you could set the value inBeforeAcquire
and retrieve and delete it inAfterRelease
.