You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a question about metrics usage.
I would like to track number of events per tenant, names of tenants are dynamic.
First of all I'm creating counter that will gather info about number of events that were processed
val baseCounter = Kamon.counter("events_processed_total", "Number of events processed by application")
My application is multi-tenant, as I want have ability to know value of events processed per tenant, when I'm incrementing counter I need add to baseCounter tag with tenant name, e.g. for tenant "XYZ Inc." it will be:
baseCounter.withTag("tenant", "XYZ Inc.")
As number of tenants is dynamic and I don't know what is tenant name until I get event I need either
call withTag on baseCounter on each event processing
maintain Map where I will keep per tenant counter, once first time we process event for given tenant, I need add new entry to mentioned Map
My question is whether I need maintain this mutable Map as application explicit state or it is ok to call withTag again on each event processing i.e. what is cost of calling withTag: looking on function def, withTag return new Counter - is it creating new Counter each time or perform some lookup on Kamon state to return existing counter if, entity for provided set of tags was already created?
For sure there would be some penalty for naively call withTag but I would like understand how big it is to know whether it is worth "pollute" application code with mentioned Map maintenance or I could accept less performant alternative.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I have a question about metrics usage.
I would like to track number of events per tenant, names of tenants are dynamic.
First of all I'm creating counter that will gather info about number of events that were processed
My application is multi-tenant, as I want have ability to know value of events processed per tenant, when I'm incrementing counter I need add to
baseCounter
tag with tenant name, e.g. for tenant "XYZ Inc." it will be:As number of tenants is dynamic and I don't know what is tenant name until I get event I need either
withTag
onbaseCounter
on each event processingMap
where I will keep per tenant counter, once first time we process event for given tenant, I need add new entry to mentionedMap
My question is whether I need maintain this mutable Map as application explicit state or it is ok to call
withTag
again on each event processing i.e. what is cost of callingwithTag
: looking on functiondef
,withTag
return newCounter
- is it creating newCounter
each time or perform some lookup on Kamon state to return existing counter if, entity for provided set of tags was already created?For sure there would be some penalty for naively call
withTag
but I would like understand how big it is to know whether it is worth "pollute" application code with mentionedMap
maintenance or I could accept less performant alternative.Thanks for any suggestions!
Beta Was this translation helpful? Give feedback.
All reactions