-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: distributed trace by otel and cloud run sidecar (#64)
* feat: set otel tracer * fix: lint * feat: update CD * chore: comment * feat: otel collector * feat: trace * feat: export trace
- Loading branch information
Showing
16 changed files
with
242 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM otel/opentelemetry-collector-contrib:0.94.0 | ||
COPY config.yaml /etc/otelcol-contrib/config.yaml | ||
EXPOSE 4317 | ||
CMD ["--config", "/etc/otelcol-contrib/config.yaml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# [START cloudrun_mc_custom_metrics_otel_config] | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
http: | ||
|
||
processors: | ||
batch: | ||
# batch metrics before sending to reduce API usage | ||
send_batch_max_size: 200 | ||
send_batch_size: 200 | ||
timeout: 5s | ||
|
||
memory_limiter: | ||
# drop metrics if memory usage gets too high | ||
check_interval: 1s | ||
limit_percentage: 65 | ||
spike_limit_percentage: 20 | ||
|
||
# automatically detect Cloud Run resource metadata | ||
resourcedetection: | ||
detectors: [env, gcp] | ||
timeout: 2s | ||
override: false | ||
|
||
resource: | ||
attributes: | ||
# add instance_id as a resource attribute | ||
- key: service.instance.id | ||
from_attribute: faas.id | ||
action: upsert | ||
# parse service name from K_SERVICE Cloud Run variable | ||
- key: service.name | ||
value: ${env:K_SERVICE} | ||
action: insert | ||
|
||
exporters: | ||
googlemanagedprometheus: # Note: this is intentionally left blank | ||
googlecloud: | ||
# otlphttp/openobserve: | ||
# endpoint: https://api.openobserve.ai/api/kiyong_organization_2077_A0vz8lYUhIFWpjS/ | ||
# headers: | ||
# Authorization: TODO: | ||
# stream-name: default | ||
|
||
extensions: | ||
health_check: | ||
|
||
service: | ||
extensions: [health_check] | ||
pipelines: | ||
metrics: | ||
receivers: [otlp] | ||
processors: [batch, memory_limiter, resourcedetection, resource] | ||
exporters: [googlemanagedprometheus, googlecloud] | ||
traces: | ||
receivers: [otlp] | ||
processors: [batch] | ||
exporters: [googlecloud] | ||
# [END cloudrun_mc_custom_metrics_otel_config] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# OpenTelemetry | ||
|
||
## References | ||
|
||
- <https://zenn.dev/google_cloud_jp/articles/20230516-cloud-run-otel> | ||
- <https://github.com/GoogleCloudPlatform/devrel-demos/tree/main/devops/otel-col-cloud-run-multicontainer> | ||
- <https://cloud.google.com/run/docs/tutorials/custom-metrics-opentelemetry-sidecar?hl=ja> | ||
- <https://opentelemetry.io/docs/collector/configuration/> | ||
|
||
## build sidecar container | ||
|
||
- ref:<https://cloud.google.com/run/docs/deploying?hl=ja#multicontainer-yaml> | ||
|
||
```bash | ||
docker buildx build .otelcollector/ --platform linux/amd64 --no-cache --tag asia-northeast1-docker.pkg.dev/kyong0612-lab/fitness-supporter/sidecar/otel:latest | ||
docker push asia-northeast1-docker.pkg.dev/kyong0612-lab/fitness-supporter/sidecar/otel:latest | ||
# docker image rm asia-northeast1-docker.pkg.dev/kyong0612-lab/fitness-supporter/sidecar/otel:latest | ||
``` | ||
|
||
## replace config | ||
|
||
- cloud runのyaml fileを編集する | ||
<https://share.cleanshot.com/ncrCNj1T> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.