Skip to content

Commit

Permalink
Merge branch 'main' into brettlangdon/system-tests.all
Browse files Browse the repository at this point in the history
  • Loading branch information
brettlangdon authored Sep 19, 2024
2 parents 6e7f340 + b07f73a commit b13c16a
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ddtrace/profiling @DataDog/profiling-python
ddtrace/settings/profiling.py @DataDog/profiling-python
ddtrace/internal/datadog/profiling @DataDog/profiling-python
tests/profiling @DataDog/profiling-python
tests/profiling-v2 @DataDog/profiling-python
tests/profiling_v2 @DataDog/profiling-python
.gitlab/tests/profiling.yml @DataDog/profiling-python

# MLObs
Expand Down
44 changes: 0 additions & 44 deletions ddtrace/_trace/_span_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,11 @@

import dataclasses
from enum import Enum
from typing import Any
from typing import Dict
from typing import Optional

from ddtrace.internal.logger import get_logger
from ddtrace.internal.utils.formats import flatten_key_value


log = get_logger(__name__)


class SpanLinkKind(Enum):
"""
A collection of standard SpanLink kinds. It's possible to use others, but these should be used when possible.
Expand Down Expand Up @@ -132,41 +126,3 @@ def __str__(self) -> str:
f"trace_id={self.trace_id} span_id={self.span_id} attributes={attrs_str} "
f"tracestate={self.tracestate} flags={self.flags} dropped_attributes={self._dropped_attributes}"
)


# Span Pointers are currently private, so let's put them here for now


_SPAN_POINTER_SPAN_LINK_TRACE_ID = 0
_SPAN_POINTER_SPAN_LINK_SPAN_ID = 0


class _SpanPointerDirection(Enum):
UPSTREAM = "u"
DOWNSTREAM = "d"


class _SpanPointer(SpanLink):
def __init__(
self,
pointer_kind: str,
pointer_direction: _SpanPointerDirection,
pointer_hash: str,
extra_attributes: Optional[Dict[str, Any]] = None,
):
super().__init__(
trace_id=_SPAN_POINTER_SPAN_LINK_TRACE_ID,
span_id=_SPAN_POINTER_SPAN_LINK_SPAN_ID,
attributes={
"ptr.kind": pointer_kind,
"ptr.dir": pointer_direction.value,
"ptr.hash": pointer_hash,
**(extra_attributes or {}),
},
)

self.kind = SpanLinkKind.SPAN_POINTER.value

def __post_init__(self):
# Do not want to do the trace_id and span_id checks that SpanLink does.
pass
55 changes: 55 additions & 0 deletions ddtrace/_trace/_span_pointer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from enum import Enum
from typing import Any
from typing import Dict
from typing import NamedTuple
from typing import Optional

from ddtrace._trace._span_link import SpanLink
from ddtrace._trace._span_link import SpanLinkKind


_SPAN_POINTER_SPAN_LINK_TRACE_ID = 0
_SPAN_POINTER_SPAN_LINK_SPAN_ID = 0


class _SpanPointerDirection(Enum):
UPSTREAM = "u"
DOWNSTREAM = "d"


class _SpanPointerDescription(NamedTuple):
# Not to be confused with _SpanPointer. This class describes the parameters
# required to attach a span pointer to a Span. It lets us decouple code
# that calculates span pointers from code that actually attaches them to
# the right Span.

pointer_kind: str
pointer_direction: _SpanPointerDirection
pointer_hash: str
extra_attributes: Dict[str, Any]


class _SpanPointer(SpanLink):
def __init__(
self,
pointer_kind: str,
pointer_direction: _SpanPointerDirection,
pointer_hash: str,
extra_attributes: Optional[Dict[str, Any]] = None,
):
super().__init__(
trace_id=_SPAN_POINTER_SPAN_LINK_TRACE_ID,
span_id=_SPAN_POINTER_SPAN_LINK_SPAN_ID,
attributes={
"ptr.kind": pointer_kind,
"ptr.dir": pointer_direction.value,
"ptr.hash": pointer_hash,
**(extra_attributes or {}),
},
)

self.kind = SpanLinkKind.SPAN_POINTER.value

def __post_init__(self):
# Do not want to do the trace_id and span_id checks that SpanLink does.
pass
4 changes: 2 additions & 2 deletions ddtrace/_trace/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from ddtrace import config
from ddtrace._trace._span_link import SpanLink
from ddtrace._trace._span_link import SpanLinkKind
from ddtrace._trace._span_link import _SpanPointer
from ddtrace._trace._span_link import _SpanPointerDirection
from ddtrace._trace._span_pointer import _SpanPointer
from ddtrace._trace._span_pointer import _SpanPointerDirection
from ddtrace._trace.context import Context
from ddtrace._trace.types import _MetaDictType
from ddtrace._trace.types import _MetricDictType
Expand Down
2 changes: 1 addition & 1 deletion riotfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2965,7 +2965,7 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION):
Venv(
name="profile-v2",
# NB riot commands that use this Venv must include --pass-env to work properly
command="python -m tests.profiling.run pytest -v --no-cov --capture=no --benchmark-disable {cmdargs} tests/profiling-v2", # noqa: E501
command="python -m tests.profiling.run pytest -v --no-cov --capture=no --benchmark-disable {cmdargs} tests/profiling_v2", # noqa: E501
env={"DD_PROFILING_ENABLE_ASSERTS": "1", "DD_PROFILING_EXPORT_LIBDD_ENABLED": "1"},
pkgs={
"gunicorn": latest,
Expand Down
2 changes: 1 addition & 1 deletion tests/.suitespec.json
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@
"@bootstrap",
"@core",
"@profiling",
"tests/profiling-v2/*"
"tests/profiling_v2/*"
],
"vendor": [
"@vendor",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/tracer/test_encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import pytest

from ddtrace._trace._span_link import SpanLink
from ddtrace._trace._span_link import _SpanPointerDirection
from ddtrace._trace._span_pointer import _SpanPointerDirection
from ddtrace._trace.context import Context
from ddtrace._trace.span import Span
from ddtrace.constants import ORIGIN_KEY
Expand Down
2 changes: 1 addition & 1 deletion tests/tracer/test_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest

from ddtrace._trace._span_link import SpanLink
from ddtrace._trace._span_link import _SpanPointerDirection
from ddtrace._trace._span_pointer import _SpanPointerDirection
from ddtrace._trace.span import Span
from ddtrace.constants import ENV_KEY
from ddtrace.constants import ERROR_MSG
Expand Down

0 comments on commit b13c16a

Please sign in to comment.