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

Assign HTTP header traceparent as cloudevent.traceparent #47

Closed
grant opened this issue Mar 12, 2021 · 0 comments · Fixed by #48
Closed

Assign HTTP header traceparent as cloudevent.traceparent #47

grant opened this issue Mar 12, 2021 · 0 comments · Fixed by #48

Comments

@grant
Copy link
Contributor

grant commented Mar 12, 2021

More narrow definition of #34, the Functions Framework contract should have a specific section around exposing the trace ID of an event-driven function to the user.

Specifically, we can expose:

Header

  • traceparent

User Function parameter

  • cloudevent.traceparent

See CloudEvent extension for more details: https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md


The older x-cloud-trace-context does not need to be propagated. This is an older value that is replaced by the standard W3C trace context header.

See: https://cloud.google.com/endpoints/docs/openapi/tracing#supported_headers

@grant grant changed the title Assign HTTP header X-Cloud-Trace-Context as cloudevent.traceparent Assign HTTP header traceparent as cloudevent.traceparent Mar 12, 2021
@grant grant closed this as completed in #48 Mar 16, 2021
taeold added a commit to firebase/firebase-functions that referenced this issue Sep 1, 2022
All traffic to Cloud Run revisions are populated with `traceparent` and `X-Cloud-Trace-Context` header [doc](https://cloud.google.com/run/docs/trace) and Functions Framework helpfully processes and injects the traceparent on cloudevent payload (See GoogleCloudPlatform/functions-framework#47).

We take advantage of this and automatically inject `trace` property to all logs generated from `functions.logger`. All logs emitted from functions logger then are correlated with requests - and it even works when concurrency > 1.

Traced logs are awesome with Cloud Logging:

![image](https://user-images.githubusercontent.com/14897098/186011800-d089db16-a5d6-4fc7-b0ba-bbfaedfebff9.png)

And looks great in Cloud Trace too!

![image](https://user-images.githubusercontent.com/14897098/186011639-b415d8af-03c0-49b9-bcc3-02d4e2ea82ad.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant