evanderkoogh / otel-cf-workers

An OpenTelemetry compatible library for instrumenting and exporting traces for Cloudflare Workers
BSD 3-Clause "New" or "Revised" License
208 stars 39 forks source link

[Question] Support for sending traces to other tracing backends/vendors? #80

Closed adnanrahic closed 2 months ago

adnanrahic commented 6 months ago

Hi!

I love the lib! 🙌

I used it to set up Wrangler local testing and integration testing with OpenTelemetry traces. I am having some issues setting up the trace exporter for the tracing backends/vendors I'm using in prod.

It works great with Honeycomb!

Wanted to ask if you have any pointers or guides on how to set up other vendors? I'm seemingly using the same config as with Honeycomb, but the trace exporter fails with strange errors.

Sample Error 1 Here's the error when I use Grafana Cloud:

(log) Error sending spans to exporter: ReferenceError: XMLHttpRequest is not defined

Grafana Cloud exporter options:

const options = {
    url: 'https://otlp-gateway-prod-us-central-0.grafana.net/otlp',
    headers: { 'Authorization': 'Basic <base64 user:token' },
}

Sample Error 2 Here's the error when I use Tracetest:

(debug) sendBeacon - can send {"resourceSpans":[{ <redacted> }]}

Tracetest exporter options:

const options = {
    url: 'https://agent-<token>.tracetest.io:4318/v1/traces',
}

Is there anything specific with the Honeycomb config I can replicate for the other ones I'm using? 🤔

Thanks! Awesome product! Excited to see it grow. 🔥

johndistasio commented 5 months ago

For whatever it's worth, I was able to use this library out of the box with HyperDX. I'm using version 1.0.0-rc.15.

adnanrahic commented 5 months ago

I managed to figure out that the underlying JavaScript lib for the OpenTelemetry exporter using OTLP HTTP does not support custom ports when using TLS (https) endpoints.

This might be the main issue why I was seeing this issue. I will try again and see if I can reproduce it.

RichiCoder1 commented 5 months ago

Cloudflare workers doesn't allow you to fetch against a non-default port. You'd need to use Origin rules to support that case or expose the HTTP endpoint on a standard (443) port.

jahands commented 3 months ago

This library already supports sending to multiple providers. For example, here's Axiom.co's docs: https://axiom.co/docs/guides/opentelemetry-cloudflare-workers