<p>I am using the opentelemetry-ruby otlp exporter for auto instrumentation:
<a href="https://github.com/open-telemetry/opentelemetry-ruby/tree/main/exporter/otlp" rel="nofollow noreferrer">https://github.com/open-telemetry/opentelemetry-ruby/tree/main/exporter/otlp</a></p>
<p>The otel collector was installed as a daemonset:
<a href="https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-collector" rel="nofollow noreferrer">https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-collector</a></p>
<p>I am trying to get the OpenTelemetry collector to collect traces from the Rails application. Both are running in the same cluster, but in different namespaces.</p>
<p>We have enabled auto-instrumentation in the app, but the rails logs are currently showing these errors:</p>
<p><code>E, [2022-04-05T22:37:47.838197 #6] ERROR -- : OpenTelemetry error: Unable to export 499 spans</code></p>
<p>I set the following env variables within the app:</p>
<pre><code>OTEL_LOG_LEVEL=debug
OTEL_EXPORTER_OTLP_ENDPOINT=http://0.0.0.0:4318
</code></pre>
<p>I can't confirm that the application can communicate with the collector pods on this port.
Curling this address from the rails/ruby app returns &quot;Connection Refused&quot;. However I am able to curl <code>http://&lt;OTEL_POD_IP&gt;:4318</code> which returns 404 page not found.</p>
<p>From inside a pod:</p>
<pre><code># curl http://localhost:4318/
curl: (7) Failed to connect to localhost port 4318: Connection refused

# curl http://10.1.0.66:4318/
404 page not found
</code></pre>
<p>This helm chart created a daemonset but there is no service running. Is there some setting I need to enable to get this to work?</p>
<p>I confirmed that otel-collector is running on every node in the cluster and the daemonset has HostPort set to 4318.</p>

<p>The correct solution is to use the <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">Kubernetes Downward API</a> to fetch the node IP address, which will allow you to export the traces directly to the daemonset pod within the same node:</p>
<pre class="lang-yaml prettyprint-override"><code>  containers:
  - name: my-app
    image: my-image
    env:
    - name: HOST_IP
      valueFrom:
        fieldRef:
          fieldPath: status.hostIP
    - name: OTEL_EXPORTER_OTLP_ENDPOINT
      value: http://$(HOST_IP):4318
</code></pre>
<p>Note that using the deployment's service as the endpoint (<code>&lt;service-name&gt;.&lt;namespace&gt;.svc.cluster.local</code>) is incorrect, as it effectively bypasses the daemonset and sends the traces directly to the deployment, which makes the daemonset useless.</p>
