예제 #1
0
 def setUp(self):
     self.exporter = CapturingExporter()
     self.tracer = tracer_module.Tracer(
         sampler=AlwaysOnSampler(),
         exporter=self.exporter,
         propagator=GoogleCloudFormatPropagator())
     config_integration.trace_integrations(['redis'], tracer=self.tracer)
     self.client = redis.StrictRedis()
    def setUp(self):
        super(TestClient, self).setUp()
        self.exporter = CapturingExporter()
        self.tracer = tracer_module.Tracer(
            sampler=AlwaysOnSampler(),
            exporter=self.exporter,
            propagator=GoogleCloudFormatPropagator())

        config_integration.trace_integrations(['tornado_httpclient'],
                                              tracer=self.tracer)
    def setUp(self):
        super(TestClient, self).setUp()
        self.exporter = CapturingExporter()
        self.tracer = tracer_module.Tracer(
            sampler=AlwaysOnSampler(),
            exporter=self.exporter,
            propagator=GoogleCloudFormatPropagator())

        self.stack_context = tracer_stack_context()
        self.stack_context.__enter__()
        execution_context.set_opencensus_tracer(self.tracer)
예제 #4
0
    def setUp(self):
        self.exporter = CapturingExporter()
        self.tracer = tracer_module.Tracer(
            sampler=AlwaysOnSampler(),
            exporter=self.exporter,
            propagator=GoogleCloudFormatPropagator()
        )

        config_integration.trace_integrations(['redis'], tracer=self.tracer)

        self.client = redis.StrictRedis()

        # Stash away the original methods for
        # after-test restoration.
        self._execute_command = redis.StrictRedis.execute_command
        self._pipeline = redis.StrictRedis.pipeline
 def initialize(
     self,
     schema=None,
     middleware: Optional[Any] = None,
     root_value: Any = None,
     graphiql: bool = False,
     pretty: bool = False,
     batch: bool = False,
     extensions: List[Union[Callable[[], GraphQLExtension],
                            GraphQLExtension]] = None,
     exporter=None,
 ):
     super().initialize(schema, middleware, root_value, graphiql, pretty,
                        batch, extensions)
     execution_context.set_opencensus_tracer(
         tracer_module.Tracer(
             sampler=AlwaysOnSampler(),
             exporter=exporter,
             propagator=GoogleCloudFormatPropagator(),
         ))
예제 #6
0
def exporter():
    exporter = CapturingExporter()
    tracer_module.Tracer(sampler=AlwaysOnSampler(),
                         exporter=exporter,
                         propagator=GoogleCloudFormatPropagator())
    return exporter
예제 #7
0
"""
Base module for flask_trace_util
"""
from opencensus.common.transports.async_ import AsyncTransport
from opencensus.ext.stackdriver.trace_exporter import StackdriverExporter
from opencensus.trace.propagation.google_cloud_format import GoogleCloudFormatPropagator
from opencensus.trace.tracer import Tracer
from opencensus.trace.samplers import AlwaysOnSampler
from flask import request
from .flask_trace import FlaskTrace
from .util import GcloudJsonFormatter, get_gcloud_project_id


propogator = GoogleCloudFormatPropagator()


def gcloud_trace_extractor():
    return request.headers.get("X-Cloud-Trace-Context")


exporter = None
try:
    exporter = StackdriverExporter()
except:
    pass


def gcloud_opencensus_tracer_generator(trace):
    span_context = propogator.from_header(trace)
    tracer = Tracer(
        exporter=exporter, span_context=span_context, sampler=AlwaysOnSampler()