Skip to content

paper2/instruments-cloud-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenTelemetry Go Cloud Functions Example

This is an example of OpenTelemetry Go Google Cloud Functions triggerd by HTTP.

Prerequisites

  • Create a project on Google Cloud Platform
  • Install
    • gcloud
    • docker

Deploy

Deploy OpenTelemetry Collector

cd collector
# Set your project id
vi deploy.sh 
./deploy.sh
cd ..

Save URL of the deployed OpenTelemetry collector.

Deploy Cloud Functions

cd greeting
# Set your project id and OpenTelemetry collector URL
vi env-greeting-1.yaml
vi env-greeting-2.yaml
# Set your project id
vi deploy.sh
./deploy.sh

Check Trace

  • curl to greeting-1

For example,

curl https://asia-northeast1-instruments-cloud-function.cloudfunctions.net/greeting-1

Alt text

Local Development

termianl1 - start jager all-in-one

docker compose up

termianl2 - start cloud function (greeting-1)

cd greeting
export OTEL_SERVICE_NAME=greeting-1
export PORT=8080
export NEXT_ENDPOINT=http://localhost:8081
FUNCTION_TARGET=Greeting LOCAL_ONLY=true go run cmd/main.go

termianl3 - start cloud function (greeting-2)

cd greeting
export OTEL_SERVICE_NAME=greeting-2
export PORT=8081
FUNCTION_TARGET=Greeting LOCAL_ONLY=true go run cmd/main.go

termianl4 - curl to greeting-1

curl http://localhost:8080

output is

Hiya!

check trace by jaeger UI

Alt text

About

OpenTelemetry Go Cloud Functions Example

Resources

License

Stars

Watchers

Forks