Skip to content

distro: add cloud resource detectors #198

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

Merged
merged 5 commits into from
Dec 3, 2024
Merged

distro: add cloud resource detectors #198

merged 5 commits into from
Dec 3, 2024

Conversation

xrmx
Copy link
Member

@xrmx xrmx commented Nov 28, 2024

What does this pull request do?

This add some code to dinamically filter the available resource detectors in order to avoid any eventual costly detection.

Related issues

Closes #23

@xrmx xrmx marked this pull request as draft November 28, 2024 14:49
@xrmx xrmx force-pushed the enable-cloud-detectors branch 2 times, most recently from ac1806d to 0cbf481 Compare December 2, 2024 11:09
@xrmx xrmx marked this pull request as ready for review December 2, 2024 11:10
@xrmx xrmx requested a review from trentm December 2, 2024 13:26
@xrmx xrmx force-pushed the enable-cloud-detectors branch from a0b1958 to d4ba9f7 Compare December 2, 2024 13:36
xrmx added 3 commits December 2, 2024 14:40
This add some code to dinamically filter the available resource
detectors in order to avoid any eventual costly detection.
@xrmx xrmx force-pushed the enable-cloud-detectors branch from d4ba9f7 to 4af2bf8 Compare December 2, 2024 13:40
Comment on lines +53 to +65
def get_cloud_resource_detectors():
"""Helper to get a subset of the available cloud resource detectors depending on the environment

This is done to avoid loading resource detectors doing HTTP requests for metadata that will fail"""
if _on_aws_lambda():
return AWS_LAMBDA_DETECTORS
elif _on_azure_functions():
return AZURE_FUNCTIONS_DETECTORS
elif _on_gcp_cloud_run():
return GCP_CLOUD_RUN_DETECTORS
elif _on_k8s():
return KUBERNETES_DETECTORS
return OTHER_CLOUD_DETECTORS
Copy link
Member

Choose a reason for hiding this comment

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

Nice. I like this.

@@ -48,6 +51,7 @@ distro = "elasticotel.distro:ElasticOpenTelemetryDistro"
[project.entry-points.opentelemetry_resource_detector]
process_runtime = "elasticotel.sdk.resources:ProcessRuntimeResourceDetector"
telemetry_distro = "elasticotel.sdk.resources:TelemetryDistroResourceDetector"
_gcp = "opentelemetry.resourcedetector.gcp_resource_detector._detector:GoogleCloudResourceDetector"
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why the leading underscore. Is it because of the _detector sub-package import?

Copy link
Member Author

@xrmx xrmx Dec 3, 2024

Choose a reason for hiding this comment

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

It's because I'm defining the entry point here while it should really be the package with the resource detector doing it 😓

@xrmx xrmx merged commit 35eaf61 into main Dec 3, 2024
11 checks passed
@xrmx xrmx mentioned this pull request Dec 24, 2024
@xrmx xrmx deleted the enable-cloud-detectors branch January 10, 2025 10:47
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.

cloud resource detectors
2 participants