Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/reference/edot-python/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,15 @@ EDOT Python uses different defaults than OpenTelemetry Python for the following

| Option | EDOT Python default | OpenTelemetry Python default | Notes |
|---|---|---|---|
| `OTEL_EXPERIMENTAL_RESOURCE_DETECTORS` | `process_runtime,os,otel,telemetry_distro,service_instance,containerid,_gcp,aws_ec2,aws_ecs,aws_elastic_beanstalk,azure_app_service,azure_vm` | `otel` | |
| `OTEL_EXPERIMENTAL_RESOURCE_DETECTORS` | `process_runtime,os,telemetry_distro,service_instance,containerid,_gcp,aws_ec2,aws_ecs,aws_elastic_beanstalk,azure_app_service,azure_vm,otel` | `otel` | |
| `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` | `DELTA` | `CUMULATIVE` | |
| `OTEL_LOG_LEVEL` | `warn` | | {applies_to}`edot_python: ga 1.9.0` |
| `OTEL_METRICS_EXEMPLAR_FILTER` | `always_off` | `trace_based` | |
| `OTEL_TRACES_SAMPLER` | `experimental_composite_parentbased_traceidratio` | `parentbased_always_on` | {applies_to}`edot_python: ga 1.10.0`<br><br>The EDOT Python default was previously `parentbased_traceidratio` {applies_to}`edot_python: ga 1.5-1.9` |
| `OTEL_TRACES_SAMPLER_ARG` | `1.0` | | {applies_to}`edot_python: ga 1.6.0`|

:::{note}
`OTEL_EXPERIMENTAL_RESOURCE_DETECTORS` cloud resource detectors are dynamically set. When running in a Kubernetes Pod it will be set to `process_runtime,os,otel,telemetry_distro,service_instance,_gcp,aws_eks`.
`OTEL_EXPERIMENTAL_RESOURCE_DETECTORS` cloud resource detectors are dynamically set. When running in a Kubernetes Pod it will be set to `process_runtime,os,telemetry_distro,service_instance,_gcp,aws_eks,otel`.
:::

:::{note}
Expand Down
6 changes: 4 additions & 2 deletions src/elasticotel/distro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ def _configure(self, **kwargs):
base_resource_detectors = [
"process_runtime",
"os",
"otel",
"telemetry_distro",
"service_instance",
"containerid",
]
detectors = base_resource_detectors + get_cloud_resource_detectors()
# the `otel` resource detector reads the `OTEL_RESOURCE_ATTRIBUTES` and `OTEL_SERVICE_NAME`
# from the environment variables. Keep it last so we can override attributes by the other
# resource detectors
detectors = base_resource_detectors + get_cloud_resource_detectors() + ["otel"]
os.environ.setdefault(OTEL_EXPERIMENTAL_RESOURCE_DETECTORS, ",".join(detectors))
2 changes: 1 addition & 1 deletion tests/distro/test_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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,service_instance,containerid,_gcp,aws_ec2,aws_ecs,aws_elastic_beanstalk,azure_app_service,azure_vm",
"process_runtime,os,telemetry_distro,service_instance,containerid,_gcp,aws_ec2,aws_ecs,aws_elastic_beanstalk,azure_app_service,azure_vm,otel",
os.environ.get(OTEL_EXPERIMENTAL_RESOURCE_DETECTORS),
)
self.assertEqual("always_off", os.environ.get(OTEL_METRICS_EXEMPLAR_FILTER))
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ def test_traces_sets_resource_attributes_from_env(self):
resource = span["resource"]
self.assertEqual(resource["service.name"], "my-service")

def test_traces_can_override_resource_attributes_from_env(self):
env = {"OTEL_RESOURCE_ATTRIBUTES": "telemetry.distro.name=custom-distro"}
stdout, stderr, returncode = self.run_script(
self.script, environment_variables=env, wrapper_script="opentelemetry-instrument"
)

telemetry = self.get_telemetry()
(span,) = telemetry["traces"]
resource = span["resource"]
self.assertEqual(resource["telemetry.distro.name"], "custom-distro")

def test_metrics_default_does_not_contain_system_metrics(self):
stdout, stderr, returncode = self.run_script(self.script, wrapper_script="opentelemetry-instrument")

Expand Down
Loading