hypertrace / javaagent

Hypertrace OpenTelemetry Java agent with payload/body and headers data capture.
Apache License 2.0
33 stars 15 forks source link

fix: use the correct otlp endpoint #287

Closed tim-mwangi closed 3 years ago

tim-mwangi commented 3 years ago

Description

Based on https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md#otlp-exporter-both-span-and-metric-exporters. Neither OTEL_EXPORTER_OTLP_TRACES_ENDPOINT or otel.exporter.otlp.traces.endpoint work

Testing

Ran it on a k8s sample application to test for the case where the default http://localhost:4317 is not set automatically and hence hides the bug.

Checklist:

tim-mwangi commented 3 years ago

@pavolloffay @shashank11p the smoke tests are failing since otel.library.version does not match the agent version. Also I debugged a bit and this attribute is not even set. Should we be concerned about this?

eg. SpringBootDisabledBodyCaptureSmokeTest line 83

Assertions.assertTrue(
        getSpanStream(traces)
                .flatMap(span -> span.getAttributesList().stream())
                .filter(attribute -> attribute.getKey().equals(OTEL_LIBRARY_VERSION_ATTRIBUTE))
                .map(attribute -> attribute.getValue().getStringValue())
                .filter(value -> value.equals(currentAgentVersion))
                .count()
            > 0)
tim-mwangi commented 3 years ago

I dug deeper into this. It seems as if there was a fix put in recently, https://github.com/open-telemetry/opentelemetry-java/commit/9d96758195949bb326bc819805e83c519297ca65, to also check the otel.exporter.otlp.traces.endpoint config and fall back to the value of otel.exporter.otlp.endpoint. The version we are currently using only supports the latter. The class of interest is https://github.com/open-telemetry/opentelemetry-java/blob/9d96758195949bb326bc819805e83c519297ca65/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/SpanExporterConfiguration.java