Get trace_id from flask request headers.

    :rtype: str
    :returns: TraceID in HTTP request headers.
762168
def get_trace_id_from_flask():
    
    if flask is None or not flask.request:
        return None

    header = flask.request.headers.get(_FLASK_TRACE_HEADER)

    if header is None:
        return None

    trace_id = header.split("/", 1)[0]

    return trace_id
10379
def get_request_token(self):
        
        
        if self._request_token is None:
            self._request_token = self._get_request_token()
        return self._request_token
1350829
def make_context(headers: Headers) -> Optional[TraceContext]:
    
    # TODO: add validation for trace_id/span_id/parent_id

    # normalize header names just in case someone passed regular dict
    # instead dict with case insensitive keys
    headers = {k.lower(): v for k, v in headers.items()}

    required = (TRACE_ID_HEADER.lower(), SPAN_ID_HEADER.lower())
    has_b3 = all(h in headers for h in required)
    has_b3_single = SINGLE_HEADER in headers

    if not(has_b3_single or has_b3):
        return None

    if has_b3:
        debug = parse_debug_header(headers)
        sampled = debug if debug else parse_sampled_header(headers)
        context = TraceContext(
            trace_id=headers[TRACE_ID_HEADER.lower()],
            parent_id=headers.get(PARENT_ID_HEADER.lower()),
            span_id=headers[SPAN_ID_HEADER.lower()],
            sampled=sampled,
            debug=debug,
            shared=False,
        )
        return context
    return _parse_single_header(headers)
717052
def getTraceCombosByIds(self, trace_ids, adjust):
    
    self.send_getTraceCombosByIds(trace_ids, adjust)
    return self.recv_getTraceCombosByIds()
150185
def _CaptureRequestLogId(self):
    
    # pylint: disable=not-callable
    if callable(request_log_id_collector):
      request_log_id = request_log_id_collector()
      if request_log_id:
        # We have a request_log_id, save it into the breakpoint labels
        self.breakpoint['labels'][
            labels.Breakpoint.REQUEST_LOG_ID] = request_log_id
621100
def get_gae_labels(self):
        
        gae_labels = {}

        trace_id = get_trace_id()
        if trace_id is not None:
            gae_labels[_TRACE_ID_LABEL] = trace_id

        return gae_labels
1098062
def with_debug_id(debug_id):
        """"""
        ctx = SpanContext(
            trace_id=None, span_id=None, parent_id=None, flags=None
        )
        ctx._debug_id = debug_id
        return ctx
651451
def trace_api(self):
        
        if self._trace_api is None:
            self._trace_api = make_trace_api(self)
        return self._trace_api
1156467
def getRequest(self, id_):
        
        for request in self.requests:
            if request.id == id_:
                return request

        raise LookupError("Request %r not found" % (id_,))
696200
def trace_inspect(self):
        
        def decorator(f):
            self.tracer.inspector = f
            return f
        return decorator
837607
def trace_next_query(self, ):
    
    self._seqid += 1
    d = self._reqs[self._seqid] = defer.Deferred()
    self.send_trace_next_query()
    return d
78685
def _get_traceback_no_io():
    
    try:
        module = load_module(str("_traceback_no_io"), traceback)
    except NotImplementedError:
        # Can't fix the I/O problem, oh well:
        return traceback

    class FakeLineCache(object):
        def checkcache(self, *args, **kwargs):
            None

        def getline(self, *args, **kwargs):
            return ""

        def lazycache(self, *args, **kwargs):
            return None

    module.linecache = FakeLineCache()
    return module
1120280
def id_request(self):
        """"""
        import inspect
        curframe = inspect.currentframe()
        calframe = inspect.getouterframes(curframe, 2)
        _LOGGER.debug('caller name: %s', calframe[1][3])
        msg = StandardSend(self.address, COMMAND_ID_REQUEST_0X10_0X00)
        self._plm.send_msg(msg)
1048791
def trace(queue_names=self.queues.keys, tracer=nil, &block)
      queues_to_trace = self.queues.slice(*queue_names)
      queues_to_trace.each do |name, opts|
        opts.merge! :durable => false, :auto_delete => true, :amqp_name => queue_name_for_tracing(opts[:amqp_name])
      end
      tracer ||=
        lambda do |msg|
          puts "-----===== new message =====-----"
          puts "SERVER: #{msg.server}"
          puts "HEADER: #{msg.header.attributes[:headers].inspect}"
          puts "EXCHANGE: #{msg.header.method.exchange}"
          puts "KEY: #{msg.header.method.routing_key}"
          puts "MSGID: #{msg.msg_id}"
          puts "DATA: #{msg.data}"
        end
      register_handler(queue_names){|msg| tracer.call msg }
      listen_queues(queue_names, &block)
    end
154708
def to_id(self):
        
        return "%s%s%s%s%s" % (TraceId.VERSION, TraceId.DELIMITER,
                               format(self.start_time, 'x'),
                               TraceId.DELIMITER, self.__number)
876388
def getTracesByIds(self, trace_ids, adjust):
    
    self.send_getTracesByIds(trace_ids, adjust)
    return self.recv_getTracesByIds()
1066327
def get_request_headers(self):
        
        request_headers = self.get_proxy_request_headers(self.request)

        if (self.add_remote_user and hasattr(self.request, 'user')
                and self.request.user.is_active):
            request_headers['REMOTE_USER'] = self.request.user.get_username()
            self.log.info("REMOTE_USER set")

        return request_headers