Skip to content

Add a resource detector for Gitlab CICD #6760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

chameleon82
Copy link

Fixes for Gitlab CI: #6759

This PR adds a resource detector for Gitlab CI which sets values according to to semantic conventions for cicd](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/attributes-registry/cicd.md) and vcs resources:

cicd.pipeline.name
cicd.pipeline.task.run.id
cicd.pipeline.task.name
cicd.pipeline.task.type
cicd.pipeline.run.id
cicd.pipeline.task.run.url.full
vcs.repository.ref.name
vcs.repository.ref.type
vcs.repository.change.id
vcs.repository.url.full

@chameleon82 chameleon82 requested a review from a team as a code owner February 12, 2025 05:57
Copy link

linux-foundation-easycla bot commented Feb 12, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@chameleon82 chameleon82 force-pushed the cicd-gitlab-detector branch 2 times, most recently from 01f4338 to abec055 Compare February 12, 2025 06:13

ciPipelineName := os.Getenv(gitlabPipelineNameEnvVar)
if ciPipelineName != "" {
attributes = append(attributes, attribute.String(string(semconv.CICDPipelineNameKey), ciPipelineName))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can adjust this kind of format. semconv.CICDPipelineNameKey.String("xxxxx")


func setTestEnv(t *testing.T, envs []EnvPair) {
for _, env := range envs {
err := os.Setenv(env.Key, env.Value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.Setenv be changed to t.Setenv

@flc1125
Copy link
Member

flc1125 commented Feb 12, 2025

We might need to add a configuration here: versions.yaml

Of course, the specific location to add it might need to be evaluated by @open-telemetry/go-approvers.


Don't forget there are two similar files:

@chameleon82
Copy link
Author

added as experimental version, but can't find version for the another component https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/detectors/azure/azurevm. not sure if this is expected for experimental versions

@dmathieu
Copy link
Member

Did you go through our new instrumentation docs?
https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/README.md#new-instrumentation

Could you develop on why this needs to be a go-contrib instrumentation, and can't be owned by you, or GitLab?

Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, thanks for your will in contributing to OTel 👍

This proposes a new module and it lacks a code owner.
This PR won't be accepted (and possibly even reviewed) if no code owner is found.

Please check https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/CONTRIBUTING.md#code-owners for more information.

@pellared
Copy link
Member

Did you go through our new instrumentation docs? https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/README.md#new-instrumentation

Could you develop on why this needs to be a go-contrib instrumentation, and can't be owned by you, or GitLab?

I created #6762

I think that we cannot expect contributors to find https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/README.md#new-instrumentation

@chameleon82
Copy link
Author

Thanks @dmathieu and @pellared for pointing those good points.
Yes, it is not directly related to instrumentation (which can be very different in the case - worker/runner or go test framework). And as I see current work on cicd semantic, it can be a good idea to have commonly used systems (github/gitlab) covered with contrib module.

I'm looking for both cases (gitlab pipelines otel observability and go test observability with tracing) and will be happy to contribute as much I can into it, but as currently not a part of a working group and do not participate SIG's - may not be a proper maintainer.

Let's ask @dnsmichi, @sguyon opinion on this as Gitlab representatives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants