Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ manifest:
tests/parametric/otel_env_vars/test_otel_exporter_otlp_logs_endpoint.py::Test_OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_metrics_endpoint.py::Test_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_endpoint.py::Test_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_headers.py::Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: missing_feature
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER: missing_feature
tests/parametric/otel_env_vars/test_otel_metric_export_timeout.py::Test_OTEL_METRIC_EXPORT_TIMEOUT: missing_feature
tests/parametric/otel_env_vars/test_otel_resource_attributes.py::Test_OTEL_RESOURCE_ATTRIBUTES: missing_feature
Expand Down
10 changes: 10 additions & 0 deletions manifests/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,16 @@ manifest:
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_metrics_endpoint.py::Test_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT::test_empty_falls_back_to_global_endpoint
: bug (APMAPI-2509)
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_endpoint.py::Test_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: v3.41.0
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_headers.py::Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS: v3.41.0
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_headers.py::Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS::test_empty_is_treated_as_unset
: bug (APMAPI-2479)
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: v3.41.0
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL::test_empty_is_treated_as_unset
: bug (APMAPI-2531)
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL::test_grpc_protocol_is_used_for_trace_export
: missing_feature (Trace exporter does not support gRPC)
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL::test_unset_uses_specification_default
: bug (APMAPI-2531)
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER: v3.37.0
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER::test_console: missing_feature (Only otlp and none exporters are implemented)
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER::test_deprecated_values: missing_feature (Only otlp and none exporters are implemented)
Expand Down
2 changes: 2 additions & 0 deletions manifests/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,8 @@ manifest:
tests/parametric/otel_env_vars/test_otel_exporter_otlp_logs_endpoint.py::Test_OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: v2.7.0
tests/parametric/otel_env_vars/test_otel_exporter_otlp_metrics_endpoint.py::Test_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: v2.6.0
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_endpoint.py::Test_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: v2.8.0
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_headers.py::Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: missing_feature
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER: missing_feature (OTEL_LOGS_EXPORTER does not configure the logs pipeline)
tests/parametric/otel_env_vars/test_otel_metric_export_timeout.py::Test_OTEL_METRIC_EXPORT_TIMEOUT: v2.5.0
tests/parametric/otel_env_vars/test_otel_metric_export_timeout.py::Test_OTEL_METRIC_EXPORT_TIMEOUT::test_invalid_values: bug (APMAPI-2460)
Expand Down
6 changes: 6 additions & 0 deletions manifests/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3963,6 +3963,12 @@ manifest:
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_endpoint.py::Test_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: v1.61.0
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_endpoint.py::Test_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT::test_empty_falls_back_to_global_endpoint
: bug (APMAPI-2412)
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_headers.py::Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS: v1.61.0
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_headers.py::Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS::test_empty_is_treated_as_unset
: bug (APMAPI-2474)
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: v1.61.0
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL::test_grpc_protocol_is_used_for_trace_export
: incomplete_test_app (gRPC trace requests are not captured by the HTTP request assertion)
Comment thread
MilanGarnier marked this conversation as resolved.
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER: v1.54.0
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER::test_console: missing_feature (Only otlp and none exporters are implemented)
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER::test_deprecated_values: missing_feature (Only otlp and none exporters are implemented)
Expand Down
2 changes: 2 additions & 0 deletions manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2300,6 +2300,8 @@ manifest:
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_metrics_endpoint.py::Test_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT::test_otlp_metrics_custom_endpoint_grpc
: missing_feature (Does not support grpc)
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_endpoint.py::Test_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: v6.0.0
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_headers.py::Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: missing_feature
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER: missing_feature (OTEL_LOGS_EXPORTER does not configure the logs pipeline)
tests/parametric/otel_env_vars/test_otel_metric_export_timeout.py::Test_OTEL_METRIC_EXPORT_TIMEOUT: v5.83.0
tests/parametric/otel_env_vars/test_otel_metric_export_timeout.py::Test_OTEL_METRIC_EXPORT_TIMEOUT::test_invalid_values: bug (APMAPI-2463)
Expand Down
2 changes: 2 additions & 0 deletions manifests/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,8 @@ manifest:
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_metrics_endpoint.py::Test_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT::test_otlp_metrics_custom_endpoint_grpc
: missing_feature (Does not support grpc)
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_endpoint.py::Test_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_headers.py::Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: missing_feature
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER: v1.23.0
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER::test_deprecated_values: missing_feature (Deprecated logging exporter is not implemented)
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER::test_invalid: bug (APMAPI-2507)
Expand Down
4 changes: 4 additions & 0 deletions manifests/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,10 @@ manifest:
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_metrics_endpoint.py::Test_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT::test_empty_falls_back_to_global_endpoint
: bug (APMAPI-2414)
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_endpoint.py::Test_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: v4.11.0
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_headers.py::Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS: v4.11.0
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: v4.11.0
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL::test_grpc_protocol_is_used_for_trace_export
: missing_feature (Trace exporter does not support gRPC)
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER: # TODO: a lower version might be supported
- declaration: missing_feature (OTEL_LOGS_EXPORTER does not configure the logs pipeline)
component_version: <4.15.2
Expand Down
2 changes: 2 additions & 0 deletions manifests/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2339,6 +2339,8 @@ manifest:
? tests/parametric/otel_env_vars/test_otel_exporter_otlp_metrics_endpoint.py::Test_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT::test_otlp_metrics_custom_endpoint_grpc
: missing_feature (Does not support grpc)
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_endpoint.py::Test_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_headers.py::Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: missing_feature
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER: v2.34.0
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER::test_console: missing_feature (Only otlp and none exporters are implemented)
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER::test_deprecated_values: missing_feature (Only otlp and none exporters are implemented)
Expand Down
2 changes: 2 additions & 0 deletions manifests/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ manifest:
tests/parametric/otel_env_vars/test_otel_exporter_otlp_logs_endpoint.py::Test_OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: v0.3.0
tests/parametric/otel_env_vars/test_otel_exporter_otlp_metrics_endpoint.py::Test_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: v0.3.0
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_endpoint.py::Test_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_headers.py::Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS: missing_feature
tests/parametric/otel_env_vars/test_otel_exporter_otlp_traces_protocol.py::Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: missing_feature
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER: v0.3.0
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER::test_console: missing_feature (Only otlp and none exporters are implemented)
tests/parametric/otel_env_vars/test_otel_logs_exporter.py::Test_OTEL_LOGS_EXPORTER::test_deprecated_values: missing_feature (Only otlp and none exporters are implemented)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
from tests.parametric.conftest import APMLibrary
from utils import features, pytest, scenarios
from utils.docker_fixtures import TestAgentAPI
from utils.docker_fixtures._test_agent import AgentRequest


VARIABLE = "OTEL_EXPORTER_OTLP_TRACES_HEADERS"

BASE_ENVIRONMENT = {
"DD_TRACE_AGENT_PROTOCOL_VERSION": None,
"DD_TRACE_ENABLED": None,
"DD_TRACE_OTEL_ENABLED": "true",
"OTEL_EXPORTER_OTLP_HEADERS": "dd-protocol=otlp,dd-otlp-path=agent",
"OTEL_EXPORTER_OTLP_TRACES_PROTOCOL": "http/protobuf",
"OTEL_TRACES_EXPORTER": "otlp",
}


@pytest.fixture(autouse=True)
def _trace_export_endpoint(
library_env: dict[str, str],
test_agent: TestAgentAPI,
test_agent_otlp_http_port: int,
) -> None:
library_env["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] = (
f"http://{test_agent.container_name}:{test_agent_otlp_http_port}/v1/traces"
)


def _trace_request(test_agent: TestAgentAPI, test_library: APMLibrary) -> AgentRequest:
with test_library as library:
with library.dd_start_span(name="otel-otlp-traces-headers"):
pass
library.dd_flush()

requests = [request for request in test_agent.requests() if request["url"].endswith("/v1/traces")]
assert requests, f"Expected OTLP trace request, got {test_agent.requests()}"
return requests[0]


def _request_headers(request: AgentRequest) -> dict[str, str]:
return {name.lower(): value for name, value in request["headers"].items()}


def _assert_routing_headers(headers: dict[str, str]) -> None:
assert headers.get("dd-protocol") == "otlp"
assert headers.get("dd-otlp-path") == "agent"


@scenarios.parametric
@features.otel_exporter_otlp_traces_headers
class Test_OTEL_EXPORTER_OTLP_TRACES_HEADERS:
@pytest.mark.parametrize(
("library_env", "expected_headers"),
[
pytest.param(
{
**BASE_ENVIRONMENT,
VARIABLE: "dd-protocol=otlp,dd-otlp-path=agent,header-one=value-one,header-two=value-two",
},
{"header-one": "value-one", "header-two": "value-two"},
id="two-header-pairs",
),
],
)
def test_header_pairs_are_sent_on_trace_export(
self,
test_agent: TestAgentAPI,
test_library: APMLibrary,
*,
expected_headers: dict[str, str],
) -> None:
headers = _request_headers(_trace_request(test_agent, test_library))
_assert_routing_headers(headers)
for name, value in expected_headers.items():
assert headers.get(name) == value, f"Expected {name}={value}, got {headers}"

@pytest.mark.parametrize("library_env", [pytest.param({**BASE_ENVIRONMENT}, id="unset")])
def test_unset_uses_global_headers(
self,
test_agent: TestAgentAPI,
test_library: APMLibrary,
) -> None:
headers = _request_headers(_trace_request(test_agent, test_library))
_assert_routing_headers(headers)
assert all(name not in headers for name in ("header-one", "header-two"))

@pytest.mark.parametrize("library_env", [pytest.param({**BASE_ENVIRONMENT, VARIABLE: ""}, id="empty")])
def test_empty_is_treated_as_unset(
self,
test_agent: TestAgentAPI,
test_library: APMLibrary,
) -> None:
headers = _request_headers(_trace_request(test_agent, test_library))
_assert_routing_headers(headers)
assert all(name not in headers for name in ("header-one", "header-two"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
from tests.parametric.conftest import APMLibrary
from utils import features, pytest, scenarios
from utils.docker_fixtures import TestAgentAPI
from utils.docker_fixtures._test_agent import AgentRequest


OTLP_TRACE_PATH = "/v1/traces"
ROUTING_HEADERS = "dd-protocol=otlp,dd-otlp-path=agent"
DEFAULT_PROTOCOL = "http/protobuf"

BASE_ENVIRONMENT = {
"DD_TRACE_AGENT_PROTOCOL_VERSION": None,
"DD_TRACE_ENABLED": None,
"DD_TRACE_OTEL_ENABLED": "true",
"OTEL_EXPORTER_OTLP_TRACES_HEADERS": ROUTING_HEADERS,
"OTEL_TRACES_EXPORTER": "otlp",
}

CONTENT_TYPES = {
"grpc": "application/grpc",
"http/protobuf": "application/x-protobuf",
"http/json": "application/json",
}

GRPC_PROTOCOL_VALUE = [
pytest.param({**BASE_ENVIRONMENT, "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL": "grpc"}, "grpc", id="grpc"),
]

HTTP_PROTOCOL_VALUES = [
pytest.param(
{**BASE_ENVIRONMENT, "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL": "http/protobuf"},
"http/protobuf",
id="http-protobuf",
),
pytest.param(
{**BASE_ENVIRONMENT, "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL": "http/json"},
"http/json",
id="http-json",
),
]

UNSET_VALUE = [pytest.param({**BASE_ENVIRONMENT}, DEFAULT_PROTOCOL, id="unset")]
EMPTY_VALUE = [
pytest.param(
{**BASE_ENVIRONMENT, "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL": ""},
DEFAULT_PROTOCOL,
id="empty",
)
]


@pytest.fixture(autouse=True)
def _trace_export_endpoint(
library_env: dict[str, str],
test_agent: TestAgentAPI,
test_agent_otlp_http_port: int,
test_agent_otlp_grpc_port: int,
) -> None:
protocol = library_env.get("OTEL_EXPORTER_OTLP_TRACES_PROTOCOL") or DEFAULT_PROTOCOL
if protocol == "grpc":
library_env["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] = (
f"http://{test_agent.container_name}:{test_agent_otlp_grpc_port}"
)
return

library_env["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] = (
f"http://{test_agent.container_name}:{test_agent_otlp_http_port}{OTLP_TRACE_PATH}"
)


def _trace_request(test_agent: TestAgentAPI, test_library: APMLibrary) -> AgentRequest:
with test_library as library:
with library.dd_start_span(name="otel-otlp-traces-protocol"):
pass
library.dd_flush()

requests = [request for request in test_agent.requests() if request["url"].endswith(OTLP_TRACE_PATH)]
assert requests, f"Expected OTLP trace request, got {test_agent.requests()}"
return requests[0]


def _assert_protocol(
test_agent: TestAgentAPI,
test_library: APMLibrary,
expected_protocol: str,
) -> None:
request = _trace_request(test_agent, test_library)
headers = {name.lower(): value for name, value in request["headers"].items()}
assert headers.get("content-type", "").startswith(CONTENT_TYPES[expected_protocol])


@scenarios.parametric
@features.otel_exporter_otlp_traces_protocol
class Test_OTEL_EXPORTER_OTLP_TRACES_PROTOCOL:
@pytest.mark.parametrize(("library_env", "expected_protocol"), GRPC_PROTOCOL_VALUE)
def test_grpc_protocol_is_used_for_trace_export(
self,
test_agent: TestAgentAPI,
test_library: APMLibrary,
*,
expected_protocol: str,
) -> None:
_assert_protocol(test_agent, test_library, expected_protocol)

@pytest.mark.parametrize(("library_env", "expected_protocol"), HTTP_PROTOCOL_VALUES)
def test_http_protocol_is_used_for_trace_export(
self,
test_agent: TestAgentAPI,
test_library: APMLibrary,
*,
expected_protocol: str,
) -> None:
_assert_protocol(test_agent, test_library, expected_protocol)

@pytest.mark.parametrize(("library_env", "expected_protocol"), UNSET_VALUE)
def test_unset_uses_specification_default(
self,
test_agent: TestAgentAPI,
test_library: APMLibrary,
*,
expected_protocol: str,
) -> None:
_assert_protocol(test_agent, test_library, expected_protocol)

@pytest.mark.parametrize(("library_env", "expected_protocol"), EMPTY_VALUE)
def test_empty_is_treated_as_unset(
self,
test_agent: TestAgentAPI,
test_library: APMLibrary,
*,
expected_protocol: str,
) -> None:
_assert_protocol(test_agent, test_library, expected_protocol)
Loading