Skip to content
Draft
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
21 changes: 10 additions & 11 deletions ddtrace/contrib/internal/dramatiq/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from ddtrace.contrib import trace_utils
from ddtrace.ext import SpanKind
from ddtrace.ext import SpanTypes
from ddtrace.internal import core
from ddtrace.settings._config import Config
from ddtrace.trace import tracer


def get_version() -> str:
Expand Down Expand Up @@ -58,19 +58,18 @@ def _traced_send_with_options_function(integration_config: Config) -> Callable[[
def _traced_send_with_options(
func: Callable[[Any], Any], instance: dramatiq.Actor, args: Tuple[Any], kwargs: Dict[Any, Any]
) -> Callable[[Any], Any]:
with tracer.trace(
with core.context_with_data(
"dramatiq.Actor.send_with_options",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to register this event. All context_with_data does is create an executioncontext object. Caling the executioncontext in the with block then dispatches a context.started.dramatiq.Actor.send_with_options. event which is not registered.

Instead of registering a new event for dramatic can we reuse an existing one. Maybe rename rq.queue.enqueue_job to task.produce and use this event identifier in both rq and dramatic.

span_name="dramatiq.Actor.send_with_option",
span_type=SpanTypes.WORKER,
service=trace_utils.ext_service(pin=None, int_config=integration_config),
) as span:
span.set_tags(
{
SPAN_KIND: SpanKind.PRODUCER,
"actor.name": instance.actor_name,
"actor.options": instance.options,
}
)

tags={
SPAN_KIND: SpanKind.PRODUCER,
"actor.name": instance.actor_name,
"actor.options": instance.options,
},
) as ctx, ctx.span:
print("the ctx.span is ------> ", ctx.span)
return func(*args, **kwargs)

return _traced_send_with_options
Loading