Homeโ€บ๐Ÿ Python Extensionsโ€บModule 121 min read ยท 13/16

Testing & Debugging

Tutorial2 exercises

Log Locations

Extension logs live on the ActiveGate:

# Extension datasource logs
/var/lib/dynatrace/remotepluginmodule/log/extensions/datasources/{extension-name}/

# Tail while testing
tail -f /var/lib/dynatrace/.../datasources/com.dynatrace.extension.my-ext/*.log

Common Errors

Error MessageCauseFix
Cannot find module __main__Missing __main__.py in wheelCheck wheel structure, rebuild
No module named XDependency not bundled in wheelAdd to setup.py install_requires
DEVICE_CONNECTION_ERRORAPI unreachable or timeoutCheck network, increase timeout
Certificate validation failedCA cert not on ActiveGateCopy ca.pem to AG certs dir
metric key not foundKey mismatch code vs YAMLCompare report_metric keys with metrics: section

๐Ÿ’ก Search for ERROR and Exception in the log โ€” Python tracebacks show the exact line number.

๐Ÿ›  Try it

This extension has a scalar OID missing .0 and a count metric with the wrong key. Find and fix both bugs.

extension.yamlYAML
Loading...

Local Testing

# test_local.py
from your_extension.__main__ import MyExtension

ext = MyExtension()
ext.activation_config = {
    "host": "10.0.0.1",
    "api_token": "test-token"
}
ext.query()  # Run one poll cycle

โš ๏ธ report_metric() won't send data locally โ€” it needs the EEC runtime. Print the values instead for testing.

Debugging Checklist

CheckHow
AG logs for tracebacksgrep -r "Exception\|ERROR" /var/lib/dynatrace/.../datasources/
Monitoring config correctDynatrace UI โ†’ Extensions โ†’ Monitoring configurations
EEC runningsystemctl status dynatracegateway
Metric keys matchCompare report_metric() calls with metrics: in YAML
CA cert installedCheck both Credential Vault and AG certificates/ dir
๐Ÿ›  Try itExercise 2

This table subgroup has a scalar OID ending in .0 and a metric used in snmp: but missing from metrics: metadata. Fix both.

extension.yamlYAML
Loading...

What's Next

๐ŸŽ‰ Python track complete! Continue to Production Skills for alerts, validation, and real-world case studies.