Skip to content

Commit 16f4e26

Browse files
Docker Utilization Disabled on Windows (#1459)
* Disable docker utilization on Windows by default * Fix testing issue --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 4795010 commit 16f4e26

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

newrelic/core/agent_protocol.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import logging
1616
import os
17+
import sys
1718
from pathlib import Path
1819

1920
from newrelic import version
@@ -355,9 +356,16 @@ def _connect_payload(app_name, linked_applications, environment, settings):
355356

356357
if settings["utilization.detect_docker"]:
357358
if not ecs_id:
358-
docker = DockerUtilization.detect()
359-
if docker:
360-
utilization_vendor_settings["docker"] = docker
359+
if sys.platform == "win32":
360+
_logger.warning(
361+
"Docker utilization detection is not supported on Windows. "
362+
"Skipping Docker utilization detection. You can disable this "
363+
"warning by not setting utilization.detect_docker in your configuration."
364+
)
365+
else:
366+
docker = DockerUtilization.detect()
367+
if docker:
368+
utilization_vendor_settings["docker"] = docker
361369

362370
if settings["utilization.detect_kubernetes"]:
363371
kubernetes = KubernetesUtilization.detect()

newrelic/core/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import logging
2828
import os
2929
import re
30+
import sys
3031
import threading
3132
import urllib.parse as urlparse
3233

@@ -960,7 +961,7 @@ def default_otlp_host(host):
960961
_settings.utilization.detect_aws = True
961962
_settings.utilization.detect_azure = True
962963
_settings.utilization.detect_azurefunction = True
963-
_settings.utilization.detect_docker = True
964+
_settings.utilization.detect_docker = sys.platform != "win32" # Docker detection is not supported on Windows
964965
_settings.utilization.detect_kubernetes = True
965966
_settings.utilization.detect_gcp = True
966967
_settings.utilization.detect_pcf = True

tests/agent_unittests/test_agent_protocol.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import logging
1616
import os
1717
import ssl
18+
import sys
1819
import tempfile
1920
from pathlib import Path
2021

@@ -375,6 +376,12 @@ def test_connect(
375376
with_aws, with_ecs, with_pcf, with_gcp, with_azure, with_azurefunction, with_docker, with_kubernetes, with_ip
376377
):
377378
global AWS, AZURE, AZUREFUNCTION, GCP, PCF, DOCKER, KUBERNETES, IP_ADDRESS
379+
380+
if sys.platform == "win32":
381+
# Docker utilization is not supported on Windows.
382+
# Override the test matrix to always be False.
383+
with_docker = False
384+
378385
if not with_aws:
379386
AWS = Exception
380387
if not with_pcf:

0 commit comments

Comments
 (0)