{"id":3362,"date":"2024-09-17T09:58:12","date_gmt":"2024-09-17T16:58:12","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=3362"},"modified":"2024-09-17T09:58:12","modified_gmt":"2024-09-17T16:58:12","slug":"observability-in-semantic-kernel","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/observability-in-semantic-kernel\/","title":{"rendered":"Observability in Semantic Kernel"},"content":{"rendered":"<p>Many of you have asked similar questions:<\/p>\n<ul>\n<li>How do I obtain the rendered prompt that Semantic Kernel sends to the AI service?<\/li>\n<li>How do I monitor the token usage of my application?<\/li>\n<li>How do I gain insights into Semantic Kernel&#8217;s operations during runtime?<\/li>\n<\/ul>\n<p>These are all excellent questions! They fundamentally belong to the same class of questions: <strong>How do I observe Semantic Kernel and, ultimately, my application?<\/strong><\/p>\n<h3>Introducing: Observability in Semantic Kernel<\/h3>\n<p>Semantic Kernel is designed to be observable. It emits logs, metrics, and traces that are compatible to the <a href=\"https:\/\/opentelemetry.io\/docs\/what-is-opentelemetry\/\">OpenTelemetry<\/a> standard. You can use your favorite observability tools to monitor and analyze the behavior of your services built on Semantic Kernel.<\/p>\n<h4>Logging<\/h4>\n<p>Semantic Kernel logs meaningful events and errors from the kernel, kernel plugins and functions, as well as the AI connectors.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-log-events-overview-app-insights.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3365\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-log-events-overview-app-insights.png\" alt=\"Image telemetry log events overview app insights\" width=\"1288\" height=\"689\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-log-events-overview-app-insights.png 1288w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-log-events-overview-app-insights-300x160.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-log-events-overview-app-insights-1024x548.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-log-events-overview-app-insights-768x411.png 768w\" sizes=\"(max-width: 1288px) 100vw, 1288px\" \/><\/a><\/p>\n<h4>Metrics<\/h4>\n<p>Semantic Kernel emits metrics from kernel functions and AI connectors. You will be able to monitor metrics such as the kernel function execution time, the token consumption of AI connectors, etc.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-metrics-overview-app-insights.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3366\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-metrics-overview-app-insights.png\" alt=\"Image telemetry metrics overview app insights\" width=\"1288\" height=\"687\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-metrics-overview-app-insights.png 1288w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-metrics-overview-app-insights-300x160.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-metrics-overview-app-insights-1024x546.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-metrics-overview-app-insights-768x410.png 768w\" sizes=\"(max-width: 1288px) 100vw, 1288px\" \/><\/a><\/p>\n<h4>Traces<\/h4>\n<p>Semantic Kernel supports distributed tracing. You can track activities across different services and within Semantic Kernel.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-trace-overview-app-insights.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3367\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-trace-overview-app-insights.png\" alt=\"Image telemetry trace overview app insights\" width=\"1734\" height=\"745\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-trace-overview-app-insights.png 1734w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-trace-overview-app-insights-300x129.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-trace-overview-app-insights-1024x440.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-trace-overview-app-insights-768x330.png 768w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/09\/telemetry-trace-overview-app-insights-1536x660.png 1536w\" sizes=\"(max-width: 1734px) 100vw, 1734px\" \/><\/a><\/p>\n<h3>OpenTelemetry Semantic Convention<\/h3>\n<p>Semantic Kernel follows the\u00a0<a href=\"https:\/\/opentelemetry.io\/docs\/concepts\/semantic-conventions\/\" data-linktype=\"external\">OpenTelemetry Semantic Convention<\/a>\u00a0for Observability. This means that the logs, metrics, and traces emitted by Semantic Kernel are structured and follow a common schema. This ensures that you can more effectively analyze the telemetry data emitted by Semantic Kernel.<\/p>\n<p><em>Please note that the\u00a0<a href=\"https:\/\/github.com\/open-telemetry\/semantic-conventions\/blob\/main\/docs\/gen-ai\/README.md\" data-linktype=\"external\">Semantic Conventions for Generative AI<\/a>\u00a0are in experimental status. Semantic Kernel strives to follow the OpenTelemetry Semantic Convention as closely as possible, and provide a consistent and meaningful observability experience for AI solutions.<\/em><\/p>\n<h3>Code samples<\/h3>\n<p>For more details and code samples, please head over to the <a href=\"https:\/\/learn.microsoft.com\/en-us\/semantic-kernel\/enterprise-readiness\/observability\/\">Semantic Kernel learn site<\/a>.<\/p>\n<article id=\"post-2931\" class=\"middle-column pe-xl-198\" data-clarity-region=\"article\">\n<div class=\"entry-content sharepostcontent \" data-bi-area=\"body_article\" data-bi-id=\"post_page_body_article\">\n<p><em>The Semantic Kernel team is dedicated to empowering developers by providing access to the latest advancements in the industry. We encourage you to leverage your creativity and build remarkable solutions with SK! Please reach out if you have any questions or feedback through our\u00a0<a href=\"https:\/\/github.com\/microsoft\/semantic-kernel\/discussions\/categories\/general\" target=\"_blank\" rel=\"noopener\">Semantic Kernel GitHub Discussion Channel<\/a>. We look forward to hearing from you!\u00a0We would also love your support, if you\u2019ve enjoyed using Semantic Kernel, give us a star on\u00a0<a href=\"https:\/\/github.com\/microsoft\/semantic-kernel\" target=\"_blank\" rel=\"noopener\">GitHub<\/a>.<\/em><\/p>\n<\/div>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>Many of you have asked similar questions: How do I obtain the rendered prompt that Semantic Kernel sends to the AI service? How do I monitor the token usage of my application? How do I gain insights into Semantic Kernel&#8217;s operations during runtime? These are all excellent questions! They fundamentally belong to the same class [&hellip;]<\/p>\n","protected":false},"author":165150,"featured_media":2364,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[48,63,9],"class_list":["post-3362","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-semantic-kernel","tag-ai","tag-microsoft-semantic-kernel","tag-semantic-kernel"],"acf":[],"blog_post_summary":"<p>Many of you have asked similar questions: How do I obtain the rendered prompt that Semantic Kernel sends to the AI service? How do I monitor the token usage of my application? How do I gain insights into Semantic Kernel&#8217;s operations during runtime? These are all excellent questions! They fundamentally belong to the same class [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/3362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/165150"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=3362"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/3362\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/2364"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=3362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=3362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=3362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}