[AI Custom Telemetry] Avoid requirement of BYO telemetry client (external logger) in function code
VS Preview 15.3 Azure compiled functions
In the Wiki it discusses the ability to send custom telemetry. This requires a developer for every function to have to define base telemetry client data (ie, Context.Operation.Id, ParentId, etc) to manually 'sync' the output to AI - which needs to stay in sync with changes on the webjobs application insight component. It is also important that the developer knows the 'how' the properties are mapped. (I think this should be the responsibility of the Logging.ApplicationInsights component).
Can we look at some way in a function of being able to place the following onto 'something' so that the webjobs application insight component can pick these up ??:
- Events (string)
- Metrics (string, data...)
- Dependencies (only ones a developer explicitly codes within the function run method, maybe with a function that wraps around and runs the call?)
Best to keep the same signatures as application insights on the TelemetryClient, but a WebJobs controlled interface/class, etc.
Dependency tracking (for binding outputs) can be ignored from that list as that is covered by automatically picking them up here Azure/azure-webjobs-sdk#1208 and correlation needs a common in sync TelemetryClient discussed here Azure/Azure-Functions#245
It would mean that if we moved to allow the loggers as an extension element referenced here Azure/azure-webjobs-sdk-script#1668 then anyone can write any external output logging implementation utilizing a common 'internal to webjobs' signature approach to outputting metrics from within a function.
Because they then travel to the Logging.XYZ it is up to that component how to translate the webjobs 'metrics, events' etc into the appropriate form.
Thus, allowing the reuse of the lower WebJobs Application Insight TelemetryClient and meaning we don't need to remember as a developer to keep the the id's in sync.
@brettsam - a lot of this stuff we've talked about doing via ILogger, right?
Consolidating comments from #398 .
Here in the WebJob.Sdk you're setting the application insight request to 0, with no further modification - unless it is a HttpTrigger when you apply the HttpResponseCode.
Suggestion is to set response code to 200 if the function executes, 500 if an exception is raised, unless it is a httpTrigger where it uses the http response code.
@erich-wang 's comments from #398 .
Ability to define an override for request.success & request.resultCode from the function.
We would really love to see the function apps support a standard for correlation vectors (when passed in by clients/triggers) rather than simply hardcoding Application Insights operation ids to the Function InvocationId.
For example,
HTTP triggers could honor a "Request-Id" header (if present in correct format) and parse it into Operation.Id and Operation.ParentOperationId.
ServiceBus message input triggers could honor a "Request-Id" BrokeredMessage Property (or use MessageId or CorrelationId Headers if you prefer) if present in correct format.
For clarity: I am referring to Request-Id headers or properties conforming to https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HierarchicalRequestId.md
@johnbirdau Yes, I'd love to see logs using ILogger set Operation Id based on Request-Id header or Correlation-Context as described here: https://docs.microsoft.com/en-us/azure/application-insights/application-insights-correlation#correlation-headers Is this on the backlog? Right now we're forced to use TelemetryClient right now, parse the headers, and update the context all manually. Lots of boilerplate that would be nice to get rid of!
Any updates on this feature request? Its been over a year.
Any updates on this?
Hey @joeyeng,
Right now we're forced to use TelemetryClient right now, parse the headers, and update the context all manually. Lots of boilerplate that would be nice to get rid of!
I think I will also have to do something similar. Would it be possible to share some of your code so that I get a lead?
Hey @joeyeng,
Right now we're forced to use TelemetryClient right now, parse the headers, and update the context all manually. Lots of boilerplate that would be nice to get rid of!
I think I will also have to do something similar. Would it be possible to share some of your code so that I get a lead?
I decided not to go that route, because it was too obtrusive and I wanted to use ILogger instead. For ILogger I basically add any correlated id's I want to get included to the logger scope.