doc/development/observability/_index.md
There are several options for developing and debugging GitLab Observability:
devvm. This is more involved but includes a development deployment of the GitLab Observability Backend. This is recommended for those who want to make changes to the GitLab Observability Backend component.This method takes advantage of our Cloud Connected Observability Backend. Your GitLab instance will require a valid Cloud License and will be treated as a GitLab Self-Managed instance, connected to a multi-tenant GitLab-hosted instance of the GitLab Observability Backend. See this design document for more details on how this works.
How to enable:
Add a GitLab Ultimate Self-Managed subscription to your GDK instance.
After this step is complete, you will have an activation code for a GitLab Ultimate Self-Managed subscription.
Set environment variables to point customers-dot to staging, and the Observability URL to staging. For GDK, this can be done in <gdk-root>/env.runit:
export GITLAB_SIMULATE_SAAS=0
export GITLAB_LICENSE_MODE=test
export CUSTOMER_PORTAL_URL=https://customers.staging.gitlab.com
export OVERRIDE_OBSERVABILITY_QUERY_URL=https://observe.staging.gitlab.com
export OVERRIDE_OBSERVABILITY_INGEST_URL=https://observe.staging.gitlab.com
On a non-GDK/GCK instance, you can set the variables using gitlab_rails['env'] in the gitlab.rb file:
gitlab_rails['env'] = {
'GITLAB_LICENSE_MODE' => 'test',
'CUSTOMER_PORTAL_URL' => 'https://customers.staging.gitlab.com',
'OVERRIDE_OBSERVABILITY_QUERY_URL' => 'https://observe.staging.gitlab.com',
'OVERRIDE_OBSERVABILITY_INGEST_URL' => 'https://observe.staging.gitlab.com'
}
Enable the feature flag for GitLab Observability features:
gdk rails consolemake consoleFeature.enable(:observability_features);Restart your instance (for example, gdk restart).
Follow the instructions to activate your new license.
Test out the GitLab Observability feature by navigating to a project and selecting Tracing, Metrics, or Logs from the Monitor section of the navigation menu.
If you are seeing 404 errors you might need to manually refresh your license data.
devvmVisit devvm and follow the README instructions for setup and developing against it.
The OpenTelemetry Demo app is a great way to run several Docker containers (representing a distributed system), and to send the logs, metrics, and traces to your local GDK instance.
You can reference the instructions for running the demo app.
Clone the Demo repository:
git clone https://github.com/open-telemetry/opentelemetry-demo.git
Change to the demo folder:
cd opentelemetry-demo/
Create a project in your local GDK instance. Take note of the project ID.
In the newly created project, create a project access token with Developer role and API scope. Save the token for use in the next step.
With an editor, edit the configuration in src/otelcollector/otelcol-config-extras.yml. Add the following YAML, replacing:
$GDK_HOST with the host and $GDK_PORT with the port number of your GitLab instance.$PROJECT_ID with the project ID and $TOKEN with the token created in the previous steps.exporters:
otlphttp/gitlab:
endpoint: http://$GDK_HOST:$GDK_PORT/api/v4/projects/$PROJECT_ID/observability/
headers:
"private-token": "$TOKEN"
service:
pipelines:
traces:
exporters: [spanmetrics, otlphttp/gitlab]
metrics:
exporters: [otlphttp/gitlab]
logs:
exporters: [otlphttp/gitlab]
[!note] For GDK and Docker to communicate you may need to set up a loopback interface.
Save the configuration and start the demo app:
docker compose up --force-recreate --remove-orphans --detach
Verify Telemetry by exploring logs, metrics, and traces under the Monitor menu in your GitLab project.
Apply the following patch to override Observability API calls with local mocks:
git apply < <(curl --silent "https://gitlab.com/gitlab-org/opstrace/opstrace/-/snippets/3747939/raw/main/mock.patch")