def write(self, data, context=None):
        """Enqueues the passed in data to the :func:`queue`. If the caller specifies a context as well, it will
        take precedence over the instance in :func:`context`.

        Args:
            data (object). data the telemetry data to send. This will be wrapped in an :class:`contracts.Envelope`
                before being enqueued to the :func:`queue`.
            context (:class:`TelemetryContext`). context the override context to use when constructing the
                :class:`contracts.Envelope`.
        """
        local_context = context or self._context
        if not local_context:
            raise Exception('Context was required but not provided')

        if not data:
            raise Exception('Data was required but not provided')

        envelope = contracts.Envelope()
        envelope.name = data.ENVELOPE_TYPE_NAME
        envelope.time = datetime.datetime.utcnow().isoformat() + 'Z'
        envelope.ikey = local_context.instrumentation_key
        tags = envelope.tags
        for prop_context in [self._context, context]:
            if not prop_context:
                continue
            for key, value in self._write_tags(prop_context):
                tags[key] = value
        envelope.data = contracts.Data()
        envelope.data.base_type = data.DATA_TYPE_NAME
        for prop_context in [context, self._context]:
            if not prop_context:
                continue
            if hasattr(data, 'properties') and prop_context.properties:
                properties = data.properties
                for key in prop_context.properties:
                    if key not in properties:
                        properties[key] = prop_context.properties[key]
        envelope.data.base_data = data

        self._queue.put(envelope)
def write ( self , data , context = None ) : local_context = context or self . _context if not local_context : raise Exception ( 'Context was required but not provided' ) if not data : raise Exception ( 'Data was required but not provided' ) envelope = contracts . Envelope ( ) envelope . name = data . ENVELOPE_TYPE_NAME envelope . time = datetime . datetime . utcnow ( ) . isoformat ( ) + 'Z' envelope . ikey = local_context . instrumentation_key tags = envelope . tags for prop_context in [ self . _context , context ] : if not prop_context : continue for key , value in self . _write_tags ( prop_context ) : tags [ key ] = value envelope . data = contracts . Data ( ) envelope . data . base_type = data . DATA_TYPE_NAME for prop_context in [ context , self . _context ] : if not prop_context : continue if hasattr ( data , 'properties' ) and prop_context . properties : properties = data . properties for key in prop_context . properties : if key not in properties : properties [ key ] = prop_context . properties [ key ] envelope . data . base_data = data self . _queue . put ( envelope )
Enqueues the passed in data to the :func:`queue`. If the caller specifies a context as well, it will
        take precedence over the instance in :func:`context`.

        Args:
            data (object). data the telemetry data to send. This will be wrapped in an :class:`contracts.Envelope`
                before being enqueued to the :func:`queue`.
            context (:class:`TelemetryContext`). context the override context to use when constructing the
                :class:`contracts.Envelope`.