Skip to content

Commit

Permalink
distro: add back GCP resource detector (#229)
Browse files Browse the repository at this point in the history
A fix for the infinite loop we were seeing has been fixed and released
so after bumping it we can re-enable it.
  • Loading branch information
xrmx authored Jan 10, 2025
1 parent f21c0dc commit a97327a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ opentelemetry-proto==1.29.0
# oteltest
opentelemetry-resource-detector-azure==0.1.5
# via elastic-opentelemetry (pyproject.toml)
opentelemetry-resourcedetector-gcp==1.7.0a0
opentelemetry-resourcedetector-gcp==1.8.0a0
# via elastic-opentelemetry (pyproject.toml)
opentelemetry-sdk==1.29.0
# via
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies = [
"opentelemetry-exporter-otlp == 1.29.0",
"opentelemetry-instrumentation == 0.50b0",
"opentelemetry-instrumentation-system-metrics == 0.50b0",
"opentelemetry-resourcedetector-gcp ~= 1.7.0a0",
"opentelemetry-resourcedetector-gcp ~= 1.8.0a0",
"opentelemetry-resource-detector-azure ~= 0.1.5",
"opentelemetry-sdk == 1.29.0",
"opentelemetry-sdk-extension-aws ~= 2.1.0",
Expand Down
5 changes: 3 additions & 2 deletions src/elasticotel/distro/resource_detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

AWS_LAMBDA_DETECTORS = ["aws_lambda"]
AZURE_FUNCTIONS_DETECTORS = ["azure_functions"]
GCP_CLOUD_RUN_DETECTORS = []
KUBERNETES_DETECTORS = ["aws_eks"]
GCP_CLOUD_RUN_DETECTORS = ["_gcp"]
KUBERNETES_DETECTORS = ["_gcp", "aws_eks"]
OTHER_CLOUD_DETECTORS = [
"_gcp",
"aws_ec2",
"aws_ecs",
"aws_elastic_beanstalk",
Expand Down
2 changes: 1 addition & 1 deletion tests/distro/test_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_default_configuration(self):
self.assertEqual("otlp", os.environ.get(OTEL_LOGS_EXPORTER))
self.assertEqual("grpc", os.environ.get(OTEL_EXPORTER_OTLP_PROTOCOL))
self.assertEqual(
"process_runtime,os,otel,telemetry_distro,aws_ec2,aws_ecs,aws_elastic_beanstalk,azure_app_service,azure_vm",
"process_runtime,os,otel,telemetry_distro,_gcp,aws_ec2,aws_ecs,aws_elastic_beanstalk,azure_app_service,azure_vm",
os.environ.get(OTEL_EXPERIMENTAL_RESOURCE_DETECTORS),
)
self.assertEqual("always_off", os.environ.get(OTEL_METRICS_EXEMPLAR_FILTER))
Expand Down
6 changes: 3 additions & 3 deletions tests/distro/test_resource_detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ def test_azure_functions(self):
@mock.patch.dict("os.environ", {"K_CONFIGURATION": "cloudrun"}, clear=True)
def test_gcp_cloud_run(self):
resource_detectors = get_cloud_resource_detectors()
self.assertEqual(resource_detectors, [])
self.assertEqual(resource_detectors, ["_gcp"])

@mock.patch.dict("os.environ", {"KUBERNETES_SERVICE_HOST": "k8s"}, clear=True)
def test_kubernetes_pod(self):
resource_detectors = get_cloud_resource_detectors()
self.assertEqual(resource_detectors, ["aws_eks"])
self.assertEqual(resource_detectors, ["_gcp", "aws_eks"])

@mock.patch.dict("os.environ", {}, clear=True)
def test_other_cloud_detectors(self):
resource_detectors = get_cloud_resource_detectors()
self.assertEqual(
resource_detectors,
["aws_ec2", "aws_ecs", "aws_elastic_beanstalk", "azure_app_service", "azure_vm"],
["_gcp", "aws_ec2", "aws_ecs", "aws_elastic_beanstalk", "azure_app_service", "azure_vm"],
)

0 comments on commit a97327a

Please sign in to comment.