# newrelic-experimental/newrelic-java-elasticsearch architecture

> Architecture diagram of the GitHub repository newrelic-experimental/newrelic-java-elasticsearch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/newrelic-experimental/newrelic-java-elasticsearch
- Repository: https://github.com/newrelic-experimental/newrelic-java-elasticsearch

## Overview

##### Project type and purpose
- This is an open-source instrumentation library (not a web or microservice) that plugs into the New Relic Java Agent to trace ElasticSearch queries.
- It consists of multiple Gradle sub-modules (elasticseach-2.x, 5.x, 6.x, 7.x, esrestclient-7.10) each producing a version-specific instrumentation JAR.

##### File structure
- Top-level:
- build.gradle, settings.gradle – declare a multi-module Gradle build
- .github/workflows – CI pipelines for release, changelog, linting
- modules named elasticsearch-X and esrestclient-7.10, each with its own build.gradle and src/main/java tree
- Each module:
- com/newrelic/instrumentation/elasticsearch (or labs/esrestclient) – the instrumentation hooks and query converters
- org/elasticsearch/... classes mirrored/stubbed to support bytecode weaving against ES client APIs
- No “frontend” or “backend” directories – it’s a pure instrumentation library.

##### README
- Describes installation (drop JAR into New Relic agent “extensions” dir) and expected runtime behavior (ES queries appear in New Relic UI).
- Build instructions show how to assemble each sub-module via Gradle.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Developer Workflow"
        direction TB
        buildGradle["build.gradle"]:::dev
        settingsGradle["settings.gradle"]:::dev
        workflows[".github/workflows"]:::dev
        buildGradle --> settingsGradle
        settingsGradle --> workflows
    end

    subgraph "Runtime Architecture"
        direction TB
        App["App JVM"]:::runtime
        ESClient["ES Client Library\n(TransportClient/RestClient)"]:::runtime
        subgraph "Instrumentation Extensions"
            direction TB
            mod2["elasticsearch-2.x"]:::extensions
            mod5_0["elasticsearch-5.0"]:::extensions
            mod5_3["elasticsearch-5.3"]:::extensions
            mod6["elasticsearch-6.x"]:::extensions
            mod7_0["elasticsearch-7.0"]:::extensions
            mod7_3["elasticsearch-7.3"]:::extensions
            mod7_14["elasticsearch-7.14"]:::extensions
            rest["esrestclient-7.10"]:::extensions
        end
        NRAgent["NR Agent Core"]:::agent
        ESCluster["ElasticSearch Cluster"]:::runtime
        NRBackend["New Relic Backend API"]:::backend

        App -->|"query() call"| ESClient
        ESClient -->|"client API"| mod2
        mod2 -->|"bytecode weaving"| NRAgent
        ESClient --> mod5_0
        ESClient --> mod5_3
        ESClient --> mod6
        ESClient --> mod7_0
        ESClient --> mod7_3
        ESClient --> mod7_14
        ESClient --> rest
        mod5_0 --> NRAgent
        mod5_3 --> NRAgent
        mod6 --> NRAgent
        mod7_0 --> NRAgent
        mod7_3 --> NRAgent
        mod7_14 --> NRAgent
        rest --> NRAgent
        ESClient -->|"proceed call"| ESCluster
        ESCluster -->|"response"| App
        NRAgent -->|"metrics & spans"| NRBackend
    end

    click buildGradle "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/blob/main/build.gradle"
    click settingsGradle "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/blob/main/settings.gradle"
    click workflows "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/blob/main/.github/workflows/release.yml"
    click workflows "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/blob/main/.github/workflows/CHANGELOG.tpl.md"
    click workflows "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/blob/main/.github/workflows/repolinter.yml"
    click mod2 "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/tree/main/elasticsearch-2.x/"
    click mod5_0 "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/tree/main/elasticsearch-5.0/"
    click mod5_3 "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/tree/main/elasticsearch-5.3/"
    click mod6 "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/tree/main/elasticsearch-6.x/"
    click mod7_0 "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/tree/main/elasticsearch-7.0/"
    click mod7_3 "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/tree/main/elasticsearch-7.3/"
    click mod7_14 "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/tree/main/elasticsearch-7.14/"
    click rest "https://github.com/newrelic-experimental/newrelic-java-elasticsearch/tree/main/esrestclient-7.10/"

    classDef runtime fill:#a0c4ff,stroke:#333,stroke-width:1px
    classDef extensions fill:#caffbf,stroke:#333,stroke-width:1px
    classDef agent fill:#bdb2ff,stroke:#333,stroke-width:1px
    classDef backend fill:#ffc6ff,stroke:#333,stroke-width:1px
    classDef dev fill:#f0f0f0,stroke:#333,stroke-width:1px
```
