本文整理匯總了Python中opentracing.ext.tags.COMPONENT屬性的典型用法代碼示例。如果您正苦於以下問題:Python tags.COMPONENT屬性的具體用法?Python tags.COMPONENT怎麽用?Python tags.COMPONENT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類opentracing.ext.tags
的用法示例。
在下文中一共展示了tags.COMPONENT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: resolve
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def resolve(
self, next_: Resolver, parent: Any, info: GraphQLResolveInfo, **kwargs
): # pylint: disable=invalid-overridden-method
if not should_trace(info):
result = next_(parent, info, **kwargs)
return result
with self._tracer.start_active_span(info.field_name) as scope:
span = scope.span
span.set_tag(tags.COMPONENT, "graphql")
span.set_tag("graphql.parentType", info.parent_type.name)
graphql_path = ".".join(
map(str, format_path(info.path)) # pylint: disable=bad-builtin
)
span.set_tag("graphql.path", graphql_path)
if kwargs:
filtered_kwargs = self.filter_resolver_args(kwargs, info)
for kwarg, value in filtered_kwargs.items():
span.set_tag(f"graphql.param.{kwarg}", value)
result = next_(parent, info, **kwargs)
return result
示例2: complex
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def complex(request):
with opentracing.tracer.start_active_span('asteroid') as pscope:
pscope.span.set_tag(ext.COMPONENT, "Python simple example app")
pscope.span.set_tag(ext.SPAN_KIND, ext.SPAN_KIND_RPC_SERVER)
pscope.span.set_tag(ext.PEER_HOSTNAME, "localhost")
pscope.span.set_tag(ext.HTTP_URL, "/python/simple/one")
pscope.span.set_tag(ext.HTTP_METHOD, "GET")
pscope.span.set_tag(ext.HTTP_STATUS_CODE, 200)
pscope.span.log_kv({"foo": "bar"})
time.sleep(.2)
with opentracing.tracer.start_active_span('spacedust', child_of=pscope.span) as cscope:
cscope.span.set_tag(ext.SPAN_KIND, ext.SPAN_KIND_RPC_CLIENT)
cscope.span.set_tag(ext.PEER_HOSTNAME, "localhost")
cscope.span.set_tag(ext.HTTP_URL, "/python/simple/two")
cscope.span.set_tag(ext.HTTP_METHOD, "POST")
cscope.span.set_tag(ext.HTTP_STATUS_CODE, 204)
cscope.span.set_baggage_item("someBaggage", "someValue")
time.sleep(.1)
return HttpResponse('Stan wuz here!')
示例3: _start_span
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def _start_span(self, servicer_context, method):
span_context = None
error = None
metadata = servicer_context.invocation_metadata()
try:
if metadata:
span_context = self._tracer.extract(
opentracing.Format.HTTP_HEADERS, dict(metadata))
except (opentracing.UnsupportedFormatException,
opentracing.InvalidCarrierException,
opentracing.SpanContextCorruptedException) as e:
logging.exception('tracer.extract() failed')
error = e
tags = {
ot_tags.COMPONENT: 'grpc',
ot_tags.SPAN_KIND: ot_tags.SPAN_KIND_RPC_SERVER
}
_add_peer_tags(servicer_context.peer(), tags)
span = self._tracer.start_span(
operation_name=method, child_of=span_context, tags=tags)
if error is not None:
span.log_kv({'event': 'error', 'error.object': error})
return span
示例4: perform_call
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def perform_call(self, original_func, kind, service_name, operation_name,
*args, **kwargs):
span = utils.start_child_span(
operation_name='boto3:{}:{}:{}'.format(
kind, service_name, operation_name
),
parent=get_current_span()
)
span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_CLIENT)
span.set_tag(tags.COMPONENT, 'boto3')
span.set_tag('boto3.service_name', service_name)
with span, span_in_stack_context(span):
try:
response = original_func(*args, **kwargs)
except ClientError as error:
self.set_request_id_tag(span, error.response)
raise
else:
if isinstance(response, dict):
self.set_request_id_tag(span, response)
return response
示例5: test_opentracing_extension_sets_graphql_component_tag_on_root_span
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def test_opentracing_extension_sets_graphql_component_tag_on_root_span(
schema, active_span_mock
):
graphql(
schema,
{"query": '{ status hello(name: "Bob") }'},
extensions=[OpenTracingExtension],
)
active_span_mock.span.set_tag.assert_called_once_with(tags.COMPONENT, "graphql")
示例6: test_opentracing_extension_sets_graphql_component_tag_on_root_span
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def test_opentracing_extension_sets_graphql_component_tag_on_root_span(
schema, active_span_mock
):
await graphql(
schema,
{"query": '{ status hello(name: "Bob") }'},
extensions=[OpenTracingExtension],
)
active_span_mock.span.set_tag.assert_called_once_with(tags.COMPONENT, "graphql")
示例7: request_started
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def request_started(self, context: ContextValue):
self._root_scope = self._tracer.start_active_span("GraphQL Query")
self._root_scope.span.set_tag(tags.COMPONENT, "graphql")
示例8: _before_request_fn
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def _before_request_fn(self, attributes):
request = stack.top.request
operation_name = request.endpoint
headers = {}
for k, v in request.headers:
headers[k.lower()] = v
try:
span_ctx = self.tracer.extract(opentracing.Format.HTTP_HEADERS,
headers)
scope = self.tracer.start_active_span(operation_name,
child_of=span_ctx)
except (opentracing.InvalidCarrierException,
opentracing.SpanContextCorruptedException):
scope = self.tracer.start_active_span(operation_name)
self._current_scopes[request] = scope
span = scope.span
span.set_tag(tags.COMPONENT, 'Flask')
span.set_tag(tags.HTTP_METHOD, request.method)
span.set_tag(tags.HTTP_URL, request.base_url)
span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_SERVER)
for attr in attributes:
if hasattr(request, attr):
payload = getattr(request, attr)
if payload not in ('', b''): # python3
span.set_tag(attr, str(payload))
self._call_start_span_cb(span, request)
示例9: test_span_tags
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def test_span_tags(self):
test_app.get('/another_test_simple')
spans = tracing._tracer.finished_spans()
assert len(spans) == 1
assert spans[0].tags == {
tags.COMPONENT: 'Flask',
tags.HTTP_METHOD: 'GET',
tags.SPAN_KIND: tags.SPAN_KIND_RPC_SERVER,
tags.HTTP_URL: 'http://localhost/another_test_simple',
'is_xhr': 'False',
}
示例10: test_simple
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def test_simple(self):
def start_span_cb(span, request):
span.set_tag('component', 'not-flask')
span.set_tag('mytag', 'myvalue')
tracing = FlaskTracing(MockTracer(), True, app,
start_span_cb=start_span_cb)
rv = test_app.get('/test')
assert '200' in str(rv.status_code)
spans = tracing.tracer.finished_spans()
assert len(spans) == 1
assert spans[0].tags.get(tags.COMPONENT, None) == 'not-flask'
assert spans[0].tags.get('mytag', None) == 'myvalue'
示例11: _start_span
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def _start_span(self, method):
active_span_context = None
if self._active_span_source is not None:
active_span = self._active_span_source.get_active_span()
if active_span is not None:
active_span_context = active_span.context
tags = {
ot_tags.COMPONENT: 'grpc',
ot_tags.SPAN_KIND: ot_tags.SPAN_KIND_RPC_CLIENT
}
return self._tracer.start_span(
operation_name=method, child_of=active_span_context, tags=tags)
示例12: set_common_tags
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def set_common_tags(span, task, span_kind):
span.set_tag(tags.SPAN_KIND, span_kind)
span.set_tag(tags.COMPONENT, 'Celery')
span.set_tag('celery.task_name', task.name)
示例13: assert_span
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def assert_span(span, result, operation, span_kind):
assert span.operation_name == 'Celery:{}:foo'.format(operation)
assert span.tags.get(tags.SPAN_KIND) == span_kind
assert span.tags.get(tags.COMPONENT) == 'Celery'
assert span.tags.get('celery.task_name') == 'foo'
assert span.tags.get('celery.task_id') == result.task_id
示例14: assert_last_span
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def assert_last_span(kind, service_name, operation, tracer, response=None):
span = tracer.recorder.get_spans()[-1]
request_id = response and response['ResponseMetadata'].get('RequestId')
assert span.operation_name == 'boto3:{}:{}:{}'.format(
kind, service_name, operation
)
assert span.tags.get(tags.SPAN_KIND) == tags.SPAN_KIND_RPC_CLIENT
assert span.tags.get(tags.COMPONENT) == 'boto3'
assert span.tags.get('boto3.service_name') == service_name
if request_id:
assert span.tags.get('aws.request_id') == request_id
示例15: assert_span
# 需要導入模塊: from opentracing.ext import tags [as 別名]
# 或者: from opentracing.ext.tags import COMPONENT [as 別名]
def assert_span(span, operation):
assert span.operation_name == 'SQL ' + operation
assert span.tags.get(tags.SPAN_KIND) == tags.SPAN_KIND_RPC_CLIENT
assert span.tags.get(tags.DATABASE_TYPE) == 'sqlite'
assert span.tags.get(tags.DATABASE_INSTANCE) == 'sqlite://'
assert span.tags.get(tags.COMPONENT) == 'sqlalchemy'