Package com.jitlogic.zorka.common.tracedata

Examples of com.jitlogic.zorka.common.tracedata.TraceRecord


    log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData");

    ArrayList<ActiveCheckResult> list = new ArrayList<ActiveCheckResult>();
    ActiveCheckResult result;
    String keySuffix = null;
    TraceRecord traceRecord = (TraceRecord) rec;
    long clock = traceRecord.getClock() / 1000l;
   
    /* Finding Record's key */
    if (traceRecord.getAttrs() != null) {
      for (Map.Entry<Integer, Object> entry : traceRecord.getAttrs().entrySet()) {
        String attrName = symbolRegistry.symbolName(entry.getKey());
       
        if (attrName.equals("URI")) {
          keySuffix = "frontends." + String.valueOf(entry.getValue());
        }
      }
    }

    if (keySuffix == null) {
      String className = symbolRegistry.symbolName(traceRecord.getClassId()).replace(".", "_");
      String methodName = symbolRegistry.symbolName(traceRecord.getMethodId()).replace(".", "_");
      keySuffix = className + "_" + methodName;
    }
   
    String key;
    if (prefix == null || prefix.length() == 0) {
      key = keySuffix;
    } else {
      key = prefix + "." + keySuffix;
    }
    log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: key=" + key);
   
   
    /* Time */
    result = new ActiveCheckResult();
    result.setHost(hostname);
    result.setKey(key + ".time");
    /* nanoseconds -> milliseconds */
    result.setValue(String.valueOf(traceRecord.getTime() / 1000000l));
    result.setLastlogsize(0);
    result.setClock(clock);
    list.add(result);
    log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: data=" + result.toString());

    /* Calls */
    result = new ActiveCheckResult();
    result.setHost(hostname);
    result.setKey(key + ".calls");
     /* contar a chamada atual como 1 */
    result.setValue("1");
    result.setLastlogsize(0);
    result.setClock(clock);
    list.add(result);
    log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: data=" + result.toString());

    /* Errors */
    result = new ActiveCheckResult();
    result.setHost(hostname);
    result.setKey(key + ".errors");
    result.setValue(String.valueOf(traceRecord.getErrors()));
    result.setLastlogsize(0);
    result.setClock(clock);
    list.add(result);
    log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: data=" + result.toString());

    /* Recursive check children */
    if ((level <= 1) && (traceRecord.getChildren() != null)) {
      log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: children.size()=" + traceRecord.getChildren().size());
      for (TraceRecord child : traceRecord.getChildren()) {
        log.debug(ZorkaLogger.ZAG_DEBUG, "### traceRecordToData: child=" + child.toString());
        list.addAll(traceRecordToData(child, key + ".backends", level+1));
      }
    }
   
View Full Code Here


    }

    public TraceRecord tr(String className, String methodName, String methodSignature,
                          long calls, long errors, int flags, long time,
                          TraceRecord... children) {
        TraceRecord tr = new TraceRecord(null);
        tr.setClassId(sid(className));
        tr.setMethodId(sid(methodName));
        tr.setSignatureId(sid(methodSignature));
        tr.setCalls(calls);
        tr.setErrors(errors);
        tr.setFlags(flags);
        tr.setTime(time);

        for (TraceRecord child : children) {
            child.setParent(tr);
            tr.addChild(child);
        }

        return tr;
    }
View Full Code Here

        return tr;
    }

    @Test
    public void testReadWriteTraceRecordWithoutMarker() throws Exception {
        TraceRecord tr = tr("some.Class", "someMethod", "()V", 1, 0, TraceRecord.EXCEPTION_PASS, 100);
        tr.setAttr(sid("ATTR1"), 10);
        tr.setAttr(sid("ATTR2"), "bork");
        tr.setAttr(sid("ATTR3"), 1.23);

        writer.write(tr);

        FressianReader reader = reader();

        Object obj = reader.readObject();

        while (obj instanceof Symbol) {
            Symbol s = (Symbol) obj;
            assertThat(s.getId()).isEqualTo(sid(s.getName()));
            obj = reader.readObject();
        }

        TraceRecord tr2 = (TraceRecord) obj;
        assertThat(tr2.getFlags()).isEqualTo(TraceRecord.EXCEPTION_PASS);
        assertThat(tr2.getCalls()).isEqualTo(tr.getCalls());
        assertThat(tr2.getTime()).isEqualTo(tr.getTime());
    }
View Full Code Here

    }


    @Test
    public void testReadWriteTraceRecordWithMarker() throws Exception {
        TraceRecord tr = tr("some.Class", "someMethod", "()V", 1, 0, TraceRecord.TRACE_BEGIN, 100);
        TraceMarker tm = new TraceMarker(tr, sid("TRACE"), 100L);
        tm.setFlags(TraceMarker.OVERFLOW_FLAG);
        tr.setMarker(tm);

        writer.write(tr);

        FressianReader reader = reader();

        Object obj = reader.readObject();

        Set<Integer> ids = new HashSet<Integer>();

        while (obj instanceof Symbol) {
            Symbol s = (Symbol) obj;
            assertThat(s.getId()).isEqualTo(sid(s.getName()));
            obj = reader.readObject();
            ids.add(s.getId());
        }

        TraceRecord tr2 = (TraceRecord) obj;
        assertThat(tr2.getFlags()).isEqualTo(TraceRecord.TRACE_BEGIN);

        TraceMarker tm2 = tr2.getMarker();

        assertThat(tm2).isNotNull();
        assertThat(tm2.getFlags()).isEqualTo(TraceMarker.OVERFLOW_FLAG);
        assertThat(tm2.getClock()).isEqualTo(100L);
        assertThat(tm2.getTraceId()).isEqualTo(sid("TRACE"));
View Full Code Here

    }


    @Test
    public void testReadWriteRecursiveTrace() throws Exception {
        TraceRecord tr =
                tr("some.Class", "someMethod", "()V", 2, 0, 0, 100,
                        tr("other.Class", "otherMethod", "()V", 1, 0, 0, 50));

        writer.write(tr);

        FressianReader reader = reader();

        Object obj = reader.readObject();

        while (obj instanceof Symbol) {
            Symbol s = (Symbol) obj;
            assertThat(s.getId()).isEqualTo(sid(s.getName()));
            obj = reader.readObject();
        }

        TraceRecord tr2 = (TraceRecord) obj;
        assertThat(tr2.numChildren()).isEqualTo(1);
        assertThat(tr2.getChild(0).getTime()).isEqualTo(50L);
    }
View Full Code Here

    }


    @Test
    public void testReadWriteTraceWithExceptionObject() throws Exception {
        TraceRecord tr =
                tr("some.Class", "someMethod", "()V", 2, 0, 0, 100,
                        tr("other.Class", "otherMethod", "()V", 1, 0, 0, 50));

        tr.setException(new Exception("oja!"));
        tr.fixup(symbols);

        writer.write(tr);

        FressianReader reader = reader();

        Object obj = reader.readObject();

        while (obj instanceof Symbol) {
            Symbol s = (Symbol) obj;
            assertThat(s.getId()).isEqualTo(sid(s.getName()));
            obj = reader.readObject();
        }

        TraceRecord tr2 = (TraceRecord) obj;

        SymbolicException se = (SymbolicException) tr2.getException();
        assertThat(se.getMessage()).isEqualTo("oja!");
        assertThat(se.getClassId()).isEqualTo(sid("java.lang.Exception"));
        assertThat(se.getStackTrace()).isNotNull();

        SymbolicStackElement sse = se.getStackTrace()[0];
View Full Code Here

            }
        }

        if (!ttop.isEmpty()) {
            if (ttop.inTrace()) {
                ttop = new TraceRecord(ttop);
                numRecords++;
            } else {
                ttop.clean();
                numRecords = 0;
            }
View Full Code Here

        }

        if (ZorkaLogger.isLogLevel(ZorkaLogger.ZTR_TRACER_DBG)) {
            if (ZorkaLogger.isLogLevel(ZorkaLogger.ZTR_TRACE_CALLS) ||
                    (ttop.inTrace() && ttop.getMarker().hasFlag(TraceMarker.TRACE_CALLS))) {
                TraceRecord tr = ttop;
                if (tr.getClassId() == 0 && tr.getParent() != null) {
                    tr = tr.getParent();
                }
                log.trace(ZorkaLogger.ZTR_TRACER_DBG, "traceReturn("
                        + symbols.symbolName(tr.getClassId()) + "." + symbols.symbolName(tr.getMethodId()) + ")");
            }
        }

        while (!(ttop.getClassId() != 0) && ttop.getParent() != null) {
            ttop = ttop.getParent();
View Full Code Here

        }

        if (ZorkaLogger.isLogLevel(ZorkaLogger.ZTR_TRACER_DBG)) {
            if (ZorkaLogger.isLogLevel(ZorkaLogger.ZTR_TRACE_EXCEPTIONS) ||
                    (ttop.inTrace() && ttop.getMarker().hasFlag(TraceMarker.TRACE_CALLS))) {
                TraceRecord tr = ttop;
                if (tr.getClassId() == 0 && tr.getParent() != null) {
                    tr = tr.getParent();
                }
                log.trace(ZorkaLogger.ZTR_TRACER_DBG, "traceError(" + symbols.symbolName(tr.getClassId()) +
                        "." + symbols.symbolName(tr.getMethodId()) + ")", (Throwable) exception);
            }
        }

        while (!(ttop.getClassId() != 0) && ttop.getParent() != null) {
            ttop = ttop.getParent();
View Full Code Here

     *                has to be attached to current method;
     * @param attrId  attribute ID
     * @param attrVal attribute value
     */
    public void newAttr(int traceId, int attrId, Object attrVal) {
        TraceRecord tr = realTop();

        while (tr != null) {
            if (traceId == -1 || (tr.hasFlag(TraceRecord.TRACE_BEGIN) &&
                    (traceId == 0 || tr.getMarker().getTraceId() == traceId))) {
                tr.setAttr(attrId, attrVal);
                break;
            }
            tr = tr.getParent();
        }
    }
View Full Code Here

TOP

Related Classes of com.jitlogic.zorka.common.tracedata.TraceRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.