Tabnine Logo
JSAgentBuilder
Code IndexAdd Tabnine to your IDE (free)

How to use
JSAgentBuilder
in
rocks.inspectit.agent.java.eum.instrumentation

Best Java code snippets using rocks.inspectit.agent.java.eum.instrumentation.JSAgentBuilder (Showing top 5 results out of 315)

origin: inspectIT/inspectIT

/**
 * Builds the JS agent from single char arguments.
 *
 * @param arguments
 *            all arguments together as a string.
 * @return the generated stream which builds the agent.
 */
public String buildJsFile(String arguments) {
  StringBuilder script = new StringBuilder();
  script.append(JS_AGENT_PREAMBLE);
  script.append("window.inspectIT_settings.activeAgentModules = \"").append(arguments).append("\";");
  script.append(getAgentCoreSource());
  // prevent duplicates of the modules added
  Set<JSAgentModule> alreadyAddedModules = new HashSet<JSAgentModule>();
  // add the modules source code
  for (char moduleIdentifier : arguments.toCharArray()) {
    if (JSAgentModule.IDENTIFIER_MAP.containsKey(moduleIdentifier)) {
      JSAgentModule module = JSAgentModule.IDENTIFIER_MAP.get(moduleIdentifier);
      if (!alreadyAddedModules.contains(module)) {
        script.append(getAgentModuleSource(module));
        alreadyAddedModules.add(module);
      }
    }
  }
  script.append(JS_AGENT_EPILOGUE);
  return script.toString();
}
origin: inspectIT/inspectIT

/**
 * @return the core agent source code, either laoded from the resources or directly fetched form
 *         the cache.
 */
@SuppressWarnings({ "PMD" })
private String getAgentCoreSource() {
  if (agentCoreSource == null) {
    synchronized (JSAgentBuilder.class) {
      if (agentCoreSource == null) {
        try {
          agentCoreSource = readResourceFile(JSBASE_RESOURCE);
        } catch (Exception e) {
          LOG.error("unable to read JS Agent core");
          return "";
        }
      }
    }
  }
  return agentCoreSource;
}
origin: inspectIT/inspectIT

/**
 * Sends the script using the given response object.
 *
 * @param res
 *            the response to write
 * @param activeModules
 *            a String listing the identifiers of the active modules.
 */
private void sendScript(WHttpServletResponse res, String activeModules) {
  // we respond with the script code
  res.setStatus(200);
  res.setContentType("application/javascript");
  res.addHeader("Cache-Control", "public, max-age=" + JSAgentBuilder.JS_AGENT_CACHE_MAX_AGE_SECONDS);
  PrintWriter writer = res.getWriter();
  writer.write(agentBuilder.buildJsFile(activeModules));
  writer.flush();
}
origin: inspectIT/inspectIT

@BeforeMethod
public void initMocks() throws IOException, StorageException {
  eumConfig.setActiveModules("a12");
  eumConfig.setEnabled(true);
  eumConfig.setScriptBaseUrl("/baseUrl/");
  when(dummyRequest.getRequestURI()).thenReturn("/mycool/url/here");
  when(config.getEndUserMonitoringConfig()).thenReturn(eumConfig);
  when(dummyResponse.getWriter()).thenReturn(Mockito.mock(PrintWriter.class));
  when(dummyResponse.getOutputStream()).thenReturn(Mockito.mock(ServletOutputStream.class));
  when(agentBuilder.buildJsFile(any(String.class))).thenReturn(AGENT_CODE);
}
origin: inspectIT/inspectIT

/**
 * @param module
 *            the module of which the source code shall be returned
 * @return @return the modules source code, either loaded from the resources or directly fetched
 *         form the cache.
 */
private String getAgentModuleSource(JSAgentModule module) {
  if (!moduleSourceCache.containsKey(module)) {
    try {
      String src = readResourceFile(module.getModuleSourceFile());
      moduleSourceCache.putIfAbsent(module, src);
      return src;
    } catch (Exception e) {
      LOG.error("unable to read JS Agent core");
      return "";
    }
  } else {
    return moduleSourceCache.get(module);
  }
}
rocks.inspectit.agent.java.eum.instrumentationJSAgentBuilder

Javadoc

Helper class for creating a javascript agent which only has some specified modules (plugins).

Most used methods

  • buildJsFile
    Builds the JS agent from single char arguments.
  • getAgentCoreSource
  • getAgentModuleSource
  • readResourceFile
    Utility method for reading resource text files.

Popular in Java

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (Timer)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • compareTo (BigDecimal)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JFrame (javax.swing)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now