(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[16952],{17:function(s,e,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/integrations/application-performance-monitoring/python",function(){return n(59507)}])},59507:function(s,e,n){"use strict";n.r(e),n.d(e,{__toc:function(){return a},default:function(){return p}});var r=n(85893),o=n(31379),i=n(9575),l={src:"/_next/static/media/python-endpoint.f993ad99.png",height:127,width:1066,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAABCAMAAADU3h9xAAAABlBMVEURDQ0pHBpLnq3VAAAACXBIWXMAABJ0AAASdAHeZh94AAAADUlEQVR4nGNgZGQAAwAAGAADi4J18gAAAABJRU5ErkJggg==",blurWidth:8,blurHeight:1},t={src:"/_next/static/media/browser-page.a04e563c.png",height:163,width:1762,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAABCAMAAADU3h9xAAAABlBMVEXg8PTj8PT328qhAAAACXBIWXMAABJ0AAASdAHeZh94AAAADElEQVR4nGNgZIAAAAARAALyGaCZAAAAAElFTkSuQmCC",blurWidth:8,blurHeight:1};let a=[{depth:3,value:"Install Integration",id:"install-integration"},{depth:3,value:"Install",id:"install"},{depth:3,value:"Configuring the App",id:"configuring-the-app"},{depth:3,value:"Run the Python App",id:"run-the-python-app"},{depth:3,value:"Launch Logit.io to view your traces",id:"launch-logitio-to-view-your-traces"},{depth:3,value:"How to diagnose no data in Stack",id:"how-to-diagnose-no-data-in-stack"}];function c(s){let e=Object.assign({p:"p",h3:"h3",code:"code",pre:"pre",span:"span",ul:"ul",li:"li",img:"img"},(0,i.a)(),s.components),{Steps:n,InstallIntegration:o,Callout:a,Tabs:c,Tab:p,MissingOtelDetailsCallout:d,LaunchVisualizer:x,DiagnoseNoData:k}=e;return a||h("Callout",!0),k||h("DiagnoseNoData",!0),o||h("InstallIntegration",!0),x||h("LaunchVisualizer",!0),d||h("MissingOtelDetailsCallout",!0),n||h("Steps",!0),p||h("Tab",!0),c||h("Tabs",!0),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.p,{children:"Use OpenTelemetry to easily send Python traces to your Logit.io Stack."}),"\n",(0,r.jsxs)(n,{children:[(0,r.jsx)(e.h3,{id:"install-integration",children:"Install Integration"}),(0,r.jsx)(o,{}),(0,r.jsxs)(a,{type:"info",children:[(0,r.jsx)(e.p,{children:"This sample app was created and tested with"}),(0,r.jsx)(e.p,{children:(0,r.jsx)(e.code,{children:"Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42)"})}),(0,r.jsx)(e.p,{children:(0,r.jsx)(e.code,{children:"pip 22.0.4"})})]}),(0,r.jsx)(e.h3,{id:"install",children:"Install"}),(0,r.jsxs)(e.p,{children:["Create a new directory for your project and name it ",(0,r.jsx)(e.code,{children:"opentelemetry_python_example"}),"."]}),(0,r.jsxs)(e.p,{children:["Open a Terminal window or Command Prompt and navigate into the new ",(0,r.jsx)(e.code,{children:"opentelemetry_python_example"})," folder.\nCreate a virtual environment for your project to manage dependencies, this is done by entering the following command."]}),(0,r.jsxs)(c,{items:["Windows","Linux/macOS/DEB/RPM"],children:[(0,r.jsx)(p,{children:(0,r.jsx)(e.pre,{"data-language":"bash","data-theme":"default",hasCopyCode:!0,children:(0,r.jsxs)(e.code,{"data-language":"bash","data-theme":"default",children:[(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"python"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"-m"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"venv"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"venv"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"venv\\Scripts\\activate"})})]})})}),(0,r.jsx)(p,{children:(0,r.jsx)(e.pre,{"data-language":"bash","data-theme":"default",hasCopyCode:!0,children:(0,r.jsxs)(e.code,{"data-language":"bash","data-theme":"default",children:[(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"python"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"-m"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"venv"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"venv"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"source"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"venv/bin/activate"})]})]})})})]}),(0,r.jsx)(e.p,{children:"We now need to install the necessary OpenTelemetry packages using pip, the packages that we will be using are as follows:"}),(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.code,{children:"opentelemetry-api"}),": Core API for OpenTelemetry"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.code,{children:"opentelemetry-sdk"}),": SDK implementation"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.code,{children:"opentelemetry-exporter-otlp"}),": Exporter to send data to the OpenTelemetry Collector or other OTLP-compatible backends"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.code,{children:"opentelemetry-instrumentation-flask"}),": Automatically instrument your Flask applications for tracing with OpenTelemetry"]}),"\n"]}),(0,r.jsx)(e.p,{children:"We install them with the following command."}),(0,r.jsx)(e.pre,{"data-language":"bash","data-theme":"default",hasCopyCode:!0,children:(0,r.jsx)(e.code,{"data-language":"bash","data-theme":"default",children:(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"pip"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"install"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"flask"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"opentelemetry-api"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"opentelemetry-sdk"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"opentelemetry-instrumentation-flask"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"opentelemetry-exporter-otlp"})]})})}),(0,r.jsxs)(e.p,{children:["Create two new files in the folder and call them ",(0,r.jsx)(e.code,{children:"app.py"})," and ",(0,r.jsx)(e.code,{children:"config.py"}),". There should now be a\ntwo files in the ",(0,r.jsx)(e.code,{children:"opentelemetry_python_example"})," folder and a folder called ",(0,r.jsx)(e.code,{children:"venv"}),"."]}),(0,r.jsx)(e.h3,{id:"configuring-the-app",children:"Configuring the App"}),(0,r.jsxs)(e.p,{children:["Copy and Paste the code below into ",(0,r.jsx)(e.code,{children:"config.py"}),"."]}),(0,r.jsx)(d,{}),(0,r.jsx)(e.pre,{"data-language":"python","data-theme":"default",filename:"config.py",hasCopyCode:!0,children:(0,r.jsxs)(e.code,{"data-language":"python","data-theme":"default",children:[(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:"# config.py"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"SERVICE_NAME "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"LogitPythonTestApp"'})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"OTLP_ENDPOINT "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"https://'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},className:"highlighted",children:"@opentelemetry.endpointAddress"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"'})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"PORT "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},className:"highlighted",children:"@opentelemetry.httpsPort"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"'})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"USERNAME "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},className:"highlighted",children:"@opentelemetry.username"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"'})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"PASSWORD "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},className:"highlighted",children:"@opentelemetry.password"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"'})]})]})}),(0,r.jsxs)(e.p,{children:["Copy and Paste the code below into ",(0,r.jsx)(e.code,{children:"app.py"})]}),(0,r.jsx)(e.pre,{"data-language":"python","data-theme":"default",filename:"app.py",hasCopyCode:!0,children:(0,r.jsxs)(e.code,{"data-language":"python","data-theme":"default",children:[(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:"# app.py"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" base64"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" datetime "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" datetime"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" opentelemetry "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" trace"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" opentelemetry"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"sdk"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"resources "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" Resource"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" opentelemetry"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"sdk"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"trace "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" TracerProvider"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" opentelemetry"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"sdk"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"trace"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"export "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" BatchSpanProcessor"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" opentelemetry"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"exporter"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"otlp"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"proto"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"http"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"trace_exporter "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" OTLPSpanExporter"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" flask "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" Flask"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"app "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"Flask"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"__name__"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:"# Importing configuration variables from config.py"})}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" config "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" SERVICE_NAME"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" OTLP_ENDPOINT"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" PORT"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" USERNAME"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" PASSWORD"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"def"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"get_basic_auth_header"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-parameter)"},children:"username"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-parameter)"},children:"password"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"):"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:'"""Encodes the username and password to base64 for Basic Auth."""'})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    credentials "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"f"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"{"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"username"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"}"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:":"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"{"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"password"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"}"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"'})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    auth_bytes "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" base64"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"b64encode"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"(credentials."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"encode"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'utf-8'"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"))"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    auth_header "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" auth_bytes"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"decode"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'utf-8'"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"return"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"f"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"Basic '}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"{"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"auth_header"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"}"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"'})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"def"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"init_tracer"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"():"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:"# Create a Resource to associate with all traces"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    resource "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" Resource"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"create"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"({"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"service.name"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:": SERVICE_NAME})"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:"# Set up the TracerProvider and add the OTLP HTTP exporter with Basic Auth"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    tracer_provider "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"TracerProvider"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"(resource"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"resource)"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    trace"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"set_tracer_provider"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"(tracer_provider)"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:"# Generate the Basic Auth header"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    auth_header "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"get_basic_auth_header"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"(USERNAME, PASSWORD)"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"  "})}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:"#Generate the full endpoint"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    endpoint "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"f"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"{"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"OTLP_ENDPOINT"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"}"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:":"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"{"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"PORT"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"}"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'/v1/traces"'})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:"# Create the OTLP HTTP exporter with the Basic Auth header"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    otlp_exporter "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"OTLPSpanExporter"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"        endpoint"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"endpoint,"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"        headers"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"{"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"Authorization"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:": auth_header}"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"    )"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:"# Add the exporter to the tracer provider"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    span_processor "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"BatchSpanProcessor"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"(otlp_exporter)"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    tracer_provider"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"add_span_processor"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"(span_processor)"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"@app"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"route"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'/'"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"def"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"hello_world"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"():"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:"# Initialize the tracer"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"init_tracer"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"()"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    tracer "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" trace"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"get_tracer"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"__name__"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"with"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" tracer"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"start_as_current_span"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"parent-span"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:")"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"as"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" parent_span"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"        now "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" datetime"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"now"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"()"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"        parent_span"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"set_attribute"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"FirstMessage"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:", "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"This is a test!"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"        parent_span"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"set_attribute"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"SecondMessage"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:", "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"Message sent at "'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"+"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:" now."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"strftime"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"%H:%M:%S"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"))"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"        "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-comment)"},children:"# Start the second span within the first span"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"        "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"with"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" tracer"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"start_as_current_span"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"child-span"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:")"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"as"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" child_span"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"            child_span"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"set_attribute"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"FirstMessage"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:", "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"This is another test!"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "})}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"with"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" tracer"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"start_as_current_span"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"hello-span"'}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"):"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"        "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"return"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"Hello, World!"'})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"      "})}),"\n",(0,r.jsx)(e.span,{className:"line",children:" "}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"if"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-constant)"},children:"__name__"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"=="}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'__main__'"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:"    app"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"run"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:"()"})]})]})}),(0,r.jsx)(e.h3,{id:"run-the-python-app",children:"Run the Python App"}),(0,r.jsx)(e.p,{children:"Run the Python app with the following command in Terminal or the Command Prompt window."}),(0,r.jsx)(e.pre,{"data-language":"bash","data-theme":"default",hasCopyCode:!0,children:(0,r.jsx)(e.code,{"data-language":"bash","data-theme":"default",children:(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"python"}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,r.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"app.py"})]})})}),(0,r.jsx)(e.p,{children:"You will see feedback from the app so that you know that is running, make a note of the\naddress and port that it is running on."}),(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Python Endpoint",placeholder:"blur",src:l})}),(0,r.jsx)(e.p,{children:"Open your browser and enter the address and port you made a note of in the previous step, the browser will return the following"}),(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Browser Page",placeholder:"blur",src:t})}),(0,r.jsx)(e.p,{children:"The action of browsing to the page served by the Python app with sent traces to your Stack."}),(0,r.jsx)(e.h3,{id:"launch-logitio-to-view-your-traces",children:"Launch Logit.io to view your traces"}),(0,r.jsx)(x,{type:"apm"}),(0,r.jsx)(e.h3,{id:"how-to-diagnose-no-data-in-stack",children:"How to diagnose no data in Stack"}),(0,r.jsx)(k,{})]})]})}function h(s,e){throw Error("Expected "+(e?"component":"object")+" `"+s+"` to be defined: you likely forgot to import, pass, or provide it.")}var p=(0,o.j)({MDXContent:function(){let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:e}=Object.assign({},(0,i.a)(),s.components);return e?(0,r.jsx)(e,{...s,children:(0,r.jsx)(c,{...s})}):c(s)},pageOpts:{filePath:"src/pages/integrations/application-performance-monitoring/python.mdx",route:"/integrations/application-performance-monitoring/python",frontMatter:{title:"Python",metaTitle:"Learn How to Integrate and Configure Python to Send Traces",pageTitle:"OpenTelemetry Python Configuration",subTitle:"Ship traces from Python to OpenSearch with OpenTelemetry",logo:"python",color:"#0e64a9",stackTypes:"apm",description:"Follow the simple steps in Logit.io's Python data integrations to start shipping traces from Python to OpenSearch with OpenTelemetry.",tags:"Python, Flask, Django, Web Framework, Apm, Grpc, Https"},title:"Python",headings:a},pageNextRoute:"/integrations/application-performance-monitoring/python"})}},function(s){s.O(0,[31379,92888,49774,40179],function(){return s(s.s=17)}),_N_E=s.O()}]);