### setup.py example Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/guides/extension_structure.rst Standard Python setup script for packaging the extension. Specifies dependencies on dt-extensions-sdk and Python >=3.10. Used by the extension execution controller to install the extension on ActiveGate or OneAgent. ```python from setuptools import setup, find_packages setup( name="my_extension", version="0.0.1", description="My_extension python EF2 extension", author="Dynatrace", packages=find_packages(), python_requires=">=3.10", include_package_data=True, install_requires=["dt-extensions-sdk"], extras_require={"dev": ["dt-extensions-sdk[cli]"]}, ) ``` -------------------------------- ### Create a virtual environment and install dt-extensions-sdk Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/index.rst Recommended when working on several extensions. Creates a virtual environment, activates it, and installs the SDK to isolate dependencies per project. ```bash python -m venv .venv source .venv/bin/activate pip install dt-extensions-sdk ``` -------------------------------- ### Install dt-extensions-sdk with CLI support via pip Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/guides/installation.rst Use this command to install the dt-extensions-sdk package from PyPI with the optional CLI extra. After installation, the dt-sdk binary will be available in your PATH. ```bash pip install dt-extensions-sdk[cli] ``` -------------------------------- ### Install the SDK with pip Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/README.md Installs the dt-extensions-sdk package with the CLI extra using pip. Requires Python 3.10 or 3.14. ```bash pip install "dt-extensions-sdk[cli]" ``` -------------------------------- ### dt-sdk --help command with ModuleNotFoundError for typer Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/cli/help.rst Run `dt-sdk --help` to display help. This example shows the error that occurs when the 'typer' module is not installed, producing a ModuleNotFoundError traceback. The traceback indicates the CLI entry point fails at import time because 'typer' is missing. ```text $ dt-sdk --help Traceback (most recent call last): File "/usr/local/bin/dt-sdk", line 3, in from dynatrace_extension.cli import app File "/workspace/input/dynatrace_extension/cli/__init__.py", line 5, in from .main import app # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^ File "/workspace/input/dynatrace_extension/cli/main.py", line 9, in import typer ModuleNotFoundError: No module named 'typer' ``` -------------------------------- ### dt-sdk wheel --help command and traceback Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/cli/wheel.rst Shows the command to get help for the wheel subcommand and the resulting ModuleNotFoundError when the 'typer' module is missing from the environment. ```text $ dt-sdk wheel --help Traceback (most recent call last): File "/usr/local/bin/dt-sdk", line 3, in from dynatrace_extension.cli import app File "/workspace/input/dynatrace_extension/cli/__init__.py", line 5, in from .main import app # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^ File "/workspace/input/dynatrace_extension/cli/main.py", line 9, in import typer ModuleNotFoundError: No module named 'typer' ``` -------------------------------- ### Generated extension directory structure Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/index.rst Shows the file layout generated for a new extension named my_extension, including configuration, source, and setup files. ```bash my_extension ├── README.md ├── activation.json ├── extension │ ├── activationSchema.json │ └── extension.yaml ├── my_extension │ ├── __init__.py │ └── __main__.py ├── secrets.json └── setup.py ``` -------------------------------- ### dt-sdk upload --help command and error output Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/cli/upload.rst Shows the command 'dt-sdk upload --help' and the resulting traceback when the 'typer' module is not installed. The error indicates a ModuleNotFoundError for 'typer'. ```text $ dt-sdk upload --help Traceback (most recent call last): File "/usr/local/bin/dt-sdk", line 3, in from dynatrace_extension.cli import app File "/workspace/input/dynatrace_extension/cli/__init__.py", line 5, in from .main import app # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^ File "/workspace/input/dynatrace_extension/cli/main.py", line 9, in import typer ModuleNotFoundError: No module named 'typer' ``` -------------------------------- ### secrets.json example Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/guides/extension_structure.rst Defines a secret named myPassword with value secretPassword. Use {{myPassword}} in activation.json to reference it. Only string-type secrets are supported. ```json { "myPassword": "secretPassword" } ``` -------------------------------- ### dt-sdk run --help output with ModuleNotFoundError Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/cli/run.rst Shows the output of running `dt-sdk run --help`. The command fails with a `ModuleNotFoundError: No module named 'typer'`, indicating the `typer` dependency is not installed in the environment. ```text $ dt-sdk run --help Traceback (most recent call last): File "/usr/local/bin/dt-sdk", line 3, in from dynatrace_extension.cli import app File "/workspace/input/dynatrace_extension/cli/__init__.py", line 5, in from .main import app # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^ File "/workspace/input/dynatrace_extension/cli/main.py", line 9, in import typer ModuleNotFoundError: No module named 'typer' ``` -------------------------------- ### Report mint lines with report_mint_lines Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Example usage of report_mint_lines to report metric lines in MINT format. The lines must comply with the MINT format. ```pycon >>> self.report_mint_lines(["my_metric 1", "my_other_metric 2"]) ``` -------------------------------- ### dt-sdk assemble --help fails with ModuleNotFoundError: No module named 'typer' Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/cli/assemble.rst Running `dt-sdk assemble --help` fails with a `ModuleNotFoundError` because the `typer` module is not installed. The traceback shows the CLI entry point and the import chain that leads to the missing dependency. ```text $ dt-sdk assemble --help Traceback (most recent call last): File "/usr/local/bin/dt-sdk", line 3, in from dynatrace_extension.cli import app File "/workspace/input/dynatrace_extension/cli/__init__.py", line 5, in from .main import app # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^ File "/workspace/input/dynatrace_extension/cli/main.py", line 9, in import typer ModuleNotFoundError: No module named 'typer' ``` -------------------------------- ### Report a metric inside query() with report_metric Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/index.rst Example line from the query() method that sends a single data point for the metric 'my_metric' with value 1 and dimension 'my_dimension' set to 'dimension1'. The next data point is sent in 60 seconds when query() runs again. ```python # Report metrics with self.report_metric("my_metric", 1, dimensions={"my_dimension": "dimension1"}) ``` -------------------------------- ### dt-sdk gencerts --help command with missing typer module error Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/cli/gencerts.rst Running the gencerts command fails with a ModuleNotFoundError because the 'typer' module is not installed. This error occurs when the dt-sdk CLI is invoked without the required dependencies. ```text $ dt-sdk gencerts --help Traceback (most recent call last): File "/usr/local/bin/dt-sdk", line 3, in from dynatrace_extension.cli import app File "/workspace/input/dynatrace_extension/cli/__init__.py", line 5, in from .main import app # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^ File "/workspace/input/dynatrace_extension/cli/main.py", line 9, in import typer ModuleNotFoundError: No module named 'typer' ``` -------------------------------- ### Sample activation config (activation.json) Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/guides/extension_structure.rst A sample activation config for local testing when the extension instance is launched using the Run command. It must contain all mandatory fields as defined in the Activation Schema and supports using secrets from the secrets.json file. ```json { "enabled": true, "description": "my_extension activation", "version": "0.0.1", "activationContext": "REMOTE", "pythonRemote": { "endpoints": [ { "url": "http://127.0.0.1:15672", "user": "guest", "password": "{{myPassword}}" } ] } } ``` -------------------------------- ### Run the extension locally with dt-sdk run Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/index.rst Launches the extension in development mode. Change into the extension directory and run dt-sdk run; the output shows the startup logs and successful execution of the query method. ```bash $ cd my_extension $ dt-sdk run Running: .venv/dt-extensions-sdk/bin/python -m my_extension --activationconfig activation.json [INFO] api (MainThread): ----------------------------------------------------- [INFO] api (MainThread): Starting my_extension, version: 1.1.0 [INFO] api (ThreadPoolExecutor-1_0): send_status: '{"status": "OK", "message": "", "timestamp": 1699993566909}' [INFO] api (ThreadPoolExecutor-1_1): send_sfm_metric: dsfm:datasource.python.threads,dt.extension.config.id="development_config_id" count,delta=4 [INFO] dynatrace_extension.sdk.extension (ThreadPoolExecutor-0_0): query method started for my_extension. [INFO] dynatrace_extension.sdk.extension (ThreadPoolExecutor-0_0): query method ended for my_extension. ``` -------------------------------- ### Build documentation with hatch Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/README.md Builds the documentation site using Hatch. ```console hatch run docs:build ``` -------------------------------- ### Create a new extension with dt-sdk create Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/README.md Creates a new extension project named 'my_first_extension'. ```bash dt-sdk create my_first_extension ``` -------------------------------- ### Simulate extension with dt-sdk run Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/README.md Simulates the extension locally. Must be run from the extension directory (e.g., my_first_extension). ```bash cd my_first_extension dt-sdk run ``` -------------------------------- ### Generate a new extension with dt-sdk create Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/index.rst Creates a new extension named my_extension from scratch using the Create command. The command prints 'Extension created at my_extension' upon success. ```bash $ dt-sdk create my_extension Extension created at my_extension ``` -------------------------------- ### Build extension with dt-sdk build Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/index.rst Run `dt-sdk build` to build and sign the extension. The command performs four stages: download dependencies, create the extension zip, sign the extension, and delete the intermediate zip. The signed build is placed in the `dist` directory. ```bash $ dt-sdk build Building and signing extension from my_extension to None Stage 1 - Download and build dependencies Cleaning my_extension/extension/lib Downloading dependencies to my_extension/extension/lib Running: .venv/dt-extensions-sdk/bin/python -m pip wheel -w extension/lib . Processing my_extension Preparing metadata (setup.py) ... done Collecting dt-extensions-sdk (from my-extension==0.0.1) Using cached dt_extensions_sdk-1.1.0-py3-none-any.whl.metadata (1.8 kB) Using cached dt_extensions_sdk-1.1.0-py3-none-any.whl (42 kB) Saved ./extension/lib/dt_extensions_sdk-1.1.0-py3-none-any.whl Building wheels for collected packages: my-extension Building wheel for my-extension (setup.py) ... done Created wheel for my-extension: filename=my_extension-0.0.1-py3-none-any.whl size=1985 sha256=19039181b70d68105512ad52b80129368724b3f15e0ba2a2b5fdb98cc710e705 Stored in directory: /private/var/folders/jd/s1xmb3jj31gcd11g3p4ncctm5q47pj/T/pip-ephem-wheel-cache-zqkysr41/wheels/9c/1c/44/e47f092abb0d0b281251f7cfc7b8d5993c2c5678b3acd80751 Successfully built my-extension Installed dependencies to my_extension/extension/lib Stage 2 - Create the extension zip file Running: dt ext assemble --source my_extension/extension --output my_extension/dist/extension.zip --force my_extension/dist/extension.zip file already exists, it will be overwritten! Building my_extension/dist/extension.zip from my_extension/extension Adding file: my_extension/extension/lib/my_extension-0.0.1-py3-none-any.whl as lib/my_extension-0.0.1-py3-none-any.whl Adding file: my_extension/extension/lib/dt_extensions_sdk-1.1.0-py3-none-any.whl as lib/dt_extensions_sdk-1.1.0-py3-none-any.whl Adding file: my_extension/extension/extension.yaml as extension.yaml Adding file: my_extension/extension/activationSchema.json as activationSchema.json Built the extension zip file to my_extension/dist/extension.zip Stage 3 - Sign the extension Signing file my_extension/dist/extension.zip to my_extension/dist/custom_my-extension-0.0.1.zip with certificate /Users/myuser/.dynatrace/certificates/developer.pem Running: dt ext sign --src my_extension/dist/extension.zip --output my_extension/dist/custom_my-extension-0.0.1.zip --key /Users/myuser/.dynatrace/certificates/developer.pem --force Created signed extension file my_extension/dist/custom_my-extension-0.0.1.zip Stage 4 - Delete my_extension/dist/extension.zip ``` -------------------------------- ### Simple activation schema (activationSchema.json) Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/guides/extension_structure.rst A minimal JSON schema for the monitoring configuration, with a single field 'host' that runs on ActiveGate. The schema generated by the Create command is larger and contains more fields, passwords, list items, and so on. ```json { "types": { "pythonRemote": { "type": "object", "properties": { "host": { "displayName": "Host", "type": "text", "nullable": false, "default": "" } } } }, "dynatrace": "1", "description": "Extension configuration", "schemaId": "python-extension.activation", "displayName": "Extension configuration", "ownerProductManagement": "Albus Dumbledore", "ownerDevelopment": "Peter Parker", "maturity": "GENERAL_AVAILABILITY", "allowedScopes": ["environment"], "multiObject": false, "properties": { "pythonRemote": { "displayName": "Python Remote Extension", "type": { "$ref": "#/types/pythonRemote" } } } } ``` -------------------------------- ### Build package with hatch Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/README.md Builds the distribution package using Hatch. ```console hatch build ``` -------------------------------- ### Upload extension with dt-sdk upload Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/README.md Uploads the built extension. Requires setting environment variables DT_API_URL and DT_API_TOKEN or passing them as arguments. ```bash # Note, you need to either set environment variables DT_API_URL and DT_API_TOKEN or pass them as arguments dt-sdk upload ``` -------------------------------- ### Run tests with hatch Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/README.md Runs the test suite using Hatch. ```console hatch run test ``` -------------------------------- ### Signed build output path Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/index.rst After building, the signed extension is placed in the `dist` directory as `custom_my-extension-0.0.1.zip`. ```bash dist/custom_my-extension-0.0.1.zip ``` -------------------------------- ### Run linting with hatch Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/README.md Runs all linting checks using Hatch. ```console hatch run lint:all ``` -------------------------------- ### Create signing certificates with dt-sdk gencerts Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/README.md Generates signing certificates required for signing extensions. Run this before creating an extension. ```bash dt-sdk gencerts ``` -------------------------------- ### Build extension with dt-sdk build Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/README.md Builds the extension package for distribution. ```bash dt-sdk build ``` -------------------------------- ### Generate certificates with dt-sdk gencerts Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/index.rst Run `dt-sdk gencerts` to generate a CA and developer certificate. The command outputs the paths of the generated CA key, CA certificate, developer certificate, and developer private key. Certificates are placed in the default directory. ```bash $ dt-sdk gencerts Running: dt ext genca --ca-cert /Users/myuser/.dynatrace/certificates/ca.pem --ca-key /Users/myuser/.dynatrace/certificates/ca.key --no-ca-passphrase Generating CA... Wrote CA private key: /Users/myuser/.dynatrace/certificates/ca.key Wrote CA certificate: /Users/myuser/.dynatrace/certificates/ca.pem Running: dt ext generate-developer-pem --output /Users/myuser/.dynatrace/certificates/developer.pem --name Acme --ca-crt /Users/myuser/.dynatrace/certificates/ca.pem --ca-key /Users/myuser/.dynatrace/certificates/ca.key Loading CA private key /Users/myuser/.dynatrace/certificates/ca.key Loading CA certificate /Users/myuser/.dynatrace/certificates/ca.pem Generating developer certificate... Wrote developer certificate: /Users/myuser/.dynatrace/certificates/developer.pem Wrote developer private key: /Users/myuser/.dynatrace/certificates/developer.pem ``` -------------------------------- ### Stop the extension with Ctrl+C and observe flush output Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/index.rst Shows the output printed when the running extension receives a SIGINT (Ctrl+C). The logs confirm the extension flushes metrics and exits, sending one metric line to EEC. ```bash ^C[INFO] api (MainThread): SIGINT captured. Flushing metrics and exiting... [INFO] api (MainThread): send_metric: my_metric,my_dimension="dimension1" gauge,1 1699993566910 [INFO] api (MainThread): Sent 1 metric lines to EEC: [MintResponse(lines_ok=1, lines_invalid=0, error=None, warnings=None)] [INFO] api (MainThread): send_sfm_metric: dsfm:datasource.python.threads,dt.extension.config.id="development_config_id" count,delta=4 [INFO] api (MainThread): send_sfm_metric: dsfm:datasource.python.execution.time,callback="query",dt.extension.config.id="development_config_id" gauge,0.0003 [INFO] api (MainThread): send_sfm_metric: dsfm:datasource.python.execution.total.count,callback="query",dt.extension.config.id="development_config_id" count,delta=1 [INFO] api (MainThread): send_sfm_metric: dsfm:datasource.python.execution.count,callback="query",dt.extension.config.id="development_config_id" count,delta=1 [INFO] api (MainThread): send_sfm_metric: dsfm:datasource.python.execution.ok.count,callback="query",dt.extension.config.id="development_config_id" count,delta=1 [INFO] api (MainThread): send_sfm_metric: dsfm:datasource.python.execution.timeout.count,callback="query",dt.extension.config.id="development_config_id" count,delta=0 [INFO] api (MainThread): send_sfm_metric: dsfm:datasource.python.execution.exception.count,callback="query",dt.extension.config.id="development_config_id" count,delta=0 ``` -------------------------------- ### get_activation_config() -> ActivationConfig Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Retrieves the activation configuration assigned to this extension instance. ```APIDOC ## get_activation_config() -> ActivationConfig ### Description Retrieve the activation config. Represents activation configuration assigned to this particular extension instance. ### Returns - **ActivationConfig** - ActivationConfig object ``` -------------------------------- ### get_version() -> str Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Returns the extension version as a string. ```APIDOC ## get_version() -> str ### Description Return the extension version. ### Returns - **str** - The extension version ``` -------------------------------- ### dynatrace_extension.Metric.to_mint_line() Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/metrics/metric.rst Converts the metric to a string that complies with the MINT protocol. ```APIDOC ## dynatrace_extension.Metric.to_mint_line() ### Description Converts the metric to a string that complies with the MINT protocol. ### Method `to_mint_line()` ### Parameters None ### Returns - **str** - The metric as a MINT protocol compliant string. ``` -------------------------------- ### report_mint_lines(lines: list[str]) -> None Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Reports metric lines using the MINT protocol. The lines must comply with the MINT format. ```APIDOC ## report_mint_lines(lines: list[str]) -> None ### Description Reports metric lines using the MINT protocol. The lines must comply with the MINT format. ### Method report_mint_lines ### Parameters - **lines** (list[str]) - Required - A list of mint lines ### Request Example ```pycon >>> self.report_mint_lines(["my_metric 1", "my_other_metric 2"]) ``` ### Response No return value. ``` -------------------------------- ### report_log_lines(log_lines: list[str | bytes], send_immediately: bool = False) Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Reports a list of log lines using log ingest. Allows specifying a list of log lines and whether to send immediately. ```APIDOC ## report_log_lines(log_lines: list[str | bytes], send_immediately: bool = False) ### Description Reports a list of log lines using log ingest. Allows specifying a list of log lines and whether to send immediately. ### Method report_log_lines ### Parameters - **log_lines** (list[str | bytes]) - Required - The list of log lines - **send_immediately** (bool) - Optional - Option to directly schedule log to be sent without batching ### Response No return value. ``` -------------------------------- ### get_snapshot(snapshot_file: Path | str | None = None) -> Snapshot Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Retrieves a oneagent snapshot, optionally from a specified file when running via dt-sdk run. ```APIDOC ## get_snapshot(snapshot_file: Path | str | None = None) -> Snapshot ### Description Retrieves an oneagent snapshot. ### Parameters - **snapshot_file** (Path | str | None) - Optional - Optional path to the snapshot file, only used when running from dt-sdk run ### Returns - **Snapshot** - Snapshot object ``` -------------------------------- ### report_event(title: str, description: str, properties: dict | None = None, timestamp: datetime | None = None, severity: Severity | str = Severity.INFO, send_immediately: bool = False) -> None Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Reports an event using log ingest. Allows specifying title, description, properties, timestamp, severity, and whether to send immediately. ```APIDOC ## report_event(title: str, description: str, properties: dict | None = None, timestamp: datetime | None = None, severity: Severity | str = Severity.INFO, send_immediately: bool = False) -> None ### Description Reports an event using log ingest. Allows specifying title, description, properties, timestamp, severity, and whether to send immediately. ### Method report_event ### Parameters - **title** (str) - Required - The title of the event - **description** (str) - Required - The description of the event - **properties** (dict | None) - Optional - A dictionary of extra event properties - **timestamp** (datetime | None) - Optional - The timestamp of the event, defaults to the current time - **severity** (Severity | str) - Optional - The severity of the event, defaults to Severity.INFO - **send_immediately** (bool) - Optional - Option to directly schedule log to be sent without batching ### Response No return value. ``` -------------------------------- ### report_log_events(log_events: list[dict], send_immediately: bool = False) Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Reports a list of custom log events using log ingest. Allows specifying a list of log event dictionaries and whether to send immediately. ```APIDOC ## report_log_events(log_events: list[dict], send_immediately: bool = False) ### Description Reports a list of custom log events using log ingest. Allows specifying a list of log event dictionaries and whether to send immediately. ### Method report_log_events ### Parameters - **log_events** (list[dict]) - Required - The list of log events - **send_immediately** (bool) - Optional - Option to directly schedule log to be sent without batching ### Response No return value. ``` -------------------------------- ### enabled_feature_sets (property) Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Returns a dictionary containing enabled feature sets with corresponding metrics defined in extension.yaml. ```APIDOC ## enabled_feature_sets (property) ### Description Returns a dictionary containing enabled feature sets with corresponding metrics defined in extension.yaml. ### Method enabled_feature_sets ### Returns dict[str, list[str]] - Dictionary containing enabled feature sets with corresponding metrics. ``` -------------------------------- ### enabled_feature_sets_metrics (property) Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Returns a list of all metric keys from enabled feature sets. ```APIDOC ## enabled_feature_sets_metrics (property) ### Description Returns a list of all metric keys from enabled feature sets. ### Returns - **list[str]** - List of all metric keys from enabled feature sets ``` -------------------------------- ### report_log_event(log_event: dict, send_immediately: bool = False) Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Reports a custom log event using log ingest. Allows specifying a log event dictionary and whether to send immediately. ```APIDOC ## report_log_event(log_event: dict, send_immediately: bool = False) ### Description Reports a custom log event using log ingest. Allows specifying a log event dictionary and whether to send immediately. ### Method report_log_event ### Parameters - **log_event** (dict) - Required - The log event dictionary. - **send_immediately** (bool) - Optional - Option to directly schedule log to be sent without batching ### Response No return value. ``` -------------------------------- ### enabled_feature_sets_names (property) Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Returns a list containing names of enabled feature sets. ```APIDOC ## enabled_feature_sets_names (property) ### Description Returns a list containing names of enabled feature sets. ### Method enabled_feature_sets_names ### Returns list[str] - List containing names of enabled feature sets. ``` -------------------------------- ### report_dt_event_dict(event: dict) Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Reports an event using event ingest API with provided dictionary. The dictionary must follow the specified format. ```APIDOC ## report_dt_event_dict(event: dict) ### Description Reports an event using event ingest API with provided dictionary. The dictionary must follow the specified format. ### Method report_dt_event_dict ### Parameters - **event** (dict) - Required - The event dictionary. Format: ```default { "type": "object", "required": ["eventType", "title"], "properties": { "eventType": { "type": "string", "enum": [ "CUSTOM_INFO", "CUSTOM_ANNOTATION", "CUSTOM_CONFIGURATION", "CUSTOM_DEPLOYMENT", "MARKED_FOR_TERMINATION", "ERROR_EVENT", "AVAILABILITY_EVENT", "PERFORMANCE_EVENT", "RESOURCE_CONTENTION_EVENT", "CUSTOM_ALERT" ] }, "title": { "type": "string", "minLength": 1 }, "startTime": {"type": "integer"}, "endTime": {"type": "integer"}, "timeout": {"type": "integer"}, "entitySelector": {"type": "string"}, "properties": { "type": "object", "patternProperties": { "^.*$": {"type": "string"} } } } } ``` ### Response No return value. ``` -------------------------------- ### get_fields_dimensions(endpoint: dict) -> dict Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Parses primaryFields from an endpoint dictionary into a dimensions dictionary. ```APIDOC ## get_fields_dimensions(endpoint: dict) -> dict ### Description Parse primaryFields from an endpoint dict into a dimensions dictionary. ### Parameters - **endpoint** (dict) - Required - The endpoint dictionary containing primaryFields ### Returns - **dict** - Dictionary mapping each field's 'key' to its 'value', or empty dict if absent ``` -------------------------------- ### dynatrace_extension.Severity Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/events/event_severity.rst Enum class defining severity levels for log events. Use with Extension.report_event() for log ingestion. ```APIDOC ## dynatrace_extension.Severity ### Description Enum class defining severity levels for log events. Use with Extension.report_event() for log ingestion. ### Members - **EMERGENCY** (str) - Value: 'EMERGENCY' - **ERROR** (str) - Value: 'ERROR' - **ALERT** (str) - Value: 'ALERT' - **CRITICAL** (str) - Value: 'CRITICAL' - **SEVERE** (str) - Value: 'SEVERE' - **WARN** (str) - Value: 'WARN' - **NOTICE** (str) - Value: 'NOTICE' - **INFO** (str) - Value: 'INFO' - **DEBUG** (str) - Value: 'DEBUG' ### Usage This enum is used as a parameter when calling the `dynatrace_extension.Extension.report_event()` method for log ingestion. ``` -------------------------------- ### Event dictionary format for report_dt_event_dict Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Format of the event dictionary expected by report_dt_event_dict. The dictionary must include required fields 'eventType' and 'title', with optional properties like startTime, endTime, timeout, entitySelector, and properties. The eventType must be one of the enumerated values. ```default { "type": "object", "required": ["eventType", "title"], "properties": { "eventType": { "type": "string", "enum": [ "CUSTOM_INFO", "CUSTOM_ANNOTATION", "CUSTOM_CONFIGURATION", "CUSTOM_DEPLOYMENT", "MARKED_FOR_TERMINATION", "ERROR_EVENT", "AVAILABILITY_EVENT", "PERFORMANCE_EVENT", "RESOURCE_CONTENTION_EVENT", "CUSTOM_ALERT" ] }, "title": { "type": "string", "minLength": 1 }, "startTime": {"type": "integer"}, "endTime": {"type": "integer"}, "timeout": {"type": "integer"}, "entitySelector": {"type": "string"}, "properties": { "type": "object", "patternProperties": { "^.*$": {"type": "string"} } } } } ``` -------------------------------- ### techrule (property) Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Internal property used by the EEC. ```APIDOC ## techrule (property) ### Description Internal property used by the EEC. ``` -------------------------------- ### get_tags_dimensions(endpoint: dict) -> dict Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Parses primaryTags from an endpoint dictionary into a dimensions dictionary. ```APIDOC ## get_tags_dimensions(endpoint: dict) -> dict ### Description Parse primaryTags from an endpoint dict into a dimensions dictionary. ### Parameters - **endpoint** (dict) - Required - The endpoint dictionary containing primaryTags ### Returns - **dict** - Dictionary mapping each tag's 'key' to its 'value', or empty dict if absent ``` -------------------------------- ### get_tags_and_fields_dimensions(endpoint: dict) -> dict Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Parses primaryFields and primaryTags from an endpoint dictionary into a merged dimensions dictionary. ```APIDOC ## get_tags_and_fields_dimensions(endpoint: dict) -> dict ### Description Parse primaryFields and primaryTags from an endpoint dict into a merged dimensions dictionary. ### Parameters - **endpoint** (dict) - Required - The endpoint dictionary containing primaryFields and primaryTags ### Returns - **dict** - Merged dictionary from primaryFields and primaryTags entries ``` -------------------------------- ### dynatrace_extension.Metric.validate() Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/metrics/metric.rst Validates the metric object. ```APIDOC ## dynatrace_extension.Metric.validate() ### Description Validates the metric object. ### Method `validate()` ### Parameters None ### Returns - **bool** - True if the metric is valid, False otherwise. ``` -------------------------------- ### report_dt_event(event_type: DtEventType, title: str, start_time: int | None = None, end_time: int | None = None, timeout: int | None = None, entity_selector: str | None = None, properties: dict[str, str] | None = None) -> None Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/extension.rst Reports an event using the v2 event ingest API. Unlike report_event, this directly raises an event or even a problem based on the specified event_type. ```APIDOC ## report_dt_event(event_type: DtEventType, title: str, start_time: int | None = None, end_time: int | None = None, timeout: int | None = None, entity_selector: str | None = None, properties: dict[str, str] | None = None) -> None ### Description Reports an event using the v2 event ingest API. Unlike report_event, this directly raises an event or even a problem based on the specified event_type. ### Method report_dt_event ### Parameters - **event_type** (DtEventType) - Required - The event type chosen from type Enum - **title** (str) - Required - The title of the event - **start_time** (int | None) - Optional - The start time of event in UTC ms, if not set, current timestamp - **end_time** (int | None) - Optional - The end time of event in UTC ms, if not set, current timestamp + timeout - **timeout** (int | None) - Optional - The timeout of event in minutes, if not set, 15 - **entity_selector** (str | None) - Optional - The entity selector, if not set, the event is associated with environment entity - **properties** (dict[str, str] | None) - Optional - A map of event properties ### Response No return value. ``` -------------------------------- ### dynatrace_extension.MetricType Source: https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/main/docs/api/metrics/metric_type.rst Enum representing the types of metrics that can be sent to Dynatrace. Use this enum to specify the metric type when creating metrics. ```APIDOC ## dynatrace_extension.MetricType ### Description Enum representing the types of metrics that can be sent to Dynatrace. Use this enum to specify the metric type when creating metrics. ### Members - **GAUGE** = 'gauge' - A gauge is a metric that represents a single numerical value that can arbitrarily go up and down. - **COUNT** = 'count' - A counter is a metric that is continuously increasing. - **DELTA** = 'count,delta' - A counter with delta aggregation. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.