# signalfx/splunk-otel-android architecture

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

- Interactive diagram: https://gitdiagram.com/signalfx/splunk-otel-android
- Repository: https://github.com/signalfx/splunk-otel-android

## Overview

##### Main Components
- Instrumentation Core (“splunk-otel-android”): This module handles most of the core logic, such as crash reporting, ANR detection, Activity/Fragment lifecycle monitoring, as well as telemetry collection and the exporting of data.
- Network Instrumentation for Volley (“splunk-otel-android-volley”): This module integrates with Volley to capture network request details, including headers, response data, and server timing attributes.
- Sample Application (“sample-app”): A demonstrative Android app that shows how the instrumentation libraries are integrated into a live app. This helps in visualizing how developers will incorporate the instrumentation into their apps.
- Build Infrastructure: Although not part of the runtime architecture, note that the buildSrc and Gradle scripts (build.gradle.kts, gradle/wrapper, etc.) manage project configurations and conventions for consistent builds.
- External Dependencies and Libraries: The project leverages OpenTelemetry APIs, Splunk RUM APIs, and Android framework components. Also highlighted are integrations with OkHttp (for HTTP client instrumentation) and various gradle tooling elements.

##### Relationships and Data Flow
- The Sample Application acts as the client that integrates with the instrumentation libraries.
- When the app runs, the instrumentation core (splunk-otel-android) hooks into the Android lifecycle (activities, fragments, etc.) to monitor events like crashes, ANRs, and UI lifecycle events.
- The Volley instrumentation module intercepts network calls made via the Volley client and wraps them so that telemetry (like HTTP attributes and errors) can be collected.
- Both instrumentation modules then interact with the OpenTelemetry APIs and, through SplunkRum, prepare and possibly export telemetry/spans to the Splunk Observability backend.
- The build infrastructure supports modularity and ensures that coding conventions (e.g., error-prone and spotless rules) are consistently applied across the modules.

##### Architectural Patterns and Design Principles
- Modular Architecture: Separation into clear modules (core instrumentation, Volley integration, sample app, build configuration).
- Instrumentation Hooks: The libraries employ hooks in the Android lifecycle to capture system events and network data, using interceptor patterns for network calls.
- Extensibility: The library exposes APIs (like SplunkRum and OpenTelemetry hooks) that allow manual instrumentation and customization (e.g., span redaction or modification before export).

##### Detail and Clarity
- That each major component is clearly labeled.
- Annotations if needed to highlight design principles such as modularity, interceptors for network calls, and lifecycle monitoring hooks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Layer
    subgraph "Application Layer"
        A["Android App (Sample)"]:::sample
    end

    %% Instrumentation Layer
    subgraph "Instrumentation Layer"
        I["Core Instrumentation Module"]:::core
        V["Volley Network Instrumentation Module"]:::volley
        A -->|"lifecycle_events"| I
        A -->|"network_calls"| V
    end

    %% Data Export Layer
    subgraph "Data Export Layer"
        E["Export/Telemetry Processor"]:::export
        I -->|"exports"| E
        V -->|"exports"| E
        E -->|"reports"| S["Splunk Observability Cloud"]:::external
    end

    %% Build Infrastructure (Supplementary)
    subgraph "Build Infrastructure"
        B1["buildSrc"]:::build
        B2["Gradle Scripts"]:::build
        B1 -->|"configures"| B2
    end

    %% Build Infrastructure supports build configuration
    B1 -.->|"build_configures"| A
    B1 -.->|"build_configures"| I
    B2 -.->|"build_configures"| V

    %% Click Events for component mapping
    click A "https://github.com/signalfx/splunk-otel-android/tree/main/sample-app/"
    click I "https://github.com/signalfx/splunk-otel-android/tree/main/splunk-otel-android/"
    click V "https://github.com/signalfx/splunk-otel-android/tree/main/splunk-otel-android-volley/"
    click B1 "https://github.com/signalfx/splunk-otel-android/tree/main/buildSrc/"
    click B2 "https://github.com/signalfx/splunk-otel-android/tree/main/gradle/"

    %% Styles
    classDef sample fill:#d1e7dd,stroke:#0f5132,stroke-width:2px;
    classDef core fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef volley fill:#cff4fc,stroke:#055160,stroke-width:2px;
    classDef export fill:#f8d7da,stroke:#842029,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#41464b,stroke-width:2px,stroke-dasharray:5,5;
    classDef build fill:#e7eaf6,stroke:#456,stroke-width:2px,stroke-dasharray:5,5;
```
