Application Insights and Azure Functions - tracking a distributed operation
I have a process which is distributed across several functions in the following manner:
Http binding function saves a message in a queue
Queue binding function processes the message, then places another message in a queue
Finally another function process the message and saves something in a database.
What I would like is for application insights to understand the context of the original request and be able to follow the flow of the request across all the distributed function calls, but there doesn't appear to be a way for me to set the operation id correctly (which I believe is ultimately the "correct" way to achieve my requirement).
I can set the parent id but this just prevents the data collected from showing up at all in application insights. I'm setting the parent id using the following code:
private static void UpdateTelemetryContext(TelemetryContext context, ExecutionContext functionContext, string id)
{
context.Operation.Id = functionContext.InvocationId.ToString();
context.Operation.ParentId = id;
context.Operation.Name = functionContext.FunctionName;
}
The only way I can sort of achieve what I want is to set the user id to be the context id I want (the thing that links all the operations together), and set the synthetic source to be "Functions" so at least I know it's not a real user.
This is the code I'm using to achieve this:
private static void UpdateTelemetryContext(TelemetryContext context, ExecutionContext functionContext, string id)
{
context.Operation.Id = functionContext.InvocationId.ToString();
context.Operation.ParentId = functionContext.InvocationId.ToString();
context.Operation.Name = functionContext.FunctionName;
context.User.Id = id;
context.Operation.SyntheticSource = "Functions";
}
Now inside application insights I can click "show timeline for user" and see all the executions of the function group together, but this feels so wrong there just has to be a better way to achieve this.
azure-functions azure-application-insights
add a comment |
I have a process which is distributed across several functions in the following manner:
Http binding function saves a message in a queue
Queue binding function processes the message, then places another message in a queue
Finally another function process the message and saves something in a database.
What I would like is for application insights to understand the context of the original request and be able to follow the flow of the request across all the distributed function calls, but there doesn't appear to be a way for me to set the operation id correctly (which I believe is ultimately the "correct" way to achieve my requirement).
I can set the parent id but this just prevents the data collected from showing up at all in application insights. I'm setting the parent id using the following code:
private static void UpdateTelemetryContext(TelemetryContext context, ExecutionContext functionContext, string id)
{
context.Operation.Id = functionContext.InvocationId.ToString();
context.Operation.ParentId = id;
context.Operation.Name = functionContext.FunctionName;
}
The only way I can sort of achieve what I want is to set the user id to be the context id I want (the thing that links all the operations together), and set the synthetic source to be "Functions" so at least I know it's not a real user.
This is the code I'm using to achieve this:
private static void UpdateTelemetryContext(TelemetryContext context, ExecutionContext functionContext, string id)
{
context.Operation.Id = functionContext.InvocationId.ToString();
context.Operation.ParentId = functionContext.InvocationId.ToString();
context.Operation.Name = functionContext.FunctionName;
context.User.Id = id;
context.Operation.SyntheticSource = "Functions";
}
Now inside application insights I can click "show timeline for user" and see all the executions of the function group together, but this feels so wrong there just has to be a better way to achieve this.
azure-functions azure-application-insights
add a comment |
I have a process which is distributed across several functions in the following manner:
Http binding function saves a message in a queue
Queue binding function processes the message, then places another message in a queue
Finally another function process the message and saves something in a database.
What I would like is for application insights to understand the context of the original request and be able to follow the flow of the request across all the distributed function calls, but there doesn't appear to be a way for me to set the operation id correctly (which I believe is ultimately the "correct" way to achieve my requirement).
I can set the parent id but this just prevents the data collected from showing up at all in application insights. I'm setting the parent id using the following code:
private static void UpdateTelemetryContext(TelemetryContext context, ExecutionContext functionContext, string id)
{
context.Operation.Id = functionContext.InvocationId.ToString();
context.Operation.ParentId = id;
context.Operation.Name = functionContext.FunctionName;
}
The only way I can sort of achieve what I want is to set the user id to be the context id I want (the thing that links all the operations together), and set the synthetic source to be "Functions" so at least I know it's not a real user.
This is the code I'm using to achieve this:
private static void UpdateTelemetryContext(TelemetryContext context, ExecutionContext functionContext, string id)
{
context.Operation.Id = functionContext.InvocationId.ToString();
context.Operation.ParentId = functionContext.InvocationId.ToString();
context.Operation.Name = functionContext.FunctionName;
context.User.Id = id;
context.Operation.SyntheticSource = "Functions";
}
Now inside application insights I can click "show timeline for user" and see all the executions of the function group together, but this feels so wrong there just has to be a better way to achieve this.
azure-functions azure-application-insights
I have a process which is distributed across several functions in the following manner:
Http binding function saves a message in a queue
Queue binding function processes the message, then places another message in a queue
Finally another function process the message and saves something in a database.
What I would like is for application insights to understand the context of the original request and be able to follow the flow of the request across all the distributed function calls, but there doesn't appear to be a way for me to set the operation id correctly (which I believe is ultimately the "correct" way to achieve my requirement).
I can set the parent id but this just prevents the data collected from showing up at all in application insights. I'm setting the parent id using the following code:
private static void UpdateTelemetryContext(TelemetryContext context, ExecutionContext functionContext, string id)
{
context.Operation.Id = functionContext.InvocationId.ToString();
context.Operation.ParentId = id;
context.Operation.Name = functionContext.FunctionName;
}
The only way I can sort of achieve what I want is to set the user id to be the context id I want (the thing that links all the operations together), and set the synthetic source to be "Functions" so at least I know it's not a real user.
This is the code I'm using to achieve this:
private static void UpdateTelemetryContext(TelemetryContext context, ExecutionContext functionContext, string id)
{
context.Operation.Id = functionContext.InvocationId.ToString();
context.Operation.ParentId = functionContext.InvocationId.ToString();
context.Operation.Name = functionContext.FunctionName;
context.User.Id = id;
context.Operation.SyntheticSource = "Functions";
}
Now inside application insights I can click "show timeline for user" and see all the executions of the function group together, but this feels so wrong there just has to be a better way to achieve this.
azure-functions azure-application-insights
azure-functions azure-application-insights
asked Nov 22 at 21:17
Ross Dargan
4,64132847
4,64132847
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
For anyone looking for an answer for this the only way you can do this is to disable the automated logging from application insights, and instead do it all manually.
This blog post helped me a lot: https://azure-development.com/2017/12/15/end2end-monitoring-of-azure-functions-with-application-insights/
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438078%2fapplication-insights-and-azure-functions-tracking-a-distributed-operation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
For anyone looking for an answer for this the only way you can do this is to disable the automated logging from application insights, and instead do it all manually.
This blog post helped me a lot: https://azure-development.com/2017/12/15/end2end-monitoring-of-azure-functions-with-application-insights/
add a comment |
For anyone looking for an answer for this the only way you can do this is to disable the automated logging from application insights, and instead do it all manually.
This blog post helped me a lot: https://azure-development.com/2017/12/15/end2end-monitoring-of-azure-functions-with-application-insights/
add a comment |
For anyone looking for an answer for this the only way you can do this is to disable the automated logging from application insights, and instead do it all manually.
This blog post helped me a lot: https://azure-development.com/2017/12/15/end2end-monitoring-of-azure-functions-with-application-insights/
For anyone looking for an answer for this the only way you can do this is to disable the automated logging from application insights, and instead do it all manually.
This blog post helped me a lot: https://azure-development.com/2017/12/15/end2end-monitoring-of-azure-functions-with-application-insights/
answered Nov 28 at 18:34
Ross Dargan
4,64132847
4,64132847
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438078%2fapplication-insights-and-azure-functions-tracking-a-distributed-operation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown