Adjust segment service and span interface.

This commit is contained in:
wusheng 2017-06-28 20:40:37 +08:00
parent e09741c832
commit d2f562f1fa
7 changed files with 71 additions and 28 deletions

View File

@ -0,0 +1,10 @@
package org.skywalking.apm.network.trace.component;
/**
* @author wusheng
*/
public interface Component {
int getId();
String getName();
}

View File

@ -0,0 +1,8 @@
package org.skywalking.apm.network.trace.component;
/**
* @author wusheng
*/
public class ComponentsDefine {
public static final OfficialComponent TOMCAT = new OfficialComponent(1, "Tomcat");
}

View File

@ -0,0 +1,24 @@
package org.skywalking.apm.network.trace.component;
/**
* @author wusheng
*/
public class OfficialComponent implements Component{
private int id;
private String name;
public OfficialComponent(int id, String name) {
this.id = id;
this.name = name;
}
@Override
public int getId() {
return id;
}
@Override
public String getName() {
return name;
}
}

View File

@ -38,14 +38,16 @@ message SpanObject {
int64 startTime = 3;
int64 endTime = 4;
int32 operationNameId = 5;
int32 peerId = 6;
string peer = 7;
SpanType spanType = 8;
SpanLayer spanLayer = 9;
string component = 10;
bool isError = 11;
repeated KeyValue tags = 12;
repeated LogMessage logs = 13;
string operationName = 6;
int32 peerId = 7;
string peer = 8;
SpanType spanType = 9;
SpanLayer spanLayer = 10;
int32 componentId = 11;
string component = 12;
bool isError = 13;
repeated KeyValue tags = 14;
repeated LogMessage logs = 15;
}
enum SpanType {

View File

@ -1,18 +0,0 @@
package org.skywalking.apm.agent.core.context.component;
/**
* @author wusheng
*/
public abstract class AbstractComponent {
private int id;
private String name;
protected AbstractComponent(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
}

View File

@ -1,5 +1,6 @@
package org.skywalking.apm.agent.core.context.trace;
import org.skywalking.apm.network.trace.component.Component;
/**
* The <code>AbstractSpan</code> represents the span's skeleton,
@ -8,6 +9,14 @@ package org.skywalking.apm.agent.core.context.trace;
* @author wusheng
*/
public interface AbstractSpan {
/**
* Set the component id, which defines in {@link org.skywalking.apm.network.trace.component.ComponentsDefine}
* @param component
*/
void setComponent(Component component);
void setComponent(String componentName);
void setLayer(SpanLayer layer);
/**

View File

@ -2,10 +2,10 @@ package org.skywalking.apm.agent.core.context.trace;
import java.util.LinkedList;
import java.util.List;
import org.skywalking.apm.agent.core.context.component.AbstractComponent;
import org.skywalking.apm.agent.core.context.util.KeyValuePair;
import org.skywalking.apm.agent.core.context.util.ThrowableTransformer;
import org.skywalking.apm.agent.core.dictionary.DictionaryUtil;
import org.skywalking.apm.network.trace.component.Component;
/**
* The <code>AbstractTracingSpan</code> represents a group of {@link AbstractSpan} implementations,
@ -35,6 +35,8 @@ public abstract class AbstractTracingSpan implements AbstractSpan {
protected int componentId = 0;
protected String componentName;
/**
* Log is a concept from OpenTracing spec.
* <p>
@ -123,7 +125,13 @@ public abstract class AbstractTracingSpan implements AbstractSpan {
this.layer = layer;
}
public void setComponent(AbstractComponent component){
@Override
public void setComponent(Component component) {
this.componentId = component.getId();
}
@Override
public void setComponent(String componentName) {
this.componentName = componentName;
}
}