Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code to support environment variables for exporter does not meet spec. #2436

Closed
longility opened this issue Aug 27, 2021 · 4 comments · Fixed by #2438
Closed

Code to support environment variables for exporter does not meet spec. #2436

longility opened this issue Aug 27, 2021 · 4 comments · Fixed by #2438
Assignees
Labels
bug Something isn't working

Comments

@longility
Copy link
Contributor

What did you do?

import { CollectorTraceExporter } from "@opentelemetry/exporter-collector-proto";

const traceExporter = new CollectorTraceExporter();

I added an env var like so OTEL_EXPORTER_OTLP_ENDPOINT=http://example.com

What did you expect to see?

For the exporter collector to send successfully and internally, automatically append v1/traces and v1/metrics.

What did you see instead?

However, it did not append like the spec says it should if I understand it correctly to where I had to add an env var like so OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://example.com/v1/traces to get it working.

code reference: https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts#L52:L58

    return typeof config.url === 'string'
      ? config.url
      : getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT.length > 0
      ? getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
      : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
      ? getEnv().OTEL_EXPORTER_OTLP_ENDPOINT
      : DEFAULT_COLLECTOR_URL;

Additional context

Specification reference: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md

Target to which the exporter is going to send spans or metrics. The endpoint MUST be a valid URL with scheme (http or https) and host, and MAY contain a port and path. A scheme of https indicates a secure connection. When using OTEL_EXPORTER_OTLP_ENDPOINT, exporters SHOULD follow the collector convention of appending the version and signal to the path (e.g. v1/traces or v1/metrics), if not present already. The per-signal endpoint configuration options take precedence and can be used to override this behavior. See the OTLP Specification for more details.

@longility longility added the bug Something isn't working label Aug 27, 2021
@longility
Copy link
Contributor Author

If this is a bug, I can submit PR to fixing the issue.

@dyladan
Copy link
Member

dyladan commented Aug 27, 2021

The code you linked seems to support the env var. If you're saying it doesn't work then it is indeed a bug.

@longility
Copy link
Contributor Author

@dyladan Sorry, maybe I wasn't clear. It supports the env var, but it doesn't follow the specification.

exporters SHOULD follow the collector convention of appending the version and signal to the path (e.g. v1/traces or v1/metrics), if not present already.

so I would think that if I do OTEL_EXPORTER_OTLP_ENDPOINT=http://example.com, then internally, it should append v1/traces when doing tracing and v1/metrics when doing metrics. However, it does not. I was thrown off as it wasn't working until I realized it wasn't appending v1/traces when I was trying to get tracing working going somewhere else.

@dyladan
Copy link
Member

dyladan commented Aug 27, 2021

ah I understand. yes I would like to see this fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants