Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
quinna-h committed Feb 25, 2025
1 parent 960cffa commit 297dda5
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 44 deletions.
8 changes: 1 addition & 7 deletions ddtrace/_trace/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ class Span(object):
"_links",
"_events",
"__weakref__",
"_span_event_formatting",
]

def __init__(
Expand All @@ -146,7 +145,6 @@ def __init__(
on_finish: Optional[List[Callable[["Span"], None]]] = None,
span_api: str = SPAN_API_DATADOG,
links: Optional[List[SpanLink]] = None,
span_event_formatting: Optional[bool] = False,
) -> None:
"""
Create a new span. Call `finish` once the traced operation is over.
Expand Down Expand Up @@ -187,7 +185,6 @@ def __init__(
self._resource = [resource or name]
self.span_type = span_type
self._span_api = span_api
self._span_event_formatting = span_event_formatting

self._meta: _MetaDictType = {}
self.error = 0
Expand Down Expand Up @@ -490,10 +487,7 @@ def _add_event(
self, name: str, attributes: Optional[Dict[str, _JSONType]] = None, timestamp: Optional[int] = None
) -> None:
"""Add an event to the span."""
if self._span_event_formatting is False:
# backwards compatibility: v0.5 and agent versions older than 7.63.0
self._events.append(SpanEvent(name, attributes, timestamp))
# TODO: add top-level span events for v0.4 and agent versions greater than or equal 7.63.0
self._events.append(SpanEvent(name, attributes, timestamp))

def get_metrics(self) -> _MetricDictType:
"""Return all metrics."""
Expand Down
25 changes: 0 additions & 25 deletions ddtrace/_trace/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from typing import Dict
from typing import List
from typing import Optional
from typing import Set
from typing import Tuple
from typing import TypeVar
from typing import Union
Expand Down Expand Up @@ -224,12 +223,6 @@ def __init__(
# globally set tags
self._tags = config.tags.copy()

# collection of services seen, used for runtime metrics tags
# a buffer for service info so we don't perpetually send the same things
self._services: Set[str] = set()
if config.service:
self._services.add(config.service)

# Runtime id used for associating data collected during runtime to
# traces
self._pid = getpid()
Expand Down Expand Up @@ -380,11 +373,6 @@ def current_trace_context(self, *args, **kwargs) -> Optional[Context]:
return active.context
return None

def top_level_span_events_enabled(self) -> bool:
# assert correct writer type
assert isinstance(self._writer, AgentWriter)
return self._writer._agent_top_level_span_events_support

def get_log_correlation_context(self, active: Optional[Union[Context, Span]] = None) -> Dict[str, str]:
"""Retrieves the data used to correlate a log with the current active trace.
Generates a dictionary for custom logging instrumentation including the trace id and
Expand Down Expand Up @@ -640,13 +628,6 @@ def _generate_diagnostic_logs(self):

def _child_after_fork(self):
self._pid = getpid()

# Assume that the services of the child are not necessarily a subset of those
# of the parent.
self._services = set()
if config.service:
self._services.add(config.service)

# Re-create the background writer thread
self._writer = self._writer.recreate()
self._span_processors, self._appsec_processor, self._deferred_processors = _default_span_processors_factory(
Expand Down Expand Up @@ -772,7 +753,6 @@ def _start_span(
service = config.service_mapping.get(service, service)

links = context._span_links if not parent else []
span_event_support = self.top_level_span_events_enabled()
if trace_id or links or context._baggage:
# child_of a non-empty context, so either a local child span or from a remote context
span = Span(
Expand Down Expand Up @@ -808,7 +788,6 @@ def _start_span(
span_type=span_type,
span_api=span_api,
on_finish=[self._on_span_finish],
span_event_formatting=span_event_support,
)
if config._report_hostname:
span.set_tag_str(_HOSTNAME_KEY, hostname.get_hostname())
Expand Down Expand Up @@ -839,10 +818,6 @@ def _start_span(
if activate:
self.context_provider.activate(span)

# update set of services handled by tracer
if service and service not in self._services and self._is_span_internal(span):
self._services.add(service)

# Only call span processors if the tracer is enabled (even if APM opted out)
if self.enabled or asm_config._apm_opt_out:
for p in chain(self._span_processors, SpanProcessor.__processors__, self._deferred_processors):
Expand Down
1 change: 0 additions & 1 deletion ddtrace/contrib/internal/graphql/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ def _set_span_errors(errors: List[GraphQLError], span: Span) -> None:
if extensions:
for key in extensions:
attributes[f"extensions.{key}"] = extensions[key]
# breakpoint()
span._add_event(
name="dd.graphql.query.error",
attributes=attributes,
Expand Down
1 change: 1 addition & 0 deletions ddtrace/internal/_encoding.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ class MsgpackEncoderBase(BufferedEncoder):

class MsgpackEncoderV04(MsgpackEncoderBase): ...
class MsgpackEncoderV05(MsgpackEncoderBase): ...
class MsgpackEncoderV041(MsgpackEncoderBase): ...

def packb(o: Any, **kwargs) -> bytes: ...
Loading

0 comments on commit 297dda5

Please sign in to comment.