-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
ac1806d
to
0cbf481
Compare
a0b1958
to
d4ba9f7
Compare
This add some code to dinamically filter the available resource detectors in order to avoid any eventual costly detection.
d4ba9f7
to
4af2bf8
Compare
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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😓
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