Enqueues the passed in data to the queue.
(self, data, context=None)
| 78 | TelemetryChannel.__init__(self, context, queue) |
| 79 | |
| 80 | def write(self, data, context=None): |
| 81 | """ |
| 82 | Enqueues the passed in data to the queue. |
| 83 | """ |
| 84 | local_context = context or self._context |
| 85 | if not local_context: |
| 86 | raise Exception('Context was required but not provided') |
| 87 | |
| 88 | if not data: |
| 89 | raise Exception('Data was required but not provided') |
| 90 | |
| 91 | envelope = contracts.Envelope() |
| 92 | # The only difference in behavior from it's parent class is setting the flag below. |
| 93 | # Suppress Vortex ingest header. |
| 94 | envelope.flags = 0x200000 |
| 95 | envelope.name = data.ENVELOPE_TYPE_NAME |
| 96 | envelope.time = datetime.datetime.utcnow().isoformat() + 'Z' |
| 97 | envelope.ikey = local_context.instrumentation_key |
| 98 | tags = envelope.tags |
| 99 | for key, value in self._write_tags(local_context): |
| 100 | tags[key] = value |
| 101 | envelope.data = contracts.Data() |
| 102 | envelope.data.base_type = data.DATA_TYPE_NAME |
| 103 | if hasattr(data, 'properties') and local_context.properties: |
| 104 | properties = data.properties |
| 105 | if not properties: |
| 106 | properties = {} |
| 107 | data.properties = properties |
| 108 | for key in local_context.properties: |
| 109 | if key not in properties: |
| 110 | properties[key] = local_context.properties[key] |
| 111 | envelope.data.base_data = data |
| 112 | |
| 113 | self._queue.put(envelope) |
| 114 | |
| 115 | |
| 116 | def build_vortex_telemetry_client(service_endpoint_uri): |
no outgoing calls
no test coverage detected