Skip to content

Commit f78661b

Browse files
authored
fix(otel): Configure collector and set credential permissions (#35)
This change introduces two main fixes for the OpenTelemetry collector setup: 1. **Collector Configuration:** The `docker run` command for the collector now includes the `--config` flag to properly load the generated GCP configuration. The `debug` exporter has been removed from the service pipelines, leaving only the `googlecloud` exporter for a cleaner and more focused setup. 2. **Credential Permissions:** The script now sets read-only permissions (`444`) on the `GOOGLE_APPLICATION_CREDENTIALS` file. This ensures the Docker container can access the credentials while adhering to the principle of least privilege.
1 parent 8e7818b commit f78661b

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ runs:
6767
mkdir -p .gemini/
6868
sed "s/OTLP_GOOGLE_CLOUD_PROJECT/${OTLP_GOOGLE_CLOUD_PROJECT}/g" "${GITHUB_ACTION_PATH}/scripts/collector-gcp.yaml.template" > ".gemini/collector-gcp.yaml"
6969
70+
chmod 444 "$GOOGLE_APPLICATION_CREDENTIALS"
7071
docker run -d --name gemini-telemetry-collector --network host \
7172
-v "${GITHUB_WORKSPACE}:/github/workspace" \
7273
-e "GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS/$GITHUB_WORKSPACE//github/workspace}" \
7374
-w "/github/workspace" \
74-
otel/opentelemetry-collector-contrib:0.128.0
75+
otel/opentelemetry-collector-contrib:0.128.0 \
76+
--config /github/workspace/.gemini/collector-gcp.yaml
7577
7678
- name: 'Install Gemini CLI'
7779
id: 'install'

docs/observability.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ The action uses its own built-in telemetry system that ensures consistent and re
1111
- [Advanced Setup](#advanced-setup)
1212
- [GitHub Actions Configuration](#github-actions-configuration)
1313
- [Viewing Telemetry Data](#viewing-telemetry-data)
14+
- [Collector Configuration](#collector-configuration)
1415
- [Troubleshooting](#troubleshooting)
1516

1617

1718
## Required Environment Variables
1819

19-
For a complete list of required environment variables, their descriptions, and how to configure them, see [Configuration](./configuration.md#environment-variables).
20+
For a complete list of required environment variables, their descriptions, and how to configure them, see [docs](../README.md#environment-variables).
2021

2122
When enabled, the action will automatically start an OpenTelemetry collector that forwards traces, metrics, and logs to your specified GCP project. You can then use Google Cloud's operations suite (formerly Stackdriver) to visualize and analyze this data.
2223

@@ -80,6 +81,14 @@ Once configured, you can view your telemetry data in the Google Cloud Console:
8081
- **Metrics**: [Cloud Monitoring Console](https://console.cloud.google.com/monitoring)
8182
- **Logs**: [Cloud Logging Console](https://console.cloud.google.com/logs)
8283

84+
## Collector Configuration
85+
86+
The action automatically handles the setup of the OpenTelemetry (OTel) collector.
87+
This includes generating the necessary Google Cloud configuration, setting the correct
88+
file permissions for credentials, and running the collector in a Docker container. The
89+
collector is configured to use only the `googlecloud` exporter, ensuring telemetry
90+
is sent directly to your Google Cloud project.
91+
8392
## Troubleshooting
8493

8594
If you encounter issues with observability setup, see the troubleshooting section in the [Workload Identity Federation documentation](./workload-identity.md#troubleshooting).

scripts/collector-gcp.yaml.template

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ exporters:
1313
prefix: 'custom.googleapis.com/gemini_cli'
1414
log:
1515
default_log_name: 'gemini_cli'
16-
debug:
17-
verbosity: 'detailed'
18-
sampling_initial: '2'
19-
sampling_thereafter: '500'
2016
service:
2117
telemetry:
2218
logs:
@@ -27,12 +23,12 @@ service:
2723
traces:
2824
receivers: ['otlp']
2925
processors: ['batch']
30-
exporters: ['googlecloud', 'debug']
26+
exporters: ['googlecloud']
3127
metrics:
3228
receivers: ['otlp']
3329
processors: ['batch']
34-
exporters: ['googlecloud', 'debug']
30+
exporters: ['googlecloud']
3531
logs:
3632
receivers: ['otlp']
3733
processors: ['batch']
38-
exporters: ['googlecloud', 'debug']
34+
exporters: ['googlecloud']

0 commit comments

Comments
 (0)