-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revise metrics emission to reflect data for both GitLab and Bitbucket
The display of metrics in pipelines as code now includes information for GitLab and Bitbucket. Signed-off-by: Savita Ashture <[email protected]>
- Loading branch information
1 parent
b89347a
commit aeaf2cf
Showing
4 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: Running the PipelineRun | ||
weight: 4 | ||
--- | ||
|
||
# Metrics Overview | ||
|
||
The metrics for pipelines-as-code can be accessed through the `pipelines-as-code-watcher` service on port `9090`. | ||
|
||
pipelines-as-code supports various exporters, such as Prometheus, Google Stackdriver, and more. | ||
You can configure these exporters by referring to the [observability configuration](../config/config-observability.yaml). | ||
|
||
| Name | Type | Description | | ||
| ---------- |---------|-----------------------------------------------------| | ||
| `pipelines_as_code_pipelinerun_count` | Counter | Number of pipelineruns created by pipelines-as-code | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package reconciler | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode/keys" | ||
"github.com/openshift-pipelines/pipelines-as-code/pkg/metrics" | ||
tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" | ||
"gotest.tools/v3/assert" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestEmitMetrics(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
annotations map[string]string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "provider is GitHub App", | ||
annotations: map[string]string{ | ||
keys.GitProvider: "github", | ||
keys.EventType: "pull_request", | ||
keys.InstallationID: "123", | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "provider is GitHub Webhook", | ||
annotations: map[string]string{ | ||
keys.GitProvider: "github", | ||
keys.EventType: "pull_request", | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "provider is GitLab", | ||
annotations: map[string]string{ | ||
keys.GitProvider: "gitlab", | ||
keys.EventType: "push", | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "unsupported provider", | ||
annotations: map[string]string{ | ||
keys.GitProvider: "unsupported", | ||
keys.EventType: "push", | ||
}, | ||
wantErr: true, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
m, err := metrics.NewRecorder() | ||
assert.NilError(t, err) | ||
r := &Reconciler{ | ||
metrics: m, | ||
} | ||
pr := &tektonv1.PipelineRun{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Annotations: tt.annotations, | ||
}, | ||
} | ||
if err = r.emitMetrics(pr); (err != nil) != tt.wantErr { | ||
t.Errorf("emitMetrics() error = %v, wantErr %v", err != nil, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |