Search in sources :

Example 1 with Component

use of zipkin2.Component in project spring-cloud-gcp by spring-cloud.

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.
 */
public Map<String, String> extract(Span zipkinSpan) {
    Map<String, String> result = new LinkedHashMap<>();
    for (Map.Entry<String, String> tag : zipkinSpan.tags().entrySet()) {
        result.put(label(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(label("endpoint.ipv4"), zipkinSpan.localEndpoint().ipv4());
        }
        if (zipkinSpan.localEndpoint().ipv6() != null) {
            result.put(label("endpoint.ipv6"), zipkinSpan.localEndpoint().ipv6());
        }
    }
    for (Annotation annotation : zipkinSpan.annotations()) {
        result.put(label(annotation.value()), formatTimestamp(annotation.timestamp()));
    }
    if (zipkinSpan.localEndpoint() != null && !zipkinSpan.localEndpoint().serviceName().isEmpty()) {
        result.put("/component", zipkinSpan.localEndpoint().serviceName());
    }
    if (zipkinSpan.parentId() == null) {
        String agentName = System.getProperty("stackdriver.trace.zipkin.agent", "spring-cloud-gcp-trace");
        result.put("/agent", agentName);
    }
    return result;
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashMap(java.util.HashMap) Annotation(zipkin2.Annotation) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with Component

use of zipkin2.Component in project spring-cloud-gcp by spring-cloud.

the class LabelExtractorTests method testRpcClientBasics.

@Test
public void testRpcClientBasics() {
    LabelExtractor extractor = new LabelExtractor();
    String instanceId = "localhost";
    long begin = 1238912378081L;
    long end = 1238912378123L;
    Span span = Span.newBuilder().traceId("123").id("9999").timestamp(begin).duration(end - begin).putTag("http.host", "localhost").putTag("custom-tag", "hello").localEndpoint(Endpoint.newBuilder().serviceName("hello-service").build()).build();
    Map<String, String> labels = extractor.extract(span);
    Assert.assertNotNull("span shouldn't be null", span);
    Assert.assertEquals("localhost", labels.get("/http/host"));
    Assert.assertEquals("spring-cloud-gcp-trace", labels.get("/agent"));
    Assert.assertEquals("hello-service", labels.get("/component"));
    Assert.assertEquals("hello", labels.get("cloud.spring.io/custom-tag"));
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 3 with Component

use of zipkin2.Component in project powerbot by powerbot.

the class DrawAbilities method repaint.

@Override
public void repaint(final Graphics render) {
    if (!ctx.game.loggedIn()) {
        return;
    }
    render.setFont(new Font("Arial", 0, 10));
    render.setColor(Color.green);
    for (final Action action : ctx.combatBar.actions()) {
        final Component c = action.component();
        final Point p = c.screenPoint();
        render.drawString(action.id() + " (" + action.bind() + ")", p.x, p.y);
    }
}
Also used : Action(org.powerbot.script.rt6.Action) Point(java.awt.Point) Component(org.powerbot.script.rt6.Component) Font(java.awt.Font)

Example 4 with Component

use of zipkin2.Component in project powerbot by powerbot.

the class DrawBoundaries method repaint.

@Override
public void repaint(final Graphics render) {
    if (!ctx.game.loggedIn()) {
        return;
    }
    final Client client = ctx.client();
    final RelativeLocation r = ctx.players.local().relative();
    final float rx = r.x();
    final float ry = r.z();
    final Component component = ctx.game.mapComponent();
    final int w = component.scrollWidth();
    final int h = component.scrollHeight();
    final int radius = Math.max(w / 2, h / 2) + 10;
    final boolean f = client.getMinimapSettings() == client.reflector.getConstant("V_MINIMAP_SCALE_ON_VALUE");
    final double a = ctx.camera.rotation() * 16384d / (Math.PI * 2d);
    int i = 0x3fff & (int) a;
    if (!f) {
        i = 0x3fff & client.getMinimapOffset() + (int) a;
    }
    int sin = Game.SIN_TABLE[i], cos = Game.COS_TABLE[i];
    if (!f) {
        final int scale = 256 + client.getMinimapScale();
        sin = 256 * sin / scale;
        cos = 256 * cos / scale;
    }
    final CollisionMap map = ctx.movement.collisionMap();
    final int mapWidth = map.width() - 6;
    final int mapHeight = map.height() - 6;
    final Point[][] points = new Point[mapWidth][mapHeight];
    final Point sp = component.screenPoint();
    for (int x = 0; x < mapWidth; ++x) {
        for (int y = 0; y < mapHeight; ++y) {
            Point p = map(x, y, rx, ry, w, h, radius, sin, cos, sp);
            if (p.x == -1 || p.y == -1) {
                p = null;
            }
            points[x][y] = p;
        }
    }
    final CollisionFlag collisionFlag = CollisionFlag.DEAD_BLOCK.mark(CollisionFlag.OBJECT_BLOCK);
    for (int x = 1; x < mapWidth - 1; ++x) {
        for (int y = 1; y < mapHeight - 1; ++y) {
            final Point tl = points[x][y];
            final Point tr = points[x + 1][y];
            final Point br = points[x + 1][y + 1];
            final Point bl = points[x][y + 1];
            if (tl != null && tr != null && br != null && bl != null) {
                render.setColor(map.flagAt(x, y).contains(collisionFlag) ? new Color(255, 0, 0, 50) : new Color(0, 255, 0, 50));
                render.fillPolygon(new int[] { tl.x, tr.x, br.x, bl.x }, new int[] { tl.y, tr.y, br.y, bl.y }, 4);
            }
        }
    }
}
Also used : RelativeLocation(org.powerbot.script.rt6.RelativeLocation) CollisionFlag(org.powerbot.script.rt6.CollisionFlag) Color(java.awt.Color) Point(java.awt.Point) Client(org.powerbot.bot.rt6.client.Client) Component(org.powerbot.script.rt6.Component) CollisionMap(org.powerbot.script.rt6.CollisionMap) Point(java.awt.Point)

Example 5 with Component

use of zipkin2.Component in project powerbot by powerbot.

the class DrawItems method repaint.

public void repaint(final Graphics render) {
    if (!ctx.game.loggedIn()) {
        return;
    }
    render.setFont(new Font("Arial", 0, 10));
    render.setColor(Color.green);
    if (ctx.bank.opened()) {
        final Component container = ctx.widgets.component(Constants.BANK_WIDGET, Constants.BANK_ITEMS);
        final Rectangle r = container.viewportRect();
        if (r != null) {
            for (final Item item : ctx.bank.select()) {
                final Component c = item.component();
                if (c == null) {
                    continue;
                }
                final Rectangle r2 = c.boundingRect();
                if (r2 == null) {
                    continue;
                }
                if (c.relativePoint().y == 0 || !r.contains(r2)) {
                    continue;
                }
                final Point p = c.screenPoint();
                render.drawString(c.itemId() + "", p.x, p.y + c.height());
            }
        }
    }
    if (ctx.backpack.component().visible()) {
        for (final Item item : ctx.backpack.select()) {
            final Component c = item.component();
            if (c == null) {
                continue;
            }
            final Point p = c.screenPoint();
            render.drawString(c.itemId() + "", p.x, p.y + c.height());
        }
    }
    if (ctx.equipment.component().visible()) {
        for (final Item item : ctx.equipment.select()) {
            if (item == null) {
                continue;
            }
            final Component c = item.component();
            if (c == null) {
                continue;
            }
            final Point p = c.screenPoint();
            render.drawString(c.itemId() + "", p.x, p.y + c.height());
        }
    }
}
Also used : Item(org.powerbot.script.rt6.Item) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Component(org.powerbot.script.rt6.Component) Font(java.awt.Font)

Aggregations

Test (org.junit.Test)6 Point (java.awt.Point)5 Component (org.powerbot.script.rt6.Component)5 Span (zipkin2.Span)5 Condition (org.powerbot.script.Condition)4 Component (org.sbolstandard.core2.Component)4 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)4 CheckResult (zipkin2.CheckResult)4 SequenceAnnotation (org.sbolstandard.core2.SequenceAnnotation)3 Font (java.awt.Font)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Component (org.powerbot.script.rt4.Component)2 Item (org.powerbot.script.rt6.Item)2 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)2 SBOLDocument (org.sbolstandard.core2.SBOLDocument)2 Sequence (org.sbolstandard.core2.Sequence)2 Component (zipkin2.Component)2 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)1