Skip to content

GrafanaProcessor

This docs was updated at: 2026-02-23

com.paragon.telemetry.grafana.GrafanaProcessor  ยท  Class

Extends TelemetryProcessor


Telemetry processor that sends telemetry to Grafana Cloud via OTLP/HTTP.

Grafana supports traces, metrics, and logs. Each signal type can be individually enabled/disabled via the builder.

Default configuration enables traces only. Enable metrics and logs as needed for your observability requirements.

See Also

  • <a href="https://grafana.com/docs/grafana-cloud/send-data/otlp/">Grafana OTLP Docs</a>

Methods

builder

public static @NonNull Builder builder()

Creates a new builder for GrafanaProcessor.


fromEnv

public static @NonNull GrafanaProcessor fromEnv()

Creates a processor from environment variables.


sendTrace

private void sendTrace(@NonNull TelemetryEvent event)

Sends trace data to Grafana.


sendMetrics

private void sendMetrics(@NonNull ResponseCompletedEvent event)

Sends metrics data to Grafana. Creates gauge/counter metrics from the completed event.


sendLog

private void sendLog(@NonNull TelemetryEvent event)

Sends log data to Grafana.


convertToSpan

private @NonNull OtelSpan convertToSpan(@NonNull TelemetryEvent event)

Converts a TelemetryEvent to an OtelSpan.


sendToEndpoint

private void sendToEndpoint(
      @NonNull String endpoint, @NonNull String json, @NonNull String type)

Sends JSON payload to the specified endpoint.


isTracesEnabled

public boolean isTracesEnabled()

Returns whether traces are enabled.


isMetricsEnabled

public boolean isMetricsEnabled()

Returns whether metrics are enabled.


isLogsEnabled

public boolean isLogsEnabled()

Returns whether logs are enabled.


httpClient

public @NonNull Builder httpClient(@NonNull OkHttpClient httpClient)

Sets the HTTP client.


baseUrl

public @NonNull Builder baseUrl(@NonNull String baseUrl)

Sets the Grafana OTLP base URL (e.g., https://otlp-gateway-prod-us-east-0.grafana.net/otlp).


instanceId

public @NonNull Builder instanceId(@NonNull String instanceId)

Sets the Grafana Cloud instance ID.


apiToken

public @NonNull Builder apiToken(@NonNull String apiToken)

Sets the Grafana Cloud API token.


objectMapper

public @NonNull Builder objectMapper(@NonNull ObjectMapper objectMapper)

Sets the ObjectMapper for JSON serialization.


tracesEnabled

public @NonNull Builder tracesEnabled(boolean enabled)

Enables or disables trace sending.


metricsEnabled

public @NonNull Builder metricsEnabled(boolean enabled)

Enables or disables metrics sending.


logsEnabled

public @NonNull Builder logsEnabled(boolean enabled)

Enables or disables log sending.


fromEnv

public @NonNull Builder fromEnv()

Loads configuration from environment variables.


build

public @NonNull GrafanaProcessor build()

Builds the GrafanaProcessor.