Search in sources :

Example 6 with Annotation

use of zipkin2.Annotation in project zipkin-gcp by openzipkin.

the class LabelExtractor method extract.

/**
 * Extracts the Stackdriver span labels that are equivalent to the Zipkin Span annotations.
 *
 * @param zipkinSpan The Zipkin Span
 * @return A map of the Stackdriver span labels equivalent to the Zipkin annotations.
 */
Map<String, String> extract(Span zipkinSpan) {
    Map<String, String> result = new LinkedHashMap<>();
    for (Map.Entry<String, String> tag : zipkinSpan.tags().entrySet()) {
        result.put(getLabelName(tag.getKey()), tag.getValue());
    }
    // trace might not show the final destination.
    if (zipkinSpan.localEndpoint() != null && zipkinSpan.kind() == Span.Kind.SERVER) {
        if (zipkinSpan.localEndpoint().ipv4() != null) {
            result.put(getLabelName("endpoint.ipv4"), zipkinSpan.localEndpoint().ipv4());
        }
        if (zipkinSpan.localEndpoint().ipv6() != null) {
            result.put(getLabelName("endpoint.ipv6"), zipkinSpan.localEndpoint().ipv6());
        }
    }
    for (Annotation annotation : zipkinSpan.annotations()) {
        result.put(getLabelName(annotation.value()), formatTimestamp(annotation.timestamp()));
    }
    if (zipkinSpan.localEndpoint() != null && !zipkinSpan.localEndpoint().serviceName().isEmpty()) {
        result.put(kComponentLabelKey, zipkinSpan.localEndpoint().serviceName());
    }
    if (zipkinSpan.parentId() == null) {
        String agentName = System.getProperty("stackdriver.trace.zipkin.agent", "zipkin-java");
        result.put(kAgentLabelKey, agentName);
    }
    return result;
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Annotation(zipkin2.Annotation) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with Annotation

use of zipkin2.Annotation in project libSBOLj by SynBioDex.

the class AnnotationTest method test_toString.

@Test
public void test_toString() throws SBOLValidationException {
    Annotation CD_annot = gRNA_b_gene.createAnnotation(new QName(prURI, "protein", "pr"), true);
    // System.out.println(CD_annot.toString());
    assertTrue(CD_annot.toString().contains("value=" + true));
}
Also used : QName(javax.xml.namespace.QName) Annotation(org.sbolstandard.core2.Annotation) Test(org.junit.Test)

Example 8 with Annotation

use of zipkin2.Annotation in project libSBOLj by SynBioDex.

the class AnnotationOutput method main.

public static void main(String[] args) throws Exception {
    String prURI = "http://partsregistry.org/";
    String prPrefix = "pr";
    SBOLDocument document = new SBOLDocument();
    document.setDefaultURIprefix(prURI);
    document.setTypesInURIs(true);
    document.addNamespace(URI.create(prURI), prPrefix);
    ComponentDefinition promoter = document.createComponentDefinition("BBa_J23119", "", new HashSet<URI>(Arrays.asList(URI.create("http://www.biopax.org/release/biopax-level3.owl#DnaRegion"))));
    promoter.addRole(SequenceOntology.PROMOTER);
    promoter.setName("J23119");
    promoter.setDescription("Constitutive promoter");
    promoter.createAnnotation(new QName(prURI, "group", prPrefix), "iGEM2006_Berkeley");
    promoter.createAnnotation(new QName(prURI, "experience", prPrefix), URI.create("http://parts.igem.org/cgi/partsdb/part_info.cgi?part_name=BBa_J23119"));
    Annotation sigmaFactor = new Annotation(QName(prURI, "sigmafactor", prPrefix), "//rnap/prokaryote/ecoli/sigma70");
    Annotation regulation = new Annotation(QName(prURI, "regulation", prPrefix), "//regulation/constitutive");
    promoter.createAnnotation(new QName(prURI, "information", prPrefix), new QName(prURI, "Information", prPrefix), URI.create("http://partsregistry.org/cd/BBa_J23119/information"), new ArrayList<Annotation>(Arrays.asList(sigmaFactor, regulation)));
    SBOLWriter.write(document, (System.out));
}
Also used : QName(javax.xml.namespace.QName) SBOLDocument(org.sbolstandard.core2.SBOLDocument) URI(java.net.URI) Annotation(org.sbolstandard.core2.Annotation) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Aggregations

Map (java.util.Map)3 QName (javax.xml.namespace.QName)3 Test (org.junit.Test)3 Annotation (org.sbolstandard.core2.Annotation)3 Annotation (zipkin2.Annotation)3 Span (zipkin2.Span)3 URI (java.net.URI)2 LinkedHashMap (java.util.LinkedHashMap)2 Endpoint (zipkin2.Endpoint)2 Tracing (brave.Tracing)1 Platform (brave.internal.Platform)1 TraceContext (brave.propagation.TraceContext)1 Reference (java.lang.ref.Reference)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 After (org.junit.After)1 RunWith (org.junit.runner.RunWith)1