io.opentracing.ActiveSpan Java Examples

The following examples show how to use io.opentracing.ActiveSpan. 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: OpenTracingSQLExecutionHook.java    From shardingsphere with Apache License 2.0 6 votes vote down vote up
@Override
public void start(final String dataSourceName, final String sql, final List<Object> parameters, 
                  final DataSourceMetaData dataSourceMetaData, final boolean isTrunkThread, final Map<String, Object> shardingExecuteDataMap) {
    if (!isTrunkThread) {
        activeSpan = ((ActiveSpan.Continuation) shardingExecuteDataMap.get(OpenTracingRootInvokeHook.ACTIVE_SPAN_CONTINUATION)).activate();
    }
    span = ShardingTracer.get().buildSpan(OPERATION_NAME)
            .withTag(Tags.COMPONENT.getKey(), ShardingTags.COMPONENT_NAME)
            .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
            .withTag(Tags.PEER_HOSTNAME.getKey(), dataSourceMetaData.getHostName())
            .withTag(Tags.PEER_PORT.getKey(), dataSourceMetaData.getPort())
            .withTag(Tags.DB_TYPE.getKey(), "sql")
            .withTag(Tags.DB_INSTANCE.getKey(), dataSourceName)
            .withTag(Tags.DB_STATEMENT.getKey(), sql)
            .withTag(ShardingTags.DB_BIND_VARIABLES.getKey(), toString(parameters)).startManual();
    
}
 
Example #2
Source File: CarManufacturer.java    From Architecting-Modern-Java-EE-Applications with MIT License 5 votes vote down vote up
public Car manufactureCar(Specification spec) {
    try (ActiveSpan span = tracer.buildSpan("createCar")
            .withTag("color", spec.getColor().toString())
            .withTag("engine", spec.getEngine().toString())
            .startActive()) {

        Car car = carFactory.createCar(spec);
        entityManager.merge(car);
        carCreated.fire(new CarCreated(spec));

        span.log("Car successfully created");

        return car;
    }
}
 
Example #3
Source File: OpenTracingSQLExecutionHookTest.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
private ActiveSpan mockActiveSpan() {
    Continuation continuation = mock(Continuation.class);
    ActiveSpan result = mock(ActiveSpan.class);
    when(continuation.activate()).thenReturn(result);
    ExecutorDataMap.getValue().put(OpenTracingRootInvokeHook.ACTIVE_SPAN_CONTINUATION, continuation);
    return result;
}
 
Example #4
Source File: SkywalkingTracer.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public ActiveSpan makeActive(Span span) {
    if (span instanceof SkywalkingSpan) {
        return new SkywalkingActiveSpan((SkywalkingSpan) span);
    } else {
        throw new IllegalArgumentException("span must be a type of SkywalkingSpan");
    }
}
 
Example #5
Source File: SkywalkingContinuation.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@NeedSnifferActivation("1. get ContextSnapshot from the dynamic field" + "2. ContextManager#continued")
@Override
public ActiveSpan activate() {
    SkywalkingSpanBuilder builder = new SkywalkingSpanBuilder("Thread/" + Thread.currentThread().getName());
    return builder.startActive();
}
 
Example #6
Source File: SkywalkingActiveSpan.java    From skywalking with Apache License 2.0 4 votes vote down vote up
/**
 * Don't support logging with payload.
 */
@Deprecated
@Override
public ActiveSpan log(long timestampMicroseconds, String eventName, Object payload) {
    return this;
}
 
Example #7
Source File: SkywalkingActiveSpan.java    From skywalking with Apache License 2.0 4 votes vote down vote up
/**
 * Don't support logging with payload.
 */
@Deprecated
@Override
public ActiveSpan log(String eventName, Object payload) {
    return this;
}
 
Example #8
Source File: SkywalkingActiveSpan.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan setOperationName(String operationName) {
    span.setOperationName(operationName);
    return this;
}
 
Example #9
Source File: SkywalkingActiveSpan.java    From skywalking with Apache License 2.0 4 votes vote down vote up
/**
 * Don't support baggage item.
 */
@Override
public ActiveSpan setBaggageItem(String key, String value) {
    return this;
}
 
Example #10
Source File: SkywalkingActiveSpan.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan log(long timestampMicroseconds, String event) {
    span.log(timestampMicroseconds, event);
    return this;
}
 
Example #11
Source File: SkywalkingActiveSpan.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan log(String event) {
    span.log(event);
    return this;
}
 
Example #12
Source File: SkywalkingActiveSpan.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan log(long timestampMicroseconds, Map<String, ?> fields) {
    span.log(timestampMicroseconds, fields);
    return this;
}
 
Example #13
Source File: SkywalkingActiveSpan.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan log(Map<String, ?> fields) {
    span.log(fields);
    return this;
}
 
Example #14
Source File: SkywalkingActiveSpan.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan setTag(String key, Number value) {
    span.setTag(key, value);
    return this;
}
 
Example #15
Source File: SkywalkingActiveSpan.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan setTag(String key, boolean value) {
    span.setTag(key, value);
    return this;
}
 
Example #16
Source File: SkywalkingActiveSpan.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan setTag(String key, String value) {
    span.setTag(key, value);
    return this;
}
 
Example #17
Source File: SkywalkingSpanBuilder.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan startActive() {
    return new SkywalkingActiveSpan(new SkywalkingSpan(this));
}
 
Example #18
Source File: SkywalkingTracer.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan activeSpan() {
    return new SkywalkingActiveSpan(new SkywalkingSpan(this));
}
 
Example #19
Source File: FooTracer.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan makeActive(final Span span) {
    return null;
}
 
Example #20
Source File: FooTracer.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveSpan activeSpan() {
    return null;
}