Skip to content

GitLab instrumentation for OpenTelemetry

Enable OpenTelemetry tracing, metrics, and logs in GDK development

NOTE: Currently the default GDK environment is not set up by default to properly collect and display OpenTelemetry data. Therefore, you should point the OTEL_EXPORTER_*_ENDPOINT ENV vars to a GitLab project:

  1. Which has an Ultimate license, and where you have
  2. In which you have at least the Maintainer role
  3. In which you have access to enable top-level root-group feature flags (or is under the gitlab-org or gitlab-com root groups which already have the flags enabled)

Once you have a project identified to use:

  1. Note the ID of the project (from the three dots at upper right of main project page).

  2. Note the ID of the top-level root group which contains the project.

  3. When setting the environment variables for the following steps, add them to env.runit in the root of the gitlab-development-kit folder.

  4. Follow instructions to configure distributed tracing for a project, with the following custom settings:

    • For the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT environment variable, use the following value:

      export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://<gitlab-host>/v3/<gitlab-top-level-group-id>/<gitlab-project-id>/ingest/traces"
  5. Follow instructions to configure distributed metrics for a project, with the following custom settings:

    • For the OTEL_EXPORTER_OTLP_METRICS_ENDPOINT environment variable, use the following value:

      export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT="https://<gitlab-host>/v3/<gitlab-top-level-group-id>/<gitlab-project-id>/ingest/metrics"
  6. Follow instructions to configure distributed logs for a project, with the following custom settings:

    • For the OTEL_EXPORTER_OTLP_LOGS_ENDPOINT environment variable, use the following value:

      export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="https://<gitlab-host>/v3/<gitlab-top-level-group-id>/<gitlab-project-id>/ingest/logs"
  7. Also add the following to the env.runit file:

    # GitLab-specific flag to enable the Rails initializer to set up OpenTelemetry exporters
    export GITLAB_ENABLE_OTEL_EXPORTERS=true
  8. gdk restart.

  9. Navigate to your project, and follow the instructions in the above docs to enable and view the tracing, metrics, or logs.

References

Related blueprints