Skip to content
Draft
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
9 changes: 6 additions & 3 deletions manifests/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ manifest:
tests/parametric/test_llm_observability/: irrelevant (library does not implement LLM Observability)
tests/parametric/test_otel_api_interoperability.py::Test_Otel_API_Interoperability: missing_feature
tests/parametric/test_otel_env_vars.py::Test_Otel_Env_Vars: incomplete_test_app (/trace/config endpoint is not implemented)
tests/parametric/test_otel_logs.py: missing_feature
tests/parametric/test_otel_metrics.py: v0.3.0
tests/parametric/test_otel_logs.py: v0.3.0-dev
tests/parametric/test_otel_logs.py::Test_FR11_Telemetry::test_telemetry_metrics: missing_feature (Rust telemetry metrics are not submitted in time to run tests against)
tests/parametric/test_otel_logs.py::Test_FR13_Scope_Fields::test_scope_attributes_field: missing_feature (OpenTelemetry Rust SDK limitation - scope attributes not exported by opentelemetry-otlp)
tests/parametric/test_otel_logs.py::Test_FR13_Scope_Fields::test_scope_schema_url_field: missing_feature (OpenTelemetry Rust SDK limitation - schema_url not exported by opentelemetry-otlp)
tests/parametric/test_otel_logs.py::Test_FR13_Scope_Fields::test_scope_version_field: missing_feature (OpenTelemetry Rust SDK limitation - scope version not exported by opentelemetry-otlp)
tests/parametric/test_otel_metrics.py: v0.3.0-dev
? tests/parametric/test_otel_metrics.py::Test_Otel_Metrics_Api_Instrument::test_otel_histogram_add_non_negative_and_negative_values
: missing_feature (OpenTelemetry Rust SDK does not filter negative values for Histogram.record(). This is a bug in the upstream SDK)
tests/parametric/test_otel_metrics.py::Test_Otel_Metrics_Api_MeterProvider::test_otel_get_meter_by_distinct_schema_url: missing_feature (Rust OpenTelemetry SDK 0.31.0's meter() method does not support schema_url parameter)
tests/parametric/test_otel_metrics.py::Test_Otel_Metrics_Api_MeterProvider::test_otel_get_meter_by_distinct_scope_attributes: missing_feature (Rust OpenTelemetry SDK 0.31.0's meter() method does not support scope attributes parameter)
tests/parametric/test_otel_metrics.py::Test_Otel_Metrics_Host_Name::test_hostname_from_dd_hostname: missing_feature
tests/parametric/test_otel_metrics.py::Test_Otel_Metrics_Telemetry::test_telemetry_metrics_grpc: missing_feature
Expand Down
48 changes: 31 additions & 17 deletions tests/parametric/test_otel_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
from .conftest import APMLibrary


def _extract_trace_id_from_span(span: dict) -> str:
"""Extract the full 128-bit trace ID from a span as a hex string.

Uses otel.trace_id from metadata if available (full 128-bit),
otherwise constructs from _dd.p.tid and trace_id (lower 64 bits).
"""
if "otel.trace_id" in span.get("meta", {}):
return span["meta"]["otel.trace_id"]
root_tid = span["meta"].get("_dd.p.tid", "0" * 16)
return f"{root_tid}{span['trace_id']:016x}"


def _find_log_components(
log_payloads: list[dict], logger_name: str, log_message: str
) -> tuple[dict | None, dict | None, dict | None]:
Expand Down Expand Up @@ -114,14 +126,7 @@ def test_otlp_logs_enabled(self, test_agent: TestAgentAPI, test_library: APMLibr
log_payloads = test_agent.wait_for_num_log_payloads(1)
assert find_log_record(log_payloads, "otlp_logs_enabled", "test_otlp_logs_enabled") is not None

@pytest.mark.parametrize(
"library_env",
[
{"DD_LOGS_OTEL_ENABLED": "false", "DD_TRACE_DEBUG": None},
{"DD_LOGS_OTEL_ENABLED": None, "DD_TRACE_DEBUG": None},
],
ids=["disabled", "default"],
)
@pytest.mark.parametrize("library_env", [{"DD_LOGS_OTEL_ENABLED": "false", "DD_TRACE_DEBUG": None}])
def test_otlp_logs_disabled(self, test_agent: TestAgentAPI, test_library: APMLibrary):
"""Logs are not emitted when disabled."""
with test_library as library:
Expand Down Expand Up @@ -216,8 +221,7 @@ def test_dd_span_context_injection(self, test_agent: TestAgentAPI, test_library:
expected_trace_id = base64.b64decode(log_record["trace_id"]).hex()

root = find_only_span(test_agent.wait_for_num_traces(1))
root_tid = root["meta"].get("_dd.p.tid", "0" * 16)
trace_id = f"{root_tid}{root['trace_id']:016x}"
trace_id = _extract_trace_id_from_span(root)
span_id = f"{root['span_id']:016x}"

assert expected_span_id == span_id, f"Expected span_id {expected_span_id}, got {span_id}, span: {root}"
Expand Down Expand Up @@ -245,8 +249,7 @@ def test_otel_span_context_injection(self, test_agent: TestAgentAPI, test_librar
expected_trace_id = base64.b64decode(log_record["trace_id"]).hex()

root = find_only_span(test_agent.wait_for_num_traces(1))
root_tid = root["meta"].get("_dd.p.tid", "0" * 16)
trace_id = f"{root_tid}{root['trace_id']:016x}"
trace_id = _extract_trace_id_from_span(root)
span_id = f"{root['span_id']:016x}"
assert expected_span_id == span_id, f"Expected span_id {expected_span_id}, got {span_id}, span: {root}"
assert expected_trace_id == trace_id, f"Expected trace_id {expected_trace_id}, got {trace_id}, span: {root}"
Expand Down Expand Up @@ -642,10 +645,14 @@ def test_default_timeout(self, test_agent: TestAgentAPI, test_library: APMLibrar
assert isinstance(exporter_timeout, dict)
assert isinstance(exporter_logs_timeout, dict)

assert exporter_timeout.get("value") == 10000, (
exporter_timeout_value = exporter_timeout.get("value")
assert exporter_timeout_value is not None, "OTEL_EXPORTER_OTLP_TIMEOUT value should not be None"
assert int(exporter_timeout_value) == 10000, (
f"OTEL_EXPORTER_OTLP_TIMEOUT should be 10000, exporter_timeout: {exporter_timeout}"
)
assert exporter_logs_timeout.get("value") == 10000, (
exporter_logs_timeout_value = exporter_logs_timeout.get("value")
assert exporter_logs_timeout_value is not None, "OTEL_EXPORTER_OTLP_LOGS_TIMEOUT value should not be None"
assert int(exporter_logs_timeout_value) == 10000, (
f"OTEL_EXPORTER_OTLP_LOGS_TIMEOUT should be 10000, exporter_logs_timeout: {exporter_logs_timeout}"
)

Expand Down Expand Up @@ -760,9 +767,16 @@ def test_telemetry_exporter_logs_configurations(
)
assert config is not None, f"No configuration found for '{expected_env}'"
assert isinstance(config, dict)
assert config.get("value") == expected_value, (
f"Expected {expected_env} to be {expected_value}, configuration: {config}"
)
value = config.get("value")
assert value is not None, f"Configuration value is None for '{expected_env}'"
if isinstance(expected_value, int):
assert int(value) == expected_value, (
f"Expected {expected_env} to be {expected_value}, configuration: {config}"
)
else:
assert value == expected_value, (
f"Expected {expected_env} to be {expected_value}, configuration: {config}"
)

@pytest.mark.parametrize(
"library_env",
Expand Down
2 changes: 2 additions & 0 deletions utils/build/docker/rust/install_ddtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ if [ -e /binaries/dd-trace-rs ]; then
cargo add --path /binaries/dd-trace-rs/datadog-opentelemetry --features metrics-http,metrics-grpc

echo "install from /binaries/datadog-opentelemetry with metrics-http and metrics-grpc features"
echo "dev" > SYSTEM_TESTS_LIBRARY_VERSION_MODE
else
# TODO: add lastest release from crates.io
cargo add --git "$REPO_URL" --tag "$PROD_TAG" datadog-opentelemetry --features metrics-http,metrics-grpc

echo "install from --git $REPO_URL --tag $PROD_TAG with metrics-http and metrics-grpc features"
echo "release" > SYSTEM_TESTS_LIBRARY_VERSION_MODE
fi

Loading
Loading