Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to intercept function invocation? #734

Closed
abatishchev opened this issue May 28, 2016 · 18 comments
Closed

Is there a way to intercept function invocation? #734

abatishchev opened this issue May 28, 2016 · 18 comments
Assignees
Labels
Milestone

Comments

@abatishchev
Copy link

In the purpose of logging and make it transparent, I'd like to be able to intercept/override the methods before and after function invocation? Is it possible now? if not, is is something you're considering to add?

@abatishchev
Copy link
Author

Any response, please?

@christopheranderson
Copy link
Contributor

I'm not sure if we have pre/post hooks for invocations. Mathew should be able to answer that. This might turn into a feature request.

@abatishchev
Copy link
Author

Having such hooks would greatly improve the SDK in my opinion, also help us (at MPSIT Engineering), to have better logging at least.

@christopheranderson
Copy link
Contributor

Is the existing logging mechanism insufficient in some way? Is there something we could do to make it better?

@abatishchev
Copy link
Author

abatishchev commented Jun 2, 2016

Please send some pointers where to look at?

We've tried out TexWriter log but this 'pollutes' function signature and body, also each function has to explicitly opt-in into logging this way. We're looking for something more transparent/lower level.

@christopheranderson
Copy link
Contributor

We've got the out TextWriter log which is the way of associating log output to a particular invocation. We also have the WebJobs Dashboard which allows you to see input/output data for each Function, execution duration, etc. Are you familiar with that dashboard?

@abatishchev
Copy link
Author

Yes, of course :) Here's the thing (it's related to #735): we write and then read logs programmatically as part of out end-to-end test. We didn't find another way to keep track which jobs were triggered by which messages.

@mathewc
Copy link
Member

mathewc commented Jun 3, 2016

We've discussed allowing pre/post hooks before, and I thought we had a feature request logged for it, but I just looked and couldn't find it. I do think that would be a good idea.

Not exactly what you're asking for I don't think, but we do log Started/Completed events through our TraceWriter infrastructure. You can add your own TraceWriter instance to the JobHostConfiguration.Tracing,Tracers collection, using specific trace source.

@jamesbascle
Copy link

Check out my post in this thread #716

If you don't mind getting down and dirty into an IoC-based AOP framework, it'll do ya.

@VenkateshSrini
Copy link

Is there we can have something like ActionFilters like MVC. We have been using to extend the functionality of API greatly with this. Is that possible

@humbleice
Copy link

Intercepting WebJobs would be helpful for incorporating Application Insights. I'm currently creating an operation context in the body of each job in order to correlate the job's telemetry data, but if that context could be created before the WebJob fires and finalized when it ends it would greatly simplify the code inside the job.

@jamesbascle
Copy link

Humble, check out my last post and link - this is exactly what I do to log messages from all functions to an external logging server.

@abatishchev
Copy link
Author

abatishchev commented Jan 18, 2017

Telemetry/AI and logging is also what we need the interception for. Looking for an organic, built-in, extensible way to achieve this.
Currently function output is available only in text context/scope of runtime (TextWriter param) and not of dependency tree creation (e.g. inject ILogger into a function and what is even hard today - its dependencies).

@brettsam
Copy link
Member

We're tracking first-class AI integration here: Azure/azure-functions-host#727

@humbleice
Copy link

@brettsam Is that conversation just for Functions or applicable for WebJobs in general?

@mathewc
Copy link
Member

mathewc commented Jan 20, 2017

I just created a new feature issue to track this. I'll close this one and we can continue any feature discussion there, thanks everyone :)

@mathewc mathewc closed this as completed Jan 20, 2017
@VenkateshSrini
Copy link

Can you please share the link to the new feature

@jamesbascle
Copy link

#980

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants