Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable traceparent header for cloudevents #336

Merged
merged 8 commits into from Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/function_wrappers.ts
Expand Up @@ -66,6 +66,11 @@ const parseCloudEventRequest = (req: Request): CloudEventsContext => {
cloudevent = getBinaryCloudEventContext(req);
cloudevent.data = req.body;
}
// Populate the traceparent header.
// @see https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md
if (req.header('traceparent')) {
cloudevent.traceparent = req.header('traceparent');
grant marked this conversation as resolved.
Show resolved Hide resolved
}
return cloudevent;
};

Expand Down
11 changes: 11 additions & 0 deletions test/integration/cloudevent.ts
Expand Up @@ -52,6 +52,17 @@ describe('CloudEvent Function', () => {
body: TEST_CLOUD_EVENT,
expectedCloudEvent: TEST_CLOUD_EVENT,
},
{
name: 'CloudEvents v1.0 structured content request',
headers: {
traceparent: '00-65088630f09e0a5359677a7429456db7-97f23477fb2bf5ec-01',
},
body: TEST_CLOUD_EVENT,
expectedCloudEvent: {
...TEST_CLOUD_EVENT,
traceparent: '00-65088630f09e0a5359677a7429456db7-97f23477fb2bf5ec-01',
},
},
{
name: 'CloudEvents v1.0 binary content request',
headers: {
Expand Down