dapr icon indicating copy to clipboard operation
dapr copied to clipboard

Dapr replaces existing CloudEvent trace with autogenerated trace

Open daniele-arosio opened this issue 1 year ago • 5 comments

Expected Behavior

I expect that it's possible to specify the desired traceid and traceparent values, using the pulish_event method with data_content_type="application/cloudevents+json".

Actual Behavior

Some Dapr CloudEvent fields can be specify (ex. source and type) as expected from documentation. But other fields are ignored (ex. traceid, traceparent).

Steps to Reproduce the Problem

dapr version: dapr==1.12.1

The following code:

MY_DATA = {
    "source":"MY_SOURCE",
    "type":"MY_TYPE",
    "data": {
        "x": 1,
        "y": 2
    },
    "traceid":"00-20fb8e95782a3548a903dd43c83396b4-c39ddb6ef445b8e3-01",
    "traceparent":"00-20fb8e95782a3548a903dd43c83396b4-c39ddb6ef445b8e3-01",
    }

dapr_client.publish_event(
    pubsub_name=MY_PUBSUB_NAME,
    topic_name=MY_TOPIC_NAME,
    data=json.dumps(MY_DATA),
    data_content_type="application/cloudevents+json",
)

produces this message:

{
    "data": {
        "x": 1,
        "y": 2
    },
    "pubsubname": "kafka-pubsub",
    "source": "MY_SOURCE",
    "specversion": "1.0",
    "time": "2024-01-23T14:04:23Z",
    "topic": "test",
    "traceid": "00-d258f97bef8a57285dd19490337d4b35-a179d57fa4846794-01",
    "traceparent": "00-d258f97bef8a57285dd19490337d4b35-a179d57fa4846794-01",
    "tracestate": "",
    "type": "MY_TYPE"
}

instead of the desired traceid and traceparent value (00-20fb8e95782a3548a903dd43c83396b4-c39ddb6ef445b8e3-01).

daniele-arosio avatar Jan 23 '24 14:01 daniele-arosio

Moving this to Dapr Runtime because this is not Python specific. It occurs at the runtime level.

berndverst avatar Feb 13 '24 03:02 berndverst

When tracing information is not attached to the gRPC request itself and only resides in the raw cloud event Dapr generates a new trace and replaces this in the cloud event.

Dapr should not override these values if they are already set.

berndverst avatar Feb 13 '24 03:02 berndverst

@berndverst In the Python SDK then, how can a user pass the traceid and traceparent?

yaron2 avatar Feb 13 '24 04:02 yaron2

Interested to see if there are any pointers here. I am interested in this from a .NET perspective too. I have no means of setting the traceparent when publishing an event but would like to be able to do so. I am trying to get distributed tracing working in Kibana but it doesn't work because Kibana is using the {SpanID} portion of the trace to build the complete picture.

It would be nice if Dapr acknowledging any traceparent or traceId metadata fields when publishing through the Dapr client and only if nothing is provided for those values, derive it's own.

KrylixZA avatar Apr 12 '24 15:04 KrylixZA

This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

dapr-bot avatar Jun 28 '24 13:06 dapr-bot

This issue has been automatically closed because it has not had activity in the last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.

dapr-bot avatar Jul 05 '24 13:07 dapr-bot

Should this be reopened?

cicoyle avatar Jul 25 '24 22:07 cicoyle