Skip to content
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

Add support for detecting MIG attributes on GCE VMs #6538

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

quentinmit
Copy link

This adds support for two new resource attributes, gcp.gce.instance_group_manager.name and gcp.gce.instance_group_manager.{zone,region}, that indicate the managed instance group that a Compute Engine VM is part of. The equivalent Collector change is in open-telemetry/opentelemetry-collector-contrib#36142

@quentinmit quentinmit requested review from dashpole and a team as code owners December 27, 2024 23:18
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 78.57143% with 3 lines in your changes missing coverage. Please review.

Project coverage is 68.5%. Comparing base (00786cc) to head (e755523).
Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
detectors/gcp/detector.go 78.5% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #6538   +/-   ##
=====================================
  Coverage   68.5%   68.5%           
=====================================
  Files        200     200           
  Lines      16768   16782   +14     
=====================================
+ Hits       11490   11501   +11     
- Misses      4933    4936    +3     
  Partials     345     345           
Files with missing lines Coverage Δ
detectors/gcp/detector.go 83.1% <78.5%> (-0.7%) ⬇️

@MrAlias
Copy link
Contributor

MrAlias commented Jan 6, 2025

Please address the lint failures.

Comment on lines +149 to +154
// TODO: semconv.GCPGceInstanceGroupManagerNameKey
gcpGceInstanceGroupManagerNameKey = attribute.Key("gcp.gce.instance_group_manager.name")
// TODO: semconv.GCPGceInstanceGroupManagerZoneKey
gcpGceInstanceGroupManagerZoneKey = attribute.Key("gcp.gce.instance_group_manager.zone")
// TODO: semconv.GCPGceInstanceGroupManagerRegionKey
gcpGceInstanceGroupManagerRegionKey = attribute.Key("gcp.gce.instance_group_manager.region")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please open an issue to track the work needed to resolve these TODOs and reference the issue in this comment.

r.attrs = append(r.attrs, gcpGceInstanceGroupManagerRegionKey.String(mig.Location))
}
} else {
r.errs = append(r.errs, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing test for this error.

Comment on lines +158 to +170
if mig, err := detect(); err == nil {
if mig.Name != "" {
r.attrs = append(r.attrs, gcpGceInstanceGroupManagerNameKey.String(mig.Name))
}
switch mig.Type {
case gcp.Zone:
r.attrs = append(r.attrs, gcpGceInstanceGroupManagerZoneKey.String(mig.Location))
case gcp.Region:
r.attrs = append(r.attrs, gcpGceInstanceGroupManagerRegionKey.String(mig.Location))
}
} else {
r.errs = append(r.errs, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation can be reduced by restructuring:

Suggested change
if mig, err := detect(); err == nil {
if mig.Name != "" {
r.attrs = append(r.attrs, gcpGceInstanceGroupManagerNameKey.String(mig.Name))
}
switch mig.Type {
case gcp.Zone:
r.attrs = append(r.attrs, gcpGceInstanceGroupManagerZoneKey.String(mig.Location))
case gcp.Region:
r.attrs = append(r.attrs, gcpGceInstanceGroupManagerRegionKey.String(mig.Location))
}
} else {
r.errs = append(r.errs, err)
}
mig, err := detect()
if err != nil {
r.errs = append(r.errs, err)
return
}
if mig.Name != "" {
r.attrs = append(r.attrs, gcpGceInstanceGroupManagerNameKey.String(mig.Name))
}
switch mig.Type {
case gcp.Zone:
r.attrs = append(r.attrs, gcpGceInstanceGroupManagerZoneKey.String(mig.Location))
case gcp.Region:
r.attrs = append(r.attrs, gcpGceInstanceGroupManagerRegionKey.String(mig.Location))
}

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.

3 participants