Java Code Examples for io.opentracing.tag.Tags#SPAN_KIND_SERVER
The following examples show how to use
io.opentracing.tag.Tags#SPAN_KIND_SERVER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpringWebSocketAgentIntercept.java From java-specialagent with Apache License 2.0 | 6 votes |
public static void messageChannelSend(final Object thiz) { final AbstractMessageChannel channel = (AbstractMessageChannel)thiz; for (final ChannelInterceptor interceptor : channel.getInterceptors()) if (interceptor instanceof TracingChannelInterceptor) return; final TracingChannelInterceptor tracingChannelInterceptor; if (channel.getBeanName().equals("clientOutboundChannel")) tracingChannelInterceptor = new TracingChannelInterceptor(GlobalTracer.get(), Tags.SPAN_KIND_CLIENT); else if (channel.getBeanName().equals("clientInboundChannel")) tracingChannelInterceptor = new TracingChannelInterceptor(GlobalTracer.get(), Tags.SPAN_KIND_SERVER); else return; channel.addInterceptor(tracingChannelInterceptor); }
Example 2
Source File: TracingChannelInterceptorTest.java From java-spring-cloud with Apache License 2.0 | 6 votes |
@Test public void testPreSendServerSpan() { MessageBuilder<String> messageBuilder = MessageBuilder.withPayload("Hi") .setHeader(TracingChannelInterceptor.SIMP_MESSAGE_TYPE, SimpMessageType.MESSAGE) .setHeader(TracingChannelInterceptor.SIMP_DESTINATION, TEST_DESTINATION); MockSpan parentSpan = mockTracer.buildSpan("parent").start(); mockTracer.inject(parentSpan.context(), Format.Builtin.TEXT_MAP, new TextMapInjectAdapter(messageBuilder)); TracingChannelInterceptor interceptor = new TracingChannelInterceptor(mockTracer, Tags.SPAN_KIND_SERVER); Message<?> processed = interceptor.preSend(messageBuilder.build(), null); // Verify span cached with message is child of propagated parentSpan span context assertTrue(processed.getHeaders().containsKey(TracingChannelInterceptor.OPENTRACING_SPAN)); MockSpan childSpan = (MockSpan) processed.getHeaders() .get(TracingChannelInterceptor.OPENTRACING_SPAN); assertEquals(parentSpan.context().spanId(), childSpan.parentId()); assertEquals(parentSpan.context().traceId(), childSpan.context().traceId()); assertEquals(TEST_DESTINATION, childSpan.operationName()); assertEquals(Tags.SPAN_KIND_SERVER, childSpan.tags().get(Tags.SPAN_KIND.getKey())); assertEquals(TracingChannelInterceptor.WEBSOCKET, childSpan.tags().get(Tags.COMPONENT.getKey())); }
Example 3
Source File: SpanBuilderShim.java From opentelemetry-java with Apache License 2.0 | 5 votes |
@Override public SpanBuilder withTag(String key, String value) { if (Tags.SPAN_KIND.getKey().equals(key)) { switch (value) { case Tags.SPAN_KIND_CLIENT: spanKind = Kind.CLIENT; break; case Tags.SPAN_KIND_SERVER: spanKind = Kind.SERVER; break; case Tags.SPAN_KIND_PRODUCER: spanKind = Kind.PRODUCER; break; case Tags.SPAN_KIND_CONSUMER: spanKind = Kind.CONSUMER; break; default: spanKind = Kind.INTERNAL; break; } } else if (Tags.ERROR.getKey().equals(key)) { error = Boolean.parseBoolean(value); } else { this.spanBuilderAttributeKeys.add(key); this.spanBuilderAttributeValues.add(AttributeValue.stringAttributeValue(value)); } return this; }
Example 4
Source File: WebsocketAutoConfiguration.java From java-spring-cloud with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnBean(WebSocketMessageBrokerConfigurationSupport.class) public TracingChannelInterceptor tracingInboundChannelInterceptor( WebSocketMessageBrokerConfigurationSupport config) { TracingChannelInterceptor interceptor = new TracingChannelInterceptor(tracer, Tags.SPAN_KIND_SERVER); config.clientInboundChannel().addInterceptor(interceptor); return interceptor; }
Example 5
Source File: OpenTracing0_33_BraveSpanTest.java From brave-opentracing with Apache License 2.0 | 5 votes |
@DataProvider public static Object[][] dataProviderKind() { return new Object[][] { {Tags.SPAN_KIND_CLIENT, Kind.CLIENT}, {Tags.SPAN_KIND_SERVER, Kind.SERVER}, {Tags.SPAN_KIND_PRODUCER, Kind.PRODUCER}, {Tags.SPAN_KIND_CONSUMER, Kind.CONSUMER} }; }
Example 6
Source File: DubboSofaTracerFilter.java From sofa-tracer with Apache License 2.0 | 4 votes |
private String spanKind(RpcContext rpcContext) { return rpcContext.isConsumerSide() ? Tags.SPAN_KIND_CLIENT : Tags.SPAN_KIND_SERVER; }
Example 7
Source File: DubboSofaTracerFilter.java From sofa-tracer with Apache License 2.0 | 4 votes |
private String spanKind(RpcContext rpcContext) { return rpcContext.isConsumerSide() ? Tags.SPAN_KIND_CLIENT : Tags.SPAN_KIND_SERVER; }