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

feat: add process discovery tests #3981

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions manifests/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ tests/:
Test_Parametric_OtelSpan_Set_Name: bug (APMAPI-778) # updates the operation name of the span not the resource name
Test_Parametric_Otel_Baggage: incomplete_test_app (otel baggage endpoints are not implemented)
Test_Parametric_Otel_Current_Span: incomplete_test_app (otel current span endpoint are not implemented)
test_process_discovery.py: missing_feature
test_span_events.py: missing_feature
test_span_links.py: missing_feature
test_telemetry.py:
Expand Down
1 change: 1 addition & 0 deletions manifests/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ tests/:
Test_Parametric_OtelSpan_Start: bug (APMAPI-778) # String attributes are incorrectly stored/serialized in a list
Test_Parametric_Otel_Baggage: missing_feature (otel baggage is not supported)
Test_Parametric_Otel_Current_Span: missing_feature (otel current span endpoint is not defined)
test_process_discovery.py: missing_feature
test_span_events.py: missing_feature
test_span_links.py: missing_feature
test_telemetry.py:
Expand Down
1 change: 1 addition & 0 deletions manifests/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,7 @@ tests/:
Test_Parametric_DDTrace_Current_Span: bug (APMAPI-778) # Fails to retreive the current span after a span has finished
Test_Parametric_Otel_Baggage: missing_feature (otel baggage is not supported)
Test_Parametric_Otel_Current_Span: bug (APMAPI-778) # Current span endpoint does not return DataDog spans created by the otel api
test_process_discovery.py: missing_feature
test_span_events.py: missing_feature
test_span_links.py: missing_feature
test_telemetry.py:
Expand Down
1 change: 1 addition & 0 deletions manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ tests/:
Test_Parametric_Otel_Current_Span: incomplete_test_app (otel current_span endpoint is not supported)
test_partial_flushing.py:
Test_Partial_Flushing: bug (APMLP-270)
test_process_discovery.py: missing_feature
test_span_events.py: missing_feature
test_span_links.py:
Test_Span_Links: *ref_5_3_0
Expand Down
1 change: 1 addition & 0 deletions manifests/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ tests/:
Test_Parametric_Otel_Current_Span: bug (APMAPI-778) # otel current span endpoint should return a span and trace id of zero if no span is "active"
test_partial_flushing.py:
Test_Partial_Flushing: missing_feature
test_process_discovery.py: missing_feature
test_sampling_delegation.py:
Test_Decisionless_Extraction: >-
missing_feature
Expand Down
1 change: 1 addition & 0 deletions manifests/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ tests/:
Test_Parametric_Otel_Baggage: v2.16.0
test_partial_flushing.py:
Test_Partial_Flushing: flaky (APMAPI-734)
test_process_discovery.py: missing_feature
test_sampling_delegation.py:
Test_Decisionless_Extraction: v2.8.0
test_sampling_span_tags.py:
Expand Down
1 change: 1 addition & 0 deletions manifests/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ tests/:
Test_Parametric_Otel_Current_Span: incomplete_test_app (otel current span endpoint is not supported)
test_partial_flushing.py: # Not configurable in a standard way
Test_Partial_Flushing: missing_feature
test_process_discovery.py: missing_feature
test_sampling_delegation.py:
Test_Decisionless_Extraction: v2.4.0
test_span_events.py: missing_feature
Expand Down
69 changes: 69 additions & 0 deletions tests/parametric/test_process_discovery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""Test the instrumented process discovery mechanism feature."""

import pytest
import json
import msgpack
from jsonschema import validate as validation_jsonschema
from utils import features, scenarios


def find_dd_memfds(test_library, pid: int) -> list[str]:
rc, out = test_library.container_exec_run(f"find /proc/{pid}/fd -lname '/memfd:datadog-tracer-info*'")
if not rc:
return []

return out.split()


def validate_schema(payload: str) -> bool:
schema = None
with open("utils/interfaces/schemas/library/process-discovery.json", "r") as f:
schema = json.load(f)

try:
validation_jsonschema(payload, schema)
return True
except Exception:
return False


def read_memfd(test_library, memfd_path: str):
rc, output = test_library.container_exec_run_raw(f"cat {memfd_path}")
if not rc:
return rc, output

return rc, msgpack.unpackb(output)


@scenarios.parametric
@features.process_discovery
class Test_ProcessDiscovery:
@pytest.mark.parametrize(
"library_env",
[
{"DD_SERVICE": "a", "DD_ENV": "test", "DD_VERSION": "0.1.0"},
{"DD_SERVICE": "b", "DD_ENV": "second-test", "DD_VERSION": "0.2.0"},
],
)
def test_metadata_content(self, test_library, library_env):
"""Verify the content of the memfd file matches the expected metadata format and structure"""
with test_library:
# NOTE(@dmehala): the server is started on container is always pid 1.
# That's a strong assumption :hehe:
# Maybe we should use `pidof pidof parametric-http-server` instead.
memfds = find_dd_memfds(test_library, 1)
assert len(memfds) == 1

rc, tracer_metadata = read_memfd(test_library, memfds[0])
assert rc
assert validate_schema(tracer_metadata)

assert tracer_metadata["schema_version"] == 1
assert tracer_metadata["runtime_id"]
# assert tracer_metadata["hostname"]
# TODO(@dmehala): how to get the version?
# assert tracer_metadata["tracer_version"] ==
assert tracer_metadata["tracer_language"] == test_library.lang
assert tracer_metadata["service_name"] == library_env["DD_SERVICE"]
assert tracer_metadata["service_version"] == library_env["DD_VERSION"]
assert tracer_metadata["service_env"] == library_env["DD_ENV"]
25 changes: 21 additions & 4 deletions utils/_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,9 @@ def semantic_core_validations(test_object):
return test_object

@staticmethod
def aws_sqs_span_creationcontext_propagation_via_xray_header_with_dd_trace(test_object):
def aws_sqs_span_creationcontext_propagation_via_xray_header_with_dd_trace(
test_object,
):
"""[AWS-SQS][Span Creation][Context Propagation][AWS X-Ray] with dd-trace

https://feature-parity.us1.prod.dog/#/?feature=263
Expand All @@ -1733,7 +1735,9 @@ def aws_sqs_span_creationcontext_propagation_via_xray_header_with_dd_trace(test_
return test_object

@staticmethod
def aws_sqs_span_creationcontext_propagation_via_message_attributes_with_dd_trace(test_object):
def aws_sqs_span_creationcontext_propagation_via_message_attributes_with_dd_trace(
test_object,
):
"""[AWS-SQS][Span Creation][Context Propagation][AWS Message Attributes] with dd-trace

https://feature-parity.us1.prod.dog/#/?feature=264
Expand Down Expand Up @@ -1796,7 +1800,9 @@ def rabbitmq_span_creationcontext_propagation_with_dd_trace(test_object):
return test_object

@staticmethod
def aws_sns_span_creationcontext_propagation_via_message_attributes_with_dd_trace(test_object):
def aws_sns_span_creationcontext_propagation_via_message_attributes_with_dd_trace(
test_object,
):
"""[AWS-SNS][Span Creation][Context Propagation] with dd-trace

https://feature-parity.us1.prod.dog/#/?feature=271
Expand Down Expand Up @@ -1850,7 +1856,9 @@ def host_block_list(test_object):
return test_object

@staticmethod
def aws_kinesis_span_creationcontext_propagation_via_message_attributes_with_dd_trace(test_object):
def aws_kinesis_span_creationcontext_propagation_via_message_attributes_with_dd_trace(
test_object,
):
"""[AWS-Kinesis][Span Creation][Context Propagation] with dd-trace

https://feature-parity.us1.prod.dog/#/?feature=280
Expand Down Expand Up @@ -2417,5 +2425,14 @@ def single_span_ingestion_control(test_object):
pytest.mark.features(feature_id=366)(test_object)
return test_object

@staticmethod
def process_discovery(test_object):
"""Process Disocvery

https://feature-parity.us1.prod.dog/#/?feature=367
"""
pytest.mark.features(feature_id=362)(test_object)
return test_object


features = _Features()
49 changes: 49 additions & 0 deletions utils/interfaces/schemas/library/process-discovery.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "/library/process-discovery.json",
"title": "Tracer Metadata",
"description": "Metadata format used for process discovery",
"type": "object",
"properties": {
"schema_version": {
"type": "integer",
"description": "Version of the schema"
},
"runtime_id": {
"type": "string",
"description": "Runtime UUID"
},
"tracer_version": {
"type": "string",
"description": "Version of the Datadog tracer library"
},
"tracer_language": {
"type": "string",
"description": "Programming language of the tracer library"
},
"hostname": {
"type": "string",
"description": "An identifier for the machine running the process"
},
"service_name": {
"type": "string",
"description": "Name of the service being instrumented"
},
"service_env": {
"type": "string",
"description": "Environment of the service being instrumented"
},
"service_version": {
"type": "string",
"description": "Version of the service being instrumented"
}
},
"required": [
"schema_version",
"tracer_version",
"tracer_language",
"hostname"
]
}


Loading
Loading