diff --git a/content/en/serverless/google_cloud_run/containers/in_container/nodejs.md b/content/en/serverless/google_cloud_run/containers/in_container/nodejs.md index b2533ae36b4..93618402ddc 100644 --- a/content/en/serverless/google_cloud_run/containers/in_container/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/in_container/nodejs.md @@ -83,6 +83,70 @@ logger.info('Hello world!'); {{% serverless-init-env-vars-in-container language="nodejs" defaultSource="cloudrun" %}} +## Distributed tracing with Pub/Sub + +To get end-to-end distributed traces between Pub/Sub producers and Cloud Run services, configure your push subscriptions with the `--push-no-wrapper` and `--push-no-wrapper-write-metadata` flags. This moves message attributes from the JSON body to HTTP headers, allowing Datadog to extract producer trace context and create proper span links. + +For more information, see [Producer-aware tracing for Google Cloud Pub/Sub and Cloud Run][4] and [Payload unwrapping][5] in the Google Cloud documentation. + +### Configure push subscriptions for full trace visibility + +**Create a new push subscription:** + +{{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions create order-processor-sub \ + --topic=orders \ + --push-endpoint=https://order-processor-xyz.run.app/pubsub \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + +**Update an existing push subscription:** + +{{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions update order-processor-sub \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + +### Configure Eventarc Pub/Sub triggers + +Eventarc Pub/Sub triggers use push subscriptions as the underlying delivery mechanism. When you create an Eventarc trigger, GCP automatically creates a managed push subscription. However, Eventarc does not expose `--push-no-wrapper-write-metadata` as a trigger creation parameter, so you must manually update the auto-created subscription. + +1. **Create the Eventarc trigger:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud eventarc triggers create order-processor-trigger \ + --destination-run-service=order-processor \ + --destination-run-region=us-central1 \ + --event-filters="type=google.cloud.pubsub.topic.v1.messagePublished" \ + --event-filters="topic=projects/my-project/topics/orders" \ + --location=us-central1 +{{< /code-block >}} + +2. **Find the auto-created subscription:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions list \ + --filter="topic:projects/my-project/topics/orders" \ + --format="table(name,pushConfig.pushEndpoint)" +{{< /code-block >}} + + Example output: + ``` + NAME PUSH_ENDPOINT + eventarc-us-central1-order-processor-trigger-abc-sub-def https://order-processor-xyz.run.app + ``` + +3. **Update the subscription for trace propagation:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions update \ + eventarc-us-central1-order-processor-trigger-abc-sub-def \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + ## Troubleshooting {{% serverless-init-troubleshooting productNames="Cloud Run services" %}} @@ -94,3 +158,5 @@ logger.info('Hello world!'); [1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/ [2]: /tracing/other_telemetry/connect_logs_and_traces/nodejs/ [3]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=nodejs#code-examples-5 +[4]: https://www.datadoghq.com/blog/pubsub-cloud-run-tracing/ +[5]: https://cloud.google.com/pubsub/docs/payload-unwrapping diff --git a/content/en/serverless/google_cloud_run/containers/sidecar/nodejs.md b/content/en/serverless/google_cloud_run/containers/sidecar/nodejs.md index 310fe4062ee..4a5995e8aac 100644 --- a/content/en/serverless/google_cloud_run/containers/sidecar/nodejs.md +++ b/content/en/serverless/google_cloud_run/containers/sidecar/nodejs.md @@ -100,6 +100,70 @@ logger.info('Hello world!'); {{% serverless-init-env-vars-sidecar language="nodejs" defaultSource="cloudrun" %}} +## Distributed tracing with Pub/Sub + +To get end-to-end distributed traces between Pub/Sub producers and Cloud Run services, configure your push subscriptions with the `--push-no-wrapper` and `--push-no-wrapper-write-metadata` flags. This moves message attributes from the JSON body to HTTP headers, allowing Datadog to extract producer trace context and create proper span links. + +For more information, see [Producer-aware tracing for Google Cloud Pub/Sub and Cloud Run][4] and [Payload unwrapping][5] in the Google Cloud documentation. + +### Configure push subscriptions for full trace visibility + +**Create a new push subscription:** + +{{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions create order-processor-sub \ + --topic=orders \ + --push-endpoint=https://order-processor-xyz.run.app/pubsub \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + +**Update an existing push subscription:** + +{{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions update order-processor-sub \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + +### Configure Eventarc Pub/Sub triggers + +Eventarc Pub/Sub triggers use push subscriptions as the underlying delivery mechanism. When you create an Eventarc trigger, GCP automatically creates a managed push subscription. However, Eventarc does not expose `--push-no-wrapper-write-metadata` as a trigger creation parameter, so you must manually update the auto-created subscription. + +1. **Create the Eventarc trigger:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud eventarc triggers create order-processor-trigger \ + --destination-run-service=order-processor \ + --destination-run-region=us-central1 \ + --event-filters="type=google.cloud.pubsub.topic.v1.messagePublished" \ + --event-filters="topic=projects/my-project/topics/orders" \ + --location=us-central1 +{{< /code-block >}} + +2. **Find the auto-created subscription:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions list \ + --filter="topic:projects/my-project/topics/orders" \ + --format="table(name,pushConfig.pushEndpoint)" +{{< /code-block >}} + + Example output: + ``` + NAME PUSH_ENDPOINT + eventarc-us-central1-order-processor-trigger-abc-sub-def https://order-processor-xyz.run.app + ``` + +3. **Update the subscription for trace propagation:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions update \ + eventarc-us-central1-order-processor-trigger-abc-sub-def \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + ## Troubleshooting {{% serverless-init-troubleshooting productNames="Cloud Run services" %}} @@ -111,3 +175,5 @@ logger.info('Hello world!'); [1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/ [2]: /tracing/other_telemetry/connect_logs_and_traces/nodejs/ [3]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=nodejs#code-examples-5 +[4]: https://www.datadoghq.com/blog/pubsub-cloud-run-tracing/ +[5]: https://cloud.google.com/pubsub/docs/payload-unwrapping diff --git a/content/en/serverless/google_cloud_run/functions/nodejs.md b/content/en/serverless/google_cloud_run/functions/nodejs.md index c1c9f74e6da..c4d4747ab75 100644 --- a/content/en/serverless/google_cloud_run/functions/nodejs.md +++ b/content/en/serverless/google_cloud_run/functions/nodejs.md @@ -89,6 +89,70 @@ logger.info('Hello world!'); {{% serverless-init-env-vars-sidecar language="nodejs" function="true" defaultSource="cloudrun" %}} +## Distributed tracing with Pub/Sub + +To get end-to-end distributed traces between Pub/Sub producers and Cloud Run functions, configure your push subscriptions with the `--push-no-wrapper` and `--push-no-wrapper-write-metadata` flags. This moves message attributes from the JSON body to HTTP headers, allowing Datadog to extract producer trace context and create proper span links. + +For more information, see [Producer-aware tracing for Google Cloud Pub/Sub and Cloud Run][4] and [Payload unwrapping][5] in the Google Cloud documentation. + +### Configure push subscriptions for full trace visibility + +**Create a new push subscription:** + +{{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions create order-processor-sub \ + --topic=orders \ + --push-endpoint=https://order-processor-xyz.run.app/pubsub \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + +**Update an existing push subscription:** + +{{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions update order-processor-sub \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + +### Configure Eventarc Pub/Sub triggers + +Eventarc Pub/Sub triggers use push subscriptions as the underlying delivery mechanism. When you create an Eventarc trigger, GCP automatically creates a managed push subscription. However, Eventarc does not expose `--push-no-wrapper-write-metadata` as a trigger creation parameter, so you must manually update the auto-created subscription. + +1. **Create the Eventarc trigger:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud eventarc triggers create order-processor-trigger \ + --destination-run-service=order-processor \ + --destination-run-region=us-central1 \ + --event-filters="type=google.cloud.pubsub.topic.v1.messagePublished" \ + --event-filters="topic=projects/my-project/topics/orders" \ + --location=us-central1 +{{< /code-block >}} + +2. **Find the auto-created subscription:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions list \ + --filter="topic:projects/my-project/topics/orders" \ + --format="table(name,pushConfig.pushEndpoint)" +{{< /code-block >}} + + Example output: + ``` + NAME PUSH_ENDPOINT + eventarc-us-central1-order-processor-trigger-abc-sub-def https://order-processor-xyz.run.app + ``` + +3. **Update the subscription for trace propagation:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions update \ + eventarc-us-central1-order-processor-trigger-abc-sub-def \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + ## Troubleshooting {{% serverless-init-troubleshooting productNames="Cloud Run services" %}} @@ -100,4 +164,6 @@ logger.info('Hello world!'); [1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/ [2]: /tracing/other_telemetry/connect_logs_and_traces/nodejs/ [3]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=nodejs#code-examples-5 +[4]: https://www.datadoghq.com/blog/pubsub-cloud-run-tracing/ +[5]: https://cloud.google.com/pubsub/docs/payload-unwrapping diff --git a/content/en/serverless/google_cloud_run/jobs/nodejs.md b/content/en/serverless/google_cloud_run/jobs/nodejs.md index e50a50a52a8..5404c7e91d3 100644 --- a/content/en/serverless/google_cloud_run/jobs/nodejs.md +++ b/content/en/serverless/google_cloud_run/jobs/nodejs.md @@ -90,6 +90,70 @@ logger.info('Hello world!'); {{% serverless-init-env-vars-in-container language="nodejs" defaultSource="cloudrun" %}} +## Distributed tracing with Pub/Sub + +To get end-to-end distributed traces between Pub/Sub producers and Cloud Run jobs, configure your push subscriptions with the `--push-no-wrapper` and `--push-no-wrapper-write-metadata` flags. This moves message attributes from the JSON body to HTTP headers, allowing Datadog to extract producer trace context and create proper span links. + +For more information, see [Producer-aware tracing for Google Cloud Pub/Sub and Cloud Run][5] and [Payload unwrapping][6] in the Google Cloud documentation. + +### Configure push subscriptions for full trace visibility + +**Create a new push subscription:** + +{{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions create order-processor-sub \ + --topic=orders \ + --push-endpoint=https://order-processor-xyz.run.app/pubsub \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + +**Update an existing push subscription:** + +{{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions update order-processor-sub \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + +### Configure Eventarc Pub/Sub triggers + +Eventarc Pub/Sub triggers use push subscriptions as the underlying delivery mechanism. When you create an Eventarc trigger, GCP automatically creates a managed push subscription. However, Eventarc does not expose `--push-no-wrapper-write-metadata` as a trigger creation parameter, so you must manually update the auto-created subscription. + +1. **Create the Eventarc trigger:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud eventarc triggers create order-processor-trigger \ + --destination-run-service=order-processor \ + --destination-run-region=us-central1 \ + --event-filters="type=google.cloud.pubsub.topic.v1.messagePublished" \ + --event-filters="topic=projects/my-project/topics/orders" \ + --location=us-central1 +{{< /code-block >}} + +2. **Find the auto-created subscription:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions list \ + --filter="topic:projects/my-project/topics/orders" \ + --format="table(name,pushConfig.pushEndpoint)" +{{< /code-block >}} + + Example output: + ``` + NAME PUSH_ENDPOINT + eventarc-us-central1-order-processor-trigger-abc-sub-def https://order-processor-xyz.run.app + ``` + +3. **Update the subscription for trace propagation:** + + {{< code-block lang="shell" disable_copy="false" >}} +gcloud pubsub subscriptions update \ + eventarc-us-central1-order-processor-trigger-abc-sub-def \ + --push-no-wrapper \ + --push-no-wrapper-write-metadata +{{< /code-block >}} + ## Troubleshooting {{% serverless-init-troubleshooting productNames="Cloud Run services" %}} @@ -102,3 +166,5 @@ logger.info('Hello world!'); [2]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/ [3]: /tracing/other_telemetry/connect_logs_and_traces/nodejs/ [4]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=nodejs#code-examples-5 +[5]: https://www.datadoghq.com/blog/pubsub-cloud-run-tracing/ +[6]: https://cloud.google.com/pubsub/docs/payload-unwrapping