<?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 Manual Testing of OTEL Tracing in Dynatrace tips</title>
    <link>https://community.dynatrace.com/t5/Dynatrace-tips/Manual-Testing-of-OTEL-Tracing/m-p/267459#M1552</link>
    <description>&lt;P&gt;&lt;FONT size="3"&gt;Not really a question but more a "how to" on testing an OTEL trace based on some fun I've had getting this going.&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;A couple of assumptions here.&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;1. you are on Linux&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;2. you are using otlphttp not otlp (grpc)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;3. you've already got a functional and configured OTEL collector (&lt;A href="https://github.com/Dynatrace/dynatrace-otel-collector" target="_blank"&gt;GitHub - Dynatrace/dynatrace-otel-collector: Dynatrace distribution of the OpenTelemetry Collector&lt;/A&gt;&amp;nbsp;) that's listening for 'otlphttp' and connected to dynatrace otlp endpoints.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;4. if you are running Istio, you have configured the required Service Entry and Net Pol to allow traffic to the otel collector service.&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;Anyway,&amp;nbsp; &amp;nbsp;next step is to&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;1. shell into a curl pod or target application pod.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;2. switch to the /tmp directory&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;3. run the below script.&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;Things you might like to change&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;** the curl command is pointing at the default telemetry service, if you've customised your service address, you'll need to modify the endpoint "&lt;A href="http://service.namespace:4318/v1/traces" target="_blank"&gt;http://service.namespace:4318/v1/traces&lt;/A&gt;"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;(e.g&amp;nbsp;&lt;A href="http://otel-collector-opentelemetry-collector.dynatrace:4318/v1/traces" target="_blank"&gt;http://otel-collector-opentelemetry-collector.dynatrace:4318/v1/traces&lt;/A&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;-- service name that is displayed in dynatrace.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"key": "service.name",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"value": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"stringValue": "my.service_name"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;-- span attributes that can be searched in dynatrace.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;"key": "my.scope.attribute",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"value": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"stringValue": "some scope attribute"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;"key": "my.span.attr",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"value": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"stringValue": "some value"&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;When it comes in, it will look like this.&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gopher_1-1736908745731.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/25723iC6E4C15822C9C7E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gopher_1-1736908745731.png" alt="gopher_1-1736908745731.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Script is below, it will put in the recent timestamp and generate unique trace and span id's.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#!/bin/sh
# Generate a unique traceId and current timestamp in nanoseconds
TRACE_ID=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
SPAN_ID=$(cat /proc/sys/kernel/random/uuid | tr -d '-' | cut -c1-16)
START_TIME=$(date -u +"%s%N")
# Ensure the start time is 19 digits long with trailing zeros
START_TIME=$(printf "%s%09d" ${START_TIME:0:10} ${START_TIME:10})
# Calculate the end time by adding 1 second (1000000000 nanoseconds) to the start time
END_TIME=$((${START_TIME} + 1000000000))
# Ensure the end time is 19 digits long
END_TIME=$(printf "%019d" $END_TIME)
# Create a unique filename for the span data
FILENAME="span_$(date -u +"%Y%m%d%H%M%S").json"
# Create the span data with the unique traceId and current timestamp
cat &amp;lt;&amp;lt;EOF &amp;gt; $FILENAME
{
  "resourceSpans": [
    {
      "resource": {
        "attributes": [
          {
            "key": "service.name",
            "value": {
              "stringValue": "my.service_name"
            }
          }
        ]
      },
      "scopeSpans": [
        {
          "scope": {
            "name": "my.library",
            "version": "1.0.0",
            "attributes": [
              {
                "key": "my.scope.attribute",
                "value": {
                  "stringValue": "some scope attribute"
                }
              }
            ]
          },
          "spans": [
            {
              "traceId": "$TRACE_ID",
              "spanId": "$SPAN_ID",
              "parentSpanId": "EEE19B7EC3C1B173",
              "name": "I'm a server span",
              "startTimeUnixNano": "$START_TIME",
              "endTimeUnixNano": "$END_TIME",
              "kind": 2,
              "attributes": [
                {
                  "key": "my.span.attr",
                  "value": {
                    "stringValue": "some value"
                  }
                }
              ],
              "droppedAttributesCount": 0,
              "events": [],
              "droppedEventsCount": 0,
              "status": {
                "code": 1
              }
            }
          ]
        }
      ]
    }
  ]
}
EOF
# Send the span data using curl
curl -vvv -i http://otel-collector-opentelemetry-collector:4318/v1/traces -X POST -H "Content-Type: application/json" -d @$FILENAME
# Print the timestamps and traceId
echo "Trace ID: $TRACE_ID"
echo "Start Time (nanoseconds): $START_TIME"
echo "End Time (nanoseconds): $END_TIME"
echo "Span data saved to: $FILENAME"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Hope it helps someone.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jan 2025 02:49:43 GMT</pubDate>
    <dc:creator>gopher</dc:creator>
    <dc:date>2025-01-15T02:49:43Z</dc:date>
    <item>
      <title>Manual Testing of OTEL Tracing</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-tips/Manual-Testing-of-OTEL-Tracing/m-p/267459#M1552</link>
      <description>&lt;P&gt;&lt;FONT size="3"&gt;Not really a question but more a "how to" on testing an OTEL trace based on some fun I've had getting this going.&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;A couple of assumptions here.&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;1. you are on Linux&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;2. you are using otlphttp not otlp (grpc)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;3. you've already got a functional and configured OTEL collector (&lt;A href="https://github.com/Dynatrace/dynatrace-otel-collector" target="_blank"&gt;GitHub - Dynatrace/dynatrace-otel-collector: Dynatrace distribution of the OpenTelemetry Collector&lt;/A&gt;&amp;nbsp;) that's listening for 'otlphttp' and connected to dynatrace otlp endpoints.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;4. if you are running Istio, you have configured the required Service Entry and Net Pol to allow traffic to the otel collector service.&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;Anyway,&amp;nbsp; &amp;nbsp;next step is to&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;1. shell into a curl pod or target application pod.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;2. switch to the /tmp directory&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;3. run the below script.&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;Things you might like to change&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;** the curl command is pointing at the default telemetry service, if you've customised your service address, you'll need to modify the endpoint "&lt;A href="http://service.namespace:4318/v1/traces" target="_blank"&gt;http://service.namespace:4318/v1/traces&lt;/A&gt;"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;(e.g&amp;nbsp;&lt;A href="http://otel-collector-opentelemetry-collector.dynatrace:4318/v1/traces" target="_blank"&gt;http://otel-collector-opentelemetry-collector.dynatrace:4318/v1/traces&lt;/A&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;-- service name that is displayed in dynatrace.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"key": "service.name",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"value": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"stringValue": "my.service_name"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;-- span attributes that can be searched in dynatrace.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;"key": "my.scope.attribute",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"value": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"stringValue": "some scope attribute"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;"key": "my.span.attr",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"value": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;"stringValue": "some value"&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;When it comes in, it will look like this.&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gopher_1-1736908745731.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/25723iC6E4C15822C9C7E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gopher_1-1736908745731.png" alt="gopher_1-1736908745731.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Script is below, it will put in the recent timestamp and generate unique trace and span id's.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#!/bin/sh
# Generate a unique traceId and current timestamp in nanoseconds
TRACE_ID=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
SPAN_ID=$(cat /proc/sys/kernel/random/uuid | tr -d '-' | cut -c1-16)
START_TIME=$(date -u +"%s%N")
# Ensure the start time is 19 digits long with trailing zeros
START_TIME=$(printf "%s%09d" ${START_TIME:0:10} ${START_TIME:10})
# Calculate the end time by adding 1 second (1000000000 nanoseconds) to the start time
END_TIME=$((${START_TIME} + 1000000000))
# Ensure the end time is 19 digits long
END_TIME=$(printf "%019d" $END_TIME)
# Create a unique filename for the span data
FILENAME="span_$(date -u +"%Y%m%d%H%M%S").json"
# Create the span data with the unique traceId and current timestamp
cat &amp;lt;&amp;lt;EOF &amp;gt; $FILENAME
{
  "resourceSpans": [
    {
      "resource": {
        "attributes": [
          {
            "key": "service.name",
            "value": {
              "stringValue": "my.service_name"
            }
          }
        ]
      },
      "scopeSpans": [
        {
          "scope": {
            "name": "my.library",
            "version": "1.0.0",
            "attributes": [
              {
                "key": "my.scope.attribute",
                "value": {
                  "stringValue": "some scope attribute"
                }
              }
            ]
          },
          "spans": [
            {
              "traceId": "$TRACE_ID",
              "spanId": "$SPAN_ID",
              "parentSpanId": "EEE19B7EC3C1B173",
              "name": "I'm a server span",
              "startTimeUnixNano": "$START_TIME",
              "endTimeUnixNano": "$END_TIME",
              "kind": 2,
              "attributes": [
                {
                  "key": "my.span.attr",
                  "value": {
                    "stringValue": "some value"
                  }
                }
              ],
              "droppedAttributesCount": 0,
              "events": [],
              "droppedEventsCount": 0,
              "status": {
                "code": 1
              }
            }
          ]
        }
      ]
    }
  ]
}
EOF
# Send the span data using curl
curl -vvv -i http://otel-collector-opentelemetry-collector:4318/v1/traces -X POST -H "Content-Type: application/json" -d @$FILENAME
# Print the timestamps and traceId
echo "Trace ID: $TRACE_ID"
echo "Start Time (nanoseconds): $START_TIME"
echo "End Time (nanoseconds): $END_TIME"
echo "Span data saved to: $FILENAME"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Hope it helps someone.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 02:49:43 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-tips/Manual-Testing-of-OTEL-Tracing/m-p/267459#M1552</guid>
      <dc:creator>gopher</dc:creator>
      <dc:date>2025-01-15T02:49:43Z</dc:date>
    </item>
  </channel>
</rss>

