Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}}
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}}
Expand All @@ -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
66 changes: 66 additions & 0 deletions content/en/serverless/google_cloud_run/functions/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}}
Expand All @@ -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

66 changes: 66 additions & 0 deletions content/en/serverless/google_cloud_run/jobs/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}}
Expand All @@ -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
Loading