diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-17 06:09:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-17 06:09:21 +0000 |
commit | c8df22c555ab707a705e57c4257fd3ed1ce7c3b0 (patch) | |
tree | 009fb7c1ff12a6192921212cae404b790fd7d66b /doc/telemetry/backend.md | |
parent | 9345f69894862e02f3491ea3136c3ed2b23fd5b8 (diff) | |
download | gitlab-ce-c8df22c555ab707a705e57c4257fd3ed1ce7c3b0.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/telemetry/backend.md')
-rw-r--r-- | doc/telemetry/backend.md | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/doc/telemetry/backend.md b/doc/telemetry/backend.md new file mode 100644 index 00000000000..c571439af8a --- /dev/null +++ b/doc/telemetry/backend.md @@ -0,0 +1,34 @@ +# Backend tracking guide + +GitLab provides `Gitlab::Tracking`, an interface that wraps the [Snowplow Ruby Tracker](https://github.com/snowplow/snowplow/wiki/ruby-tracker) for tracking custom events. + +## Tracking in Ruby + +Custom event tracking and instrumentation can be added by directly calling the `GitLab::Tracking.event` class method, which accepts the following arguments: + +| argument | type | default value | description | +|:-----------|:-------|:---------------------------|:------------| +| `category` | string | 'application' | Area or aspect of the application. This could be `HealthCheckController` or `Lfs::FileTransformer` for instance. | +| `action` | string | 'generic' | The action being taken, which can be anything from a controller action like `create` to something like an Active Record callback. | +| `data` | object | {} | Additional data such as `label`, `property`, `value`, and `context` as described [in our Feature Instrumentation taxonomy](https://about.gitlab.com/handbook/product/feature-instrumentation/#taxonomy). These will be set as empty strings if you don't provide them. | + +Tracking can be viewed as either tracking user behavior, or can be utilized for instrumentation to monitor and visual performance over time in an area or aspect of code. + +For example: + +```ruby +class Projects::CreateService < BaseService + def execute + project = Project.create(params) + + Gitlab::Tracking.event('Projects::CreateService', 'create_project', + label: project.errors.full_messages.to_sentence, + value: project.valid? + ) + end +end +``` + +### Performance + +We use the [AsyncEmitter](https://github.com/snowplow/snowplow/wiki/Ruby-Tracker#52-the-asyncemitter-class) when tracking events, which allows for instrumentation calls to be run in a background thread. This is still an active area of development. |