philopon / helics

New Relic® agent SDK wrapper for Haskell
MIT License
13 stars 6 forks source link

Expose ability to set transaction names manually #2

Closed iand675 closed 9 years ago

iand675 commented 9 years ago

For the WAI middleware, I would like to be able to alter the transaction name, but it sets it automatically. Also, it would be nice if you could expose the TransactionId in a way that doesn't error out if the helics middleware is missing, for example:

lookupTransactionId :: Request -> Maybe TransactionId
philopon commented 9 years ago

For the WAI middleware, I would like to be able to alter the transaction name, but it sets it automatically.

I'll add configure which has transactionName field.

transactionName :: Request -> ByteString

Also, it would be nice if you could expose the TransactionId in a way that doesn't error out if the helics middleware is missing.

Hmm... I cannot imagine case that get transaction id when middleware is missing. Could you tell me about its use case?

iand675 commented 9 years ago

Thanks!

Hmm... I cannot imagine case that get transaction id when middleware is missing. Could you tell me about its use case?

For example, I want to write some code that uses helics in production, but doesn't use it in development. I know the environment based on an environment variable. I'd like to still have some instrumentation code in development that just doesn't run if the transaction id doesn't exist. For example:

dbSegment :: Request -> IO a -> IO a
dbSegment r m = case lookupTransactionId r of
  Nothing -> m
  Just tid -> datastoreSegment autoScope def m tid
philopon commented 9 years ago

Ok. I understood! Thanks for your explanation. I'll add Request -> Maybe TransactionId function.