Skip to content

Commit

Permalink
Update the README
Browse files Browse the repository at this point in the history
  • Loading branch information
psx95 committed Oct 2, 2024
1 parent bd74452 commit f27f836
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions examples/otlpmetrics-function/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to Google Managed Prometheus using OpenTelemetry Collector running as a sidecar.

Additional details on deploying functions on Cloud Run can be viewed [here](https://cloud.google.com/run/docs/deploy-functions).

##### Important Note
This example leverages the use of `always-allocated CPU` for Cloud Run Services, which may have different pricing implication compared to the default `CPU only allocated during request` option.
Please see the [pricing table](https://cloud.google.com/run/pricing#tables) for differences and additional details.

### Prerequisites

##### Get Google Cloud Credentials on your machine
Expand Down Expand Up @@ -38,8 +42,8 @@ Follow these steps:
2. Build & push the docker image with the collector:
```shell
# From the root of the repository
cd examples/otlpmetrics-functions/collector-deployment
docker build . -t otel-collector
cd examples/otlpmetrics-function/collector-deployment
docker build . -t us-central1-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/otlp-cloud-run/otel-collector
docker push us-central1-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/otlp-cloud-run/otel-collector
```

Expand All @@ -56,7 +60,7 @@ gradle clean build shadowJar
This command should generate a JAR named `hello-world-function.jar` in `out/deployment` directory.

#### Deploy the function
You can either use `gcloud` or a `terrafrom` script to deploy the function along with the docker container:
This example shows how to use the `gcloud` CLI to deploy the function along with the docker container:

##### Using gcloud command

Expand All @@ -72,4 +76,16 @@ gcloud beta run deploy cloud-func-helloworld \
--image=us-central1-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/otlp-cloud-run/otel-collector:latest
```

After your Cloud Run Function has finished deploying, depending on your authentication setup, you can create a proxy to the deployed function on your localhost to facilitate testing:

```shell
# This will allow you to invoke your deployed function from http://localhost:8080
gcloud beta run services proxy cloud-func-helloworld --port=8080
```

### Viewing exported metrics

This example is configured to export metrics via `debug` and `googlemanagedprometheus` exporters in the OpenTelemetry Collector.

- The output of the debug exporter can be viewed on std out or the logs in Google Cloud Run Function logs, but it is mostly used for debugging any issues with your export.
- The exported metrics from `googlemanagedprometheus` can be viewed in [metrics explorer](https://cloud.google.com/monitoring/charts/metrics-selector). You can search for the metric named `function_counter_gmp` and it should be listed under the resource `Prometheus Target`.

0 comments on commit f27f836

Please sign in to comment.