def test_can_override_tracing_options(self): timeout = timedelta(seconds=50) timeout2 = timedelta(seconds=100) opts = self._create_cluster_opts( tracing_options=ClusterTracingOptions(tracing_orphaned_queue_flush_interval=timeout)) args = self._mock_hack() args.update({'tracing_options': ClusterTracingOptions(tracing_orphaned_queue_flush_interval=timeout2)}) cluster = Cluster.connect(self.cluster.connstr, opts, **args) self.assertEqual(timeout2, cluster.tracing_orphaned_queue_flush_interval) b = cluster.bucket(self.bucket_name) self.assertEqual(timeout2, b.tracing_orphaned_queue_flush_interval)
def test_tracing_threshold_analytics(self): timeout = timedelta(seconds=0.3) opt = ClusterTracingOptions(tracing_threshold_analytics=timeout) opts = self._create_cluster_opts(tracing_options=opt) cluster = Cluster.connect(self.cluster.connstr, opts, **self._mock_hack()) self.assertEqual(timeout, cluster.tracing_threshold_analytics)
def test_tracing_threshold_queue_size(self): size = 100 opt = ClusterTracingOptions(tracing_threshold_queue_size=size) opts = self._create_cluster_opts(tracing_options=opt) cluster = Cluster.connect(self.cluster.connstr, opts, **self._mock_hack()) self.assertEqual(size, cluster.tracing_threshold_queue_size) b = cluster.bucket(self.bucket_name) self.assertEqual(size, b.tracing_threshold_queue_size)
def test_tracing_threshold_queue_flush_interval(self): timeout = timedelta(seconds=10) opt = ClusterTracingOptions(tracing_threshold_queue_flush_interval=timeout) opts = self._create_cluster_opts(tracing_options=opt) cluster = Cluster.connect(self.cluster.connstr, opts, **self._mock_hack()) self.assertEqual(timeout, cluster.tracing_threshold_queue_flush_interval) b = cluster.bucket(self.bucket_name) self.assertEqual(timeout, b.tracing_threshold_queue_flush_interval)
def setUp(self, trace_all=True, flushcount=0, enable_logging=False, use_parent_tracer=False, *args, **kwargs): self.timeout = None # self.enable_logging = enable_logging or os.environ.get("PYCBC_ENABLE_LOGGING") self.use_parent_tracer = use_parent_tracer self.using_jaeger = (os.environ.get("PYCBC_USE_JAEGER") == "TRUE") self.flushdict = { k: v for k, v in zip(map(str, range(1, 100)), map(str, range(1, 100))) } self.trace_all = os.environ.get("PYCBC_TRACE_ALL") or trace_all self.flushcount = flushcount if self.using_jaeger and self.flushcount > 5: raise SkipTest("too slow when using jaeger") enable_logging |= bool(self.trace_all) if enable_logging: couchbase.enable_logging() if self.use_parent_tracer: kwargs['init_tracer'] = self.init_tracer kwargs['enable_tracing'] = "true" if self.trace_all: tracing_options = ClusterTracingOptions( tracing_orphaned_queue_flush_interval=timedelta( milliseconds=1), tracing_orphaned_queue_size=9, tracing_threshold_queue_flush_interval=timedelta( milliseconds=1), tracing_threshold_queue_size=9, tracing_threshold_kv=timedelta(milliseconds=1), #tracing_threshold_query=timedelta(milliseconds=1), tracing_threshold_view=timedelta(milliseconds=1), tracing_threshold_search=timedelta(milliseconds=1), tracing_threshold_analytics=timedelta(milliseconds=1)) dummy_auth = PasswordAuthenticator("default", "password") # the dummy_auth isn't really used, the base class decides between classic # and password dependng on mock or not. opts = ClusterOptions(authenticator=dummy_auth, tracing_options=tracing_options) kwargs["cluster_options"] = opts super(TracedCase, self).setUp(**kwargs)
from couchbase.cluster import Cluster, ClusterOptions, ClusterTracingOptions from couchbase.auth import PasswordAuthenticator from couchbase import enable_logging # NOTE: for simple test to see output, drop the threshold # ex: tracing_threshold_kv=timedelta(microseconds=1) # tag::threshold_logging_config[] # configure logging logging.basicConfig(stream=sys.stderr, level=logging.INFO) # setup couchbase logging enable_logging() tracing_opts = ClusterTracingOptions( tracing_threshold_queue_size=10, tracing_threshold_kv=timedelta(milliseconds=500)) cluster_opts = ClusterOptions(authenticator=PasswordAuthenticator( "Administrator", "password"), tracing_options=tracing_opts) cluster = Cluster( "couchbase://localhost", options=cluster_opts ) # end::threshold_logging_config[] collection = cluster.bucket("beer-sample").default_collection()
import sys from couchbase.cluster import Cluster, ClusterOptions, ClusterTracingOptions from couchbase.auth import PasswordAuthenticator from couchbase.exceptions import TimeoutException from couchbase import enable_logging # tag::orphan_logging_config[] # configure logging logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) # setup couchbase logging enable_logging() tracing_opts = ClusterTracingOptions( # report interval tracing_orphaned_queue_flush_interval=timedelta(minutes=1), # sample size tracing_orphaned_queue_size=10) cluster_opts = ClusterOptions(authenticator=PasswordAuthenticator( "Administrator", "password"), tracing_options=tracing_opts) cluster = Cluster("couchbase://localhost", options=cluster_opts) # end::orphan_logging_config[] collection = cluster.bucket("beer-sample").default_collection() for _ in range(100): try: # set timeout low to see orphan response collection.get("21st_amendment_brewery_cafe",