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

[DOCS] for sample: https://github.com/firebase/functions-samples/tree/main/2nd-gen/instrument-with-opentelemetry #1021

Open
dan-wu-open opened this issue Oct 20, 2022 · 7 comments
Assignees

Comments

@dan-wu-open
Copy link

Which sample?

https://github.com/firebase/functions-samples/tree/main/2nd-gen/instrument-with-opentelemetry

What is the issue with this sample's docs?

The docs mention a ./.env file but I don't see it. Would appreciate it to see how it's set up! Would love to add telemetry to all of our cloud functions

@adamnathanlewis
Copy link

Yeah been trying to set this up using NODE_OPTIONS but can't get it working. @taeold Really excited about this but would love your input! 🙏

@adamnathanlewis
Copy link

adamnathanlewis commented Oct 21, 2022

By the way @dan-wu-open I think you might be able to get what you're looking for by setting an environment variable called NODE_OPTIONS to --require "./tracing.js". You can set this with an env file or as part of your CI/CD or manually on the function within the google cloud console. That said, it isn't working for me! Worth giving it a try though

https://console.cloud.google.com/functions/list
Select your function
Edit
Expand Runtime, build, connections and security settings

image

Give it a try 😄

@kaczors
Copy link

kaczors commented Oct 21, 2022

I am struggling with setting this up in TypeScript, somehow my custom spans are not visible.
One general remark useful while testing: by default Cloud Run will trace 0.1 request per second per container (https://cloud.google.com/run/docs/trace#trace_sampling_rate). When I was invoking my callable from Angular app the OPTIONS preflight request was draining this quota and real request were not traced (there is nice property in logs traceSampled: true saying if given request was sampled or not)

@taeold
Copy link
Collaborator

taeold commented Oct 25, 2022

Whoops my mistake. Thanks for calling it out @dan-wu-open and @adamaffinitech. Fix incoming at #1022

@taeold
Copy link
Collaborator

taeold commented Oct 25, 2022

@kaczors Thanks for sharing your problem.

It's a real bummer that we don't get to configure the Cloud Run sampling rate :(.

I believe Open Telemetry allows you to configure a sampler that can override the 0.1 sampling rate of Cloud Run. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#built-in-samplers.

Unfortunately, this would mean that you won't have the overarching request span generated by the Cloud Run's load balancer, but you'd at least be getting spans generated by your application.

I will take a closer look and see if I can write some sample code this weekend. If you are willing to share your work, I think the community will appreciate it!

@georgecartridge
Copy link

@kaczors Thanks for sharing your problem.

It's a real bummer that we don't get to configure the Cloud Run sampling rate :(.

I believe Open Telemetry allows you to configure a sampler that can override the 0.1 sampling rate of Cloud Run. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#built-in-samplers.

Unfortunately, this would mean that you won't have the overarching request span generated by the Cloud Run's load balancer, but you'd at least be getting spans generated by your application.

I will take a closer look and see if I can write some sample code this weekend. If you are willing to share your work, I think the community will appreciate it!

Do you happen to have any working code around this?

I'm using v2 callable functions but only the OPTIONS pre-flight CORS request is getting its trace sampled. The actual onCall function invocation gets a traceId and spanId, but I think due to the sampling rate of Cloud Run, it's not then getting sampled and showing up in the trace explorer.

@kaczors
Copy link

kaczors commented Jan 25, 2024

@kaczors Thanks for sharing your problem.
It's a real bummer that we don't get to configure the Cloud Run sampling rate :(.
I believe Open Telemetry allows you to configure a sampler that can override the 0.1 sampling rate of Cloud Run. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#built-in-samplers.
Unfortunately, this would mean that you won't have the overarching request span generated by the Cloud Run's load balancer, but you'd at least be getting spans generated by your application.
I will take a closer look and see if I can write some sample code this weekend. If you are willing to share your work, I think the community will appreciate it!

Do you happen to have any working code around this?

I'm using v2 callable functions but only the OPTIONS pre-flight CORS request is getting its trace sampled. The actual onCall function invocation gets a traceId and spanId, but I think due to the sampling rate of Cloud Run, it's not then getting sampled and showing up in the trace explorer.

sorry, I did not found any workaround and not using this solution anymore

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

No branches or pull requests

5 participants