<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic 📦 New Package: Automatic OpenTelemetry Instrumentation for MCP in Dynatrace tips</title>
    <link>https://community.dynatrace.com/t5/Dynatrace-tips/New-Package-Automatic-OpenTelemetry-Instrumentation-for-MCP/m-p/282885#M1711</link>
    <description>&lt;P&gt;I’ve just published &lt;STRONG&gt;opentelemetry-instrumentation-mcp&lt;/STRONG&gt;, a (v1.0.0) package that makes it effortless to add observability to Model Context Protocol (MCP) applications.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Why it matters:&lt;/STRONG&gt;&lt;BR /&gt;This package automatically instruments every MCP tool call with a span and exports those spans via OTLP to Dynatrace. No more boilerplate around tracer.startSpan – you get built‑in OpenTelemetry setup and error handling out of the box&lt;/P&gt;
&lt;H4&gt;&lt;span class="lia-unicode-emoji" title=":key:"&gt;🔑&lt;/span&gt;Key features&lt;/H4&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Automatic instrumentation&lt;/STRONG&gt; of MCP tool calls – each invocation gets its own span&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Built‑in OpenTelemetry NodeSDK&lt;/STRONG&gt; – no manual SDK configuration needed&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Zero‑code integration&lt;/STRONG&gt; – just import and go&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;OTLP export&lt;/STRONG&gt; to Dynatrace – the package reads OTEL_EXPORTER_OTLP_ENDPOINT and DYNATRACE_API_TOKEN environment variables and sends your traces to Dynatrace for you&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Comprehensive tracing&lt;/STRONG&gt; with error tracking – exceptions are captured and spans are marked with error status automatically&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;H4&gt;&lt;span class="lia-unicode-emoji" title=":rocket:"&gt;🚀&lt;/span&gt;Getting started&lt;/H4&gt;
&lt;P&gt;Install the package from npm:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;npm install &lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/39872"&gt;@theharithsa&lt;/a&gt;/opentelemetry-instrumentation-mcp&lt;/LI-CODE&gt;
&lt;P&gt;For most users, the &lt;STRONG&gt;auto‑registration&lt;/STRONG&gt; approach is easiest: at the very top of your application’s entry point (e.g., src/index.ts), add a single import line:&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt; &lt;SPAN class=""&gt;'@theharithsa/opentelemetry-instrumentation-mcp/register'&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;That’s it! The package will start the OpenTelemetry SDK, load the default Node instrumentations and the MCP instrumentation, and export spans to your Dynatrace tenant. Just ensure these environment variables are set&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;OTEL_EXPORTER_OTLP_ENDPOINT&lt;/STRONG&gt; – your Dynatrace OTLP endpoint (e.g., https://{environmentid}.apps.dynatrace.com/api/v2/otlp/v1/traces)&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;DYNATRACE_API_TOKEN&lt;/STRONG&gt; – a token with trace ingest permissions&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="theharithsa_0-1754163395288.png" style="width: 760px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29343i626D2AC924B4FB38/image-dimensions/760x390?v=v2" width="760" height="390" role="button" title="theharithsa_0-1754163395288.png" alt="theharithsa_0-1754163395288.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For advanced use cases, you can create your own NodeSDK instance and pass new McpInstrumentation() alongside other instrumentations&lt;/P&gt;
&lt;H4&gt;&lt;span class="lia-unicode-emoji" title=":hammer_and_wrench:"&gt;🛠&lt;/span&gt;️ Custom attributes&lt;/H4&gt;
&lt;P&gt;Need to enrich spans with more context? Because the instrumentation runs your tool callback in the proper OpenTelemetry context, you can obtain the active span in your callback and set attributes like the model name, API name or custom metadata:&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt; { trace, context } &lt;SPAN class=""&gt;from&lt;/SPAN&gt; &lt;SPAN class=""&gt;'@opentelemetry/api'&lt;/SPAN&gt;;

&lt;SPAN class=""&gt;// inside your MCP tool callback…&lt;/SPAN&gt;
&lt;SPAN class=""&gt;const&lt;/SPAN&gt; span = trace.&lt;SPAN class=""&gt;getSpan&lt;/SPAN&gt;(context.&lt;SPAN class=""&gt;active&lt;/SPAN&gt;());
span?.&lt;SPAN class=""&gt;setAttribute&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'model.name'&lt;/SPAN&gt;, modelName);
span?.&lt;SPAN class=""&gt;setAttribute&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'api.name'&lt;/SPAN&gt;, apiName);
&lt;SPAN class=""&gt;// …rest of your logic&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Alternatively, you can modify the instrumentation itself to set default attributes on every span.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;H4&gt;&lt;span class="lia-unicode-emoji" title=":link:"&gt;🔗&lt;/span&gt;Useful links&lt;/H4&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":package:"&gt;📦&lt;/span&gt;&lt;STRONG&gt;npm package&lt;/STRONG&gt;: &lt;A class="" href="https://www.npmjs.com/package/@theharithsa/opentelemetry-instrumentation-mcp?activeTab=readme" target="_new" rel="noopener"&gt;@theharithsa/opentelemetry-instrumentation-mcp&lt;/A&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":laptop_computer:"&gt;💻&lt;/span&gt;&lt;STRONG&gt;GitHub repo&lt;/STRONG&gt;: &lt;A class="" href="https://github.com/theharithsa/opentelemetry-instrumentation-mcp" target="_new" rel="noopener"&gt;github.com/theharithsa/opentelemetry-instrumentation-mcp&lt;/A&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;If you try out the package, let us know what you think! Pull requests and issues are welcome on GitHub.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2026 08:10:14 GMT</pubDate>
    <dc:creator>theharithsa</dc:creator>
    <dc:date>2026-04-15T08:10:14Z</dc:date>
    <item>
      <title>📦 New Package: Automatic OpenTelemetry Instrumentation for MCP</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-tips/New-Package-Automatic-OpenTelemetry-Instrumentation-for-MCP/m-p/282885#M1711</link>
      <description>&lt;P&gt;I’ve just published &lt;STRONG&gt;opentelemetry-instrumentation-mcp&lt;/STRONG&gt;, a (v1.0.0) package that makes it effortless to add observability to Model Context Protocol (MCP) applications.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Why it matters:&lt;/STRONG&gt;&lt;BR /&gt;This package automatically instruments every MCP tool call with a span and exports those spans via OTLP to Dynatrace. No more boilerplate around tracer.startSpan – you get built‑in OpenTelemetry setup and error handling out of the box&lt;/P&gt;
&lt;H4&gt;&lt;span class="lia-unicode-emoji" title=":key:"&gt;🔑&lt;/span&gt;Key features&lt;/H4&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Automatic instrumentation&lt;/STRONG&gt; of MCP tool calls – each invocation gets its own span&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Built‑in OpenTelemetry NodeSDK&lt;/STRONG&gt; – no manual SDK configuration needed&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Zero‑code integration&lt;/STRONG&gt; – just import and go&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;OTLP export&lt;/STRONG&gt; to Dynatrace – the package reads OTEL_EXPORTER_OTLP_ENDPOINT and DYNATRACE_API_TOKEN environment variables and sends your traces to Dynatrace for you&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Comprehensive tracing&lt;/STRONG&gt; with error tracking – exceptions are captured and spans are marked with error status automatically&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;H4&gt;&lt;span class="lia-unicode-emoji" title=":rocket:"&gt;🚀&lt;/span&gt;Getting started&lt;/H4&gt;
&lt;P&gt;Install the package from npm:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;npm install &lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/39872"&gt;@theharithsa&lt;/a&gt;/opentelemetry-instrumentation-mcp&lt;/LI-CODE&gt;
&lt;P&gt;For most users, the &lt;STRONG&gt;auto‑registration&lt;/STRONG&gt; approach is easiest: at the very top of your application’s entry point (e.g., src/index.ts), add a single import line:&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt; &lt;SPAN class=""&gt;'@theharithsa/opentelemetry-instrumentation-mcp/register'&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;That’s it! The package will start the OpenTelemetry SDK, load the default Node instrumentations and the MCP instrumentation, and export spans to your Dynatrace tenant. Just ensure these environment variables are set&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;OTEL_EXPORTER_OTLP_ENDPOINT&lt;/STRONG&gt; – your Dynatrace OTLP endpoint (e.g., https://{environmentid}.apps.dynatrace.com/api/v2/otlp/v1/traces)&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;DYNATRACE_API_TOKEN&lt;/STRONG&gt; – a token with trace ingest permissions&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="theharithsa_0-1754163395288.png" style="width: 760px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29343i626D2AC924B4FB38/image-dimensions/760x390?v=v2" width="760" height="390" role="button" title="theharithsa_0-1754163395288.png" alt="theharithsa_0-1754163395288.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For advanced use cases, you can create your own NodeSDK instance and pass new McpInstrumentation() alongside other instrumentations&lt;/P&gt;
&lt;H4&gt;&lt;span class="lia-unicode-emoji" title=":hammer_and_wrench:"&gt;🛠&lt;/span&gt;️ Custom attributes&lt;/H4&gt;
&lt;P&gt;Need to enrich spans with more context? Because the instrumentation runs your tool callback in the proper OpenTelemetry context, you can obtain the active span in your callback and set attributes like the model name, API name or custom metadata:&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt; { trace, context } &lt;SPAN class=""&gt;from&lt;/SPAN&gt; &lt;SPAN class=""&gt;'@opentelemetry/api'&lt;/SPAN&gt;;

&lt;SPAN class=""&gt;// inside your MCP tool callback…&lt;/SPAN&gt;
&lt;SPAN class=""&gt;const&lt;/SPAN&gt; span = trace.&lt;SPAN class=""&gt;getSpan&lt;/SPAN&gt;(context.&lt;SPAN class=""&gt;active&lt;/SPAN&gt;());
span?.&lt;SPAN class=""&gt;setAttribute&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'model.name'&lt;/SPAN&gt;, modelName);
span?.&lt;SPAN class=""&gt;setAttribute&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'api.name'&lt;/SPAN&gt;, apiName);
&lt;SPAN class=""&gt;// …rest of your logic&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Alternatively, you can modify the instrumentation itself to set default attributes on every span.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;H4&gt;&lt;span class="lia-unicode-emoji" title=":link:"&gt;🔗&lt;/span&gt;Useful links&lt;/H4&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":package:"&gt;📦&lt;/span&gt;&lt;STRONG&gt;npm package&lt;/STRONG&gt;: &lt;A class="" href="https://www.npmjs.com/package/@theharithsa/opentelemetry-instrumentation-mcp?activeTab=readme" target="_new" rel="noopener"&gt;@theharithsa/opentelemetry-instrumentation-mcp&lt;/A&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":laptop_computer:"&gt;💻&lt;/span&gt;&lt;STRONG&gt;GitHub repo&lt;/STRONG&gt;: &lt;A class="" href="https://github.com/theharithsa/opentelemetry-instrumentation-mcp" target="_new" rel="noopener"&gt;github.com/theharithsa/opentelemetry-instrumentation-mcp&lt;/A&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;If you try out the package, let us know what you think! Pull requests and issues are welcome on GitHub.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2026 08:10:14 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-tips/New-Package-Automatic-OpenTelemetry-Instrumentation-for-MCP/m-p/282885#M1711</guid>
      <dc:creator>theharithsa</dc:creator>
      <dc:date>2026-04-15T08:10:14Z</dc:date>
    </item>
  </channel>
</rss>

