Add a button to the project page that instruments OpenTelemetry
Technical Documentation
Duo OTel Workflow - Technical Overview
Purpose
The Duo OTel feature provides a one-click solution for adding OpenTelemetry instrumentation to a project. It leverages Duo Workflows to automatically:
- Analyze the project's primary programming language
- Create an issue with language-appropriate OTel setup instructions
- Start an AI-powered workflow to implement the changes
Access Control Flow
flowchart TD
A[User clicks button] --> B{Empty repo?}
B -->|Yes| X[Hidden]
B -->|No| C{Has repository_languages?}
C -->|No| X
C -->|Yes| D{Can push_code?}
D -->|No| X
D -->|Yes| E{duo_add_otel enabled?}
E -->|No| X
E -->|Yes| F{duo_remote_flows_enabled?}
F -->|No| X
F -->|Yes| G[Button visible]
G --> H[User clicks]
H --> I{can create_issue?}
I -->|No| Y[403 Error]
I -->|Yes| J{can create_duo_workflow_for_ci?}
J -->|No| Z[Error: Duo workflows not available]
J -->|Yes| K[Proceed with workflow]
Language Template Selection
flowchart LR
A[project.repository_languages.first] --> B{Language?}
B -->|Ruby| C[RUBY_TEMPLATE<br/>• opentelemetry-sdk gem<br/>• config/initializers/opentelemetry.rb]
B -->|JavaScript<br/>TypeScript| D[JAVASCRIPT_TEMPLATE<br/>• @opentelemetry/sdk-node<br/>• tracing.js with --require]
B -->|Python| E[PYTHON_TEMPLATE<br/>• opentelemetry-sdk pip<br/>• otel_config.py]
B -->|Other| F[DEFAULT_TEMPLATE<br/>• Generic instructions]
Service Execution Flow
flowchart TD
subgraph CreateWorkflowService.execute
A[Start] --> B{can_create_issue?}
B -->|No| ERR1[Error: User cannot create issues]
B -->|Yes| C{duo_workflow_available?}
C -->|No| ERR2[Error: Duo workflows not available]
C -->|Yes| D[create_issue]
D --> E{Issue created?}
E -->|No| ERR3[Return issue errors]
E -->|Yes| F[create_and_start_workflow]
F --> G[CreateWorkflowService]
G --> H{Created?}
H -->|No| ERR4[Return error]
H -->|Yes| I[build_start_params]
I --> J[generate_oauth_token]
J --> K[generate_workflow_token]
K --> L[StartWorkflowService]
L --> M{Started?}
M -->|No| ERR5[Return error]
M -->|Yes| SUCCESS[Return issue + workflow + workload_id]
end
API Reference
Endpoint: POST /:namespace/:project/-/duo_otel_workflows
Authorization:
- User must pass show_duo_otel_button? check
- Feature flag duo_add_otel must be enabled
Success Response (201):
{
issue: {
iid: 42,
web_url: https://gitlab.com/group/project/-/issues/42
},
workflow: {
id: 123
},
workload_id: abc-123-def
}
Error Response (422):
{
error: User cannot create issues
}
Workflow Configuration
| Setting | Value |
|---|---|
| Workflow Definition | developer/v1 |
| Agent Privileges | READ_WRITE_FILES, READ_ONLY_GITLAB, READ_WRITE_GITLAB, USE_GIT |
| Environment | web |
| Source Branch | Project default branch |