deep.api.resource
Constant values for Resource data.
DEEP_RESOURCE_ATTRIBUTES = 'DEEP_RESOURCE_ATTRIBUTES'
module-attribute
The environment key to find user defined attributes as key value string.
DEEP_SERVICE_NAME = 'DEEP_SERVICE_NAME'
module-attribute
The environment key to define the service name for deep.
PROCESS_EXECUTABLE_NAME = 'process.executable.name'
module-attribute
The name of the process executable. On Linux based systems, can be set to the Name
in
proc/[pid]/status
. On Windows, can be set to the base name of GetProcessImageFileNameW
.
SERVICE_INSTANCE_ID = 'service.instance.id'
module-attribute
The string ID of the service instance.
Note: MUST be unique for each instance of the same service.namespace,service.name
pair (in other words
service.namespace,service.name,service.instance.id
triplet MUST be globally unique). The ID helps to distinguish
instances of the same service that exist at the same time (e.g. instances of a horizontally scaled service). It is
preferable for the ID to be persistent and stay the same for the lifetime of the service instance, however it is
acceptable that the ID is ephemeral and changes during important lifetime events for the service (e.g. service
restarts). If the service has no inherent unique ID that can be used as the value of this attribute it is recommended
to generate a random Version 1 or Version 4 RFC 4122 UUID (services aiming for reproducible UUIDs may also use Version
5, see RFC 4122 for more recommendations).
SERVICE_NAME = 'service.name'
module-attribute
Logical name of the service.
Note: MUST be the same for all instances of horizontally scaled services. If the value was
not specified, SDKs MUST fallback to unknown_service:
concatenated with
process.executable.name
, e.g. unknown_service:bash
. If process.executable.name
is not available, the value MUST be set to unknown_service
.
SERVICE_NAMESPACE = 'service.namespace'
module-attribute
A namespace for service.name
.
Note: A string value having a meaning that helps to distinguish a group of services, for example
the team name that owns a group of services. service.name
is expected to be unique within the same namespace.
If service.namespace
is not specified in the Resource then service.name
is expected to be unique for
all services that have no explicit namespace defined (so the empty/unspecified namespace is simply one more
valid namespace). Zero-length namespace string is assumed equal to unspecified namespace.
SERVICE_VERSION = 'service.version'
module-attribute
The version string of the service API or implementation.
TELEMETRY_AUTO_VERSION = 'telemetry.auto.version'
module-attribute
The version string of the auto instrumentation agent, if used.
TELEMETRY_SDK_LANGUAGE = 'telemetry.sdk.language'
module-attribute
The language of the telemetry SDK.
TELEMETRY_SDK_NAME = 'telemetry.sdk.name'
module-attribute
The name of the telemetry SDK as defined above.
TELEMETRY_SDK_VERSION = 'telemetry.sdk.version'
module-attribute
The version string of the telemetry SDK.
DeepResourceDetector
Bases: ResourceDetector
Detect the resource information for Deep.
Source code in deep/api/resource/__init__.py
detect()
Create a resource from the discovered environment data.
:return: the created resource
Source code in deep/api/resource/__init__.py
Resource
A Resource is an immutable representation of the entity producing telemetry as Attributes.
Source code in deep/api/resource/__init__.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
attributes: BoundedAttributes
property
The underlying attributes for the resource.
schema_url: str
property
The schema url for the resource.
__eq__(other)
Check if other object is equals to this one.
Source code in deep/api/resource/__init__.py
__hash__()
__init__(attributes, schema_url=None)
Create new resource.
:param attributes: the attributes :param schema_url: the schema url
Source code in deep/api/resource/__init__.py
create(attributes=None, schema_url=None)
staticmethod
Create a new Resource
from attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attributes
|
Optional[Attributes]
|
Optional zero or more key-value pairs. |
None
|
schema_url
|
Optional[str]
|
Optional URL pointing to the schema |
None
|
Returns:
Type | Description |
---|---|
Resource
|
The newly-created Resource. |
Source code in deep/api/resource/__init__.py
get_empty()
staticmethod
merge(other)
Merge another resource into this one.
Merges this resource and an updating resource into a new Resource
.
If a key exists on both the old and updating resource, the value of the updating resource will override the old resource value.
The updating resource's schema_url
will be used only if the old
schema_url
is empty. Attempting to merge two resources with
different, non-empty values for schema_url
will result in an error
and return the old resource.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Resource
|
The other resource to be merged. |
required |
Returns:
Type | Description |
---|---|
Resource
|
The newly-created Resource. |
Source code in deep/api/resource/__init__.py
to_json(indent=4)
ResourceDetector
Bases: ABC
Detect the resource information for Deep.
Source code in deep/api/resource/__init__.py
__init__(raise_on_error=False)
Create a new detector.
:param raise_on_error: should raise exception on error
get_aggregated_resources(detectors, initial_resource=None, timeout=5)
Retrieve resources from detectors in the order that they were passed.
:param detectors: List of resources in order of priority :param initial_resource: Static resource. This has the highest priority :param timeout: Number of seconds to wait for each detector to return :return: