Hi, Konrad
I'll give you some concrete example about this.
I our previous sync model pipeline, we have some transactional logging to
measure request level metrics like response time.
For example, when an http request comes in, we usually do:
TransBegin("URL")
requestHandler1.exec()
requestHandler2.exec()
dispatch(request)
TransEnd("URL")
In each handler, they might be sub transactions, so the final logging
output might be something like:
t1 URL.start
t2 action1.start
t3 action1.end
t4 action2.start
t5 action2.end
t6 URL.end
So we can know how much time cost on each part.
This is easy in sync mode, because threadlocal is naturally a good place to
group/stack those messages.
let's say I can generated an uuid at the very beginning to represent the
request and pass along with thread local. So any subsequent api calls can
retrieve the uuid and associate some messages to the uuid.
So, the fact is there're a lot of legacy code are doing this way and it's
not possible for me to change them all.
That's why I'm thinking of using a way to pass the uuid implicitly with
AOP.(to wrap and unwrap the necessary info (uuid)
automatically/transparently to developer)
Leon
在 2014年5月30日星期五UTC-7上午3时59分41秒,Konrad Malawski写道:
>
> The thread local stuff is quite "scary" in an Actor setting by the way and
> if possible it would be best to work around it (in a way other than
> setCurrentThreadId - I'm guessing that's your current impl?).
> Would you be able to construct MDC on your own, bypassing the threadlocals?
>
>
> On Fri, May 30, 2014 at 12:57 PM, Konrad Malawski <[email protected]
> <javascript:>> wrote:
>
>> So metrics.
>> I would suggest piggybacking on kamon: http://kamon.io/
>> Since the guys have many of the things figured out already - it's open
>> source so it should be possible to either get metrics from their pointcuts
>> or piggyback in some other way.
>>
>>
>> On Fri, May 30, 2014 at 11:58 AM, Leon Ma <[email protected]
>> <javascript:>> wrote:
>>
>>> My case is actually to pass some information like Mapped Diagnostic
>>> Context.
>>>
>>> Some of my legacy java code is using threadlocal to carry on those MDC
>>> information, that's why I need a way to:
>>>
>>> intercept "tell" : collect threadlocal information and do some wrapping
>>> like MDCCtx(mymessage, threadLocalInfoThatINeed)
>>> intercept "receive" : unwrapper MDCCtx, recover thread local info.
>>>
>>> Thanks
>>>
>>> Leon
>>>
>>>
>>>
>>>
>>>
>>> 在 2014年5月29日星期四UTC+8下午11时27分01秒,Konrad Malawski写道:
>>>
>>>> Hello Leon,
>>>> Well, "the Scala way"™ would rather be using plain total or partial
>>>> functions and composing them - I believe that's what whoever the quoted
>>>> sentence comes from had in mind.
>>>> In Akka we also believe that less magic is better :-)
>>>>
>>>> I would therefore suggest you to try modelling your required behaviour
>>>> in terms of functions instead of aspects.
>>>> What's your use case?
>>>>
>>>>
>>>> --
>>>> Cheers,
>>>> Konrad 'ktoso' Malawski
>>>> hAkker - Typesafe, Inc
>>>>
>>>> <http://scaladays.org>
>>>>
>>> --
>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>> >>>>>>>>>> Check the FAQ:
>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>> >>>>>>>>>> Search the archives:
>>> https://groups.google.com/group/akka-user
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Akka User List" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected] <javascript:>.
>>> To post to this group, send email to [email protected]
>>> <javascript:>.
>>> Visit this group at http://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Cheers,
>> Konrad 'ktoso' Malawski
>> hAkker - Typesafe, Inc
>>
>> <http://scaladays.org>
>>
>
>
>
> --
> Cheers,
> Konrad 'ktoso' Malawski
> hAkker - Typesafe, Inc
>
> <http://scaladays.org>
>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.