ads.telemetry package

Submodules

ads.telemetry.telemetry module

class ads.telemetry.telemetry.Surface(value)[source]

Bases: Enum

An Enum class used to label the surface where ADS is being utilized.

DATAFLOW = 5
DATASCIENCE_JOB = 2
DATASCIENCE_MODEL_DEPLOYMENT = 4
DATASCIENCE_NOTEBOOK = 3
DATASCIENCE_PIPELINE = 7
OCI_SERVICE = 6
WORKSTATION = 1
classmethod surface()[source]
class ads.telemetry.telemetry.Telemetry(name: str = '', environ_variable: str = 'EXTRA_USER_AGENT_INFO')[source]

Bases: object

This class is designed to capture a telemetry sequence and store it in the specified environment variable. By default the EXTRA_USER_AGENT_INFO environment variable is used.

name

The name of the telemetry. The very beginning of the telemetry string.

Type:

(str, optional). Default to empty string.

environ_variable

The name of the environment variable to capture the telemetry sequence.

Type:

(str, optional). Defaults to EXTRA_USER_AGENT_INFO.

add(value: str) Telemetry[source]

Appends the new value to the telemetry data.

Parameters:

value (str) – The value that need to be added to the telemetry.

Returns:

self – An instance of the Telemetry.

Return type:

Telemetry

begin(value: str = '') Telemetry[source]

This method should be invoked at the start of telemetry sequence capture. It resets the value of the associated environment variable.

Parameters:

value ((str, optional). Defaults to empty string.) – The value that need to be added to the telemetry.

Returns:

self – An instance of the Telemetry.

Return type:

Telemetry

clean() Telemetry[source]

Cleans the associated environment variable.

Returns:

self – An instance of the Telemetry.

Return type:

Telemetry

environ_variable: str = 'EXTRA_USER_AGENT_INFO'
name: str = ''
print() None[source]

Prints the telemetry sequence from environment variable.

restore() Telemetry[source]

Restores the original value of the environment variable.

Returns:

self – An instance of the Telemetry.

Return type:

Telemetry

ads.telemetry.telemetry.telemetry(entry_point: str = '', name: str = '', environ_variable: str = 'EXTRA_USER_AGENT_INFO') Callable[source]

The telemetry decorator. Injects the Telemetry object into the kwargs arguments of the decorated function. This is essential for adding additional information to the telemetry from within the decorated function. Eventually this information will be merged into the additional_user_agent.

Important Note: The telemetry decorator exclusively updates the specified environment variable and does not perform any additional actions. “

Parameters:
  • entry_point (str) – The entry point of the telemetry. Example: “plugin=project&action=run”

  • name (str) – The name of the telemetry.

  • environ_variable ((str, optional). Defaults to EXTRA_USER_AGENT_INFO.) – The name of the environment variable to capture the telemetry sequence.

Examples

>>> @telemetry(entry_point="plugin=project&action=run", name="ads")
... def test_function(**kwargs)
...     telemetry = kwargs.get("telemetry")
...     telemetry.add("param=hello_world")
...     print(telemetry)
>>> test_function()
... "ads&plugin=project&action=run&param=hello_world"
ads.telemetry.telemetry.update_oci_client_config(config: Dict[str, Any] | None = None) Dict[str, Any][source]

Adds user agent information to the signer config if it is not setup yet.

Parameters:

config (Dict) – The signer configuration.

Returns:

The updated configuration.

Return type:

Dict

Module contents