public long getCounter(final String statName) { if (statName == null || !isRecording()) return -1; final Long stat = counters.get(statName); if (stat == null) return -1; return stat; }
public void updateCounter(final String statName, final String description, final long plus, final String metadata) { if (statName == null || !isRecording()) return; Long oldValue; Long newValue; do { oldValue = counters.get(statName); if (oldValue == null) { counters.putIfAbsent(statName, 0L); oldValue = counters.get(statName); } newValue = oldValue + plus; } while (!counters.replace(statName, oldValue, newValue)); }
public void configure(final String iConfiguration) { if (iConfiguration == null || iConfiguration.length() == 0) return; if (isRecording()) stopRecording(); startRecording(); }
protected void revertSubclassesProfiler(final OCommandContext iContext, int num) { final OProfiler profiler = Orient.instance().getProfiler(); if (profiler.isRecording()) { profiler.updateCounter(profiler.getDatabaseMetric(getDatabase().getName(), "query.indexUseAttemptedAndReverted"), "Reverted index usage in query", num); } }
private void logProfiling() { if (executionPlan.getStatement() != null && Orient.instance().getProfiler().isRecording()) { final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) { final OSecurityUser user = db.getUser(); final String userString = user != null ? user.toString() : null; Orient.instance().getProfiler() .stopChrono("db." + ODatabaseRecordThreadLocal.instance().get().getName() + ".command.sql." + executionPlan.getStatement(), "Command executed against the database", System.currentTimeMillis() - totalExecutionTime, "db.*.command.*", null, userString); } } }
protected void revertProfiler(final OCommandContext iContext, final OIndex<?> index, final List<Object> keyParams, final OIndexDefinition indexDefinition) { if (iContext.isRecordingMetrics()) { iContext.updateMetric("compositeIndexUsed", -1); } final OProfiler profiler = Orient.instance().getProfiler(); if (profiler.isRecording()) { profiler.updateCounter(profiler.getDatabaseMetric(index.getDatabaseName(), "query.indexUsed"), "Used index in query", -1); int params = indexDefinition.getParamCount(); if (params > 1) { final String profiler_prefix = profiler.getDatabaseMetric(index.getDatabaseName(), "query.compositeIndexUsed"); profiler.updateCounter(profiler_prefix, "Used composite index in query", -1); profiler.updateCounter(profiler_prefix + "." + params, "Used composite index in query with " + params + " params", -1); profiler.updateCounter(profiler_prefix + "." + params + '.' + keyParams.size(), "Used composite index in query with " + params + " params and " + keyParams.size() + " keys", -1); } } }
protected void updateProfiler(final OCommandContext iContext, final OIndex<?> index, final List<Object> keyParams, final OIndexDefinition indexDefinition) { if (iContext.isRecordingMetrics()) iContext.updateMetric("compositeIndexUsed", +1); final OProfiler profiler = Orient.instance().getProfiler(); if (profiler.isRecording()) { profiler.updateCounter(profiler.getDatabaseMetric(index.getDatabaseName(), "query.indexUsed"), "Used index in query", +1); int params = indexDefinition.getParamCount(); if (params > 1) { final String profiler_prefix = profiler.getDatabaseMetric(index.getDatabaseName(), "query.compositeIndexUsed"); profiler.updateCounter(profiler_prefix, "Used composite index in query", +1); profiler.updateCounter(profiler_prefix + "." + params, "Used composite index in query with " + params + " params", +1); profiler.updateCounter(profiler_prefix + "." + params + '.' + keyParams.size(), "Used composite index in query with " + params + " params and " + keyParams.size() + " keys", +1); } } }
if (profiler.isRecording()) { profiler .updateCounter(profiler.getDatabaseMetric(database.getName(), "query.indexUsed"), "Used index in query", +1);
@Deprecated public Object execute(final Map<Object, Object> iArgs) { final long start = Orient.instance().getProfiler().startChrono(); Object result; while (true) { try { if (callback != null) return callback.call(iArgs); final OCommandExecutorScript command = new OCommandExecutorScript(); command.parse(new OCommandScript(getLanguage(), getCode())); result = command.execute(iArgs); break; } catch (ONeedRetryException | ORetryQueryException ignore) { } } if (Orient.instance().getProfiler().isRecording()) Orient.instance().getProfiler().stopChrono("db." + ODatabaseRecordThreadLocal.instance().get().getName() + ".function.execute", "Time to execute a function", start, "db.*.function.execute"); return result; }
/** * Register statistic information about usage of index in {@link OProfilerStub}. * * @param index which usage is registering. */ private void updateStatistic(OIndex<?> index) { final OProfiler profiler = Orient.instance().getProfiler(); if (profiler.isRecording()) { Orient.instance().getProfiler() .updateCounter(profiler.getDatabaseMetric(index.getDatabaseName(), "query.indexUsed"), "Used index in query", +1); final int paramCount = index.getDefinition().getParamCount(); if (paramCount > 1) { final String profiler_prefix = profiler.getDatabaseMetric(index.getDatabaseName(), "query.compositeIndexUsed"); profiler.updateCounter(profiler_prefix, "Used composite index in query", +1); profiler .updateCounter(profiler_prefix + "." + paramCount, "Used composite index in query with " + paramCount + " params", +1); } } }
if (profiler.isRecording()) {
if (Orient.instance().getProfiler().isRecording()) { final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) {