Skip to content

Propagate trace inforation from incoming headers#7932

Merged
yaron2 merged 16 commits into
dapr:masterfrom
evhen14:trace-info-propagation
Oct 31, 2024
Merged

Propagate trace inforation from incoming headers#7932
yaron2 merged 16 commits into
dapr:masterfrom
evhen14:trace-info-propagation

Conversation

@evhen14

@evhen14 evhen14 commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

Description

The change allows Pub/Sub users to tap into tracing without requiring to publish CloudEvents on the subscription side.

The change assumes that traceparent and tracestate are the metadata fields used for this purpose. For backward compatibility, it also adds traceid field to the internally created cloud event.

Issue reference

#7918

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

2. Install [Delve](https://github.com/go-delve/delve/tree/master/Documentation/installation) for Go debugging, if desired.

3. Install [golangci-lint](https://golangci-lint.run/usage/install) version 1.55.2.
3. Install [golangci-lint](https://golangci-lint.run/welcome/install/) version 1.55.2.

@daixiang0 daixiang0 Jul 24, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems it is not relative to the main topic, please update it in other PR, one thing one PR is good enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

just to be clear, the old link is broken. I've removed this change, but please don't expect a separate PR from me.

return err
}
} else {
// all messages consumed with "rawPayload=false" are deserialized as a CloudEvent, even when the payload is not a CloudEvent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it documented?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What's the best place to document it? Here, I'm just stating what's happening. You can submit any payload without specifying rawPayload=true and it will treat it as a CloudEvent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is an implementation detail tbh. It doesn't mean that they will be sent as CloudEvent. it's just that they are being deserialized as cloud events regardless of whether they are rawPayload = true or false.

evhen14 added 2 commits July 24, 2024 14:04
Signed-off-by: Yevgen Polyak <[email protected]>
Signed-off-by: Yevgen Polyak <[email protected]>
@evhen14
evhen14 requested a review from daixiang0 July 24, 2024 03:52
@codecov

codecov Bot commented Jul 24, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 76.31579% with 9 lines in your changes missing coverage. Please review.

Project coverage is 54.45%. Comparing base (7ea7016) to head (e3bcbdf).

Files Patch % Lines
pkg/runtime/subscription/subscription.go 58.33% 3 Missing and 2 partials ⚠️
pkg/api/grpc/grpc.go 66.66% 2 Missing ⚠️
pkg/api/http/http.go 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7932      +/-   ##
==========================================
+ Coverage   54.39%   54.45%   +0.06%     
==========================================
  Files         507      507              
  Lines       27769    27790      +21     
==========================================
+ Hits        15104    15134      +30     
+ Misses      11461    11448      -13     
- Partials     1204     1208       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yaron2

yaron2 commented Oct 29, 2024

Copy link
Copy Markdown
Member

@evhen14 see the failing static checks

}
if _, ok := cloudEvent[contribpubsub.TraceParentField]; !ok {
if traceparent, ok := msg.Metadata[contribpubsub.TraceParentField]; ok {
cloudEvent[contribpubsub.TraceIDField] = traceparent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems to be different than the update logic above, where the TraceID populates both TraceID and TraceParent. In this block TraceParent is used for TraceID. Is this intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The traceparent override is based on this comment. I've made a change to make them consistent and adjusted the unit test

Signed-off-by: Yevgen Polyak <[email protected]>
Comment thread pkg/runtime/subscription/subscription.go
Signed-off-by: Yevgen Polyak <[email protected]>
@yaron2
yaron2 merged commit d697612 into dapr:master Oct 31, 2024
@evhen14
evhen14 deleted the trace-info-propagation branch October 31, 2024 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants