Skip to content

Traceparent not forwarded via PubSub #355

@dkrizic

Description

@dkrizic

I don't know if this is a bug or feature request. I have two services "server" and "echo". Server sends send a message via pubsub to echo. Both services are fully instrumented with OpenTelemetry. A call to server give me the following trace

image

The last method SendNotifcation forwards the instrumented ctx to the DAPR client:

func (n *Sender) SendNotification(ctx context.Context, message []byte) error {
	ctx, span := otel.Tracer("sender").Start(ctx, "SendNotification")
	defer span.End()

	llog := log.WithFields(log.Fields{
		"pubsubName": n.PubSubName,
		"topicName":  n.TopicName,
		"message":    string(message),
	})
	llog.Debug("Sending sender")
	err := n.client.PublishEvent(ctx, n.PubSubName, n.TopicName, message)
	if err != nil {
		llog.WithError(err).Warn("Unable to send sender")
		return err
	}
	return nil
}

But the transported message has a new traceid:

{
    "data": "{\"Before\":{\"Id\":\"77\",\"Title\":\"Title\",\"Description\":\"The description\",\"Status\":\"\"},\"After\":{\"Id\":\"77\",\"Title\":\"Title\",\"Description\":\"The description\",\"Status\":\"\"},\"ChangeType\":\"CREATE\"}",
    "datacontenttype": "text/plain",
    "id": "b946b14e-1770-4316-8483-9eca55602318",
    "pubsubname": "todo-pubsub",
    "source": "todo",
    "specversion": "1.0",
    "time": "2023-01-29T11:22:03Z",
    "topic": "todo",
    "traceid": "00-f4905fb842564c59ca0905e18f408be7-24f05a94522b81d3-01",
    "traceparent": "00-f4905fb842564c59ca0905e18f408be7-24f05a94522b81d3-01",
    "tracestate": "",
    "type": "com.dapr.event.sent"
}

Receiving the trace works again:

image

But alltogether I have two traces:

image

Questions:

  • Is this feature missing?
  • Am I doing something wrong?
  • Does this make sense at all having a trace over asynchronous communication?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions