Module newrelic

ballerinax/newrelic Ballerina library

1.1.0

Overview

The New Relic Observability Extension provides an implementation for tracing and metrics, publishing both metrics and traces to a New Relic platform.

Key Features

  • Publish traces and metrics directly to New Relic
  • Support for multiple API keys for different New Relic accounts
  • Configurable sampler, reporter, and custom metric attributes
  • Available metrics including response times, request counts, error rates, and Kafka stats

Enabling New Relic Extension

To package the New Relic extension into the Jar, follow the following steps.

  1. Add the following import to your program.
Copy
import ballerinax/newrelic as _;
  1. Add the following to the Ballerina.toml when building your program.
Copy
[package]
org = "my_org"
name = "my_package"
version = "1.0.0"

[build-options]
observabilityIncluded=true

To enable the extension and publish traces and metrics to New Relic, add the following to the Config.toml when running your program.

Copy
[ballerina.observe]
tracingEnabled=true
tracingProvider="newrelic"
metricsEnabled=true
metricsReporter="newrelic"

[ballerinax.newrelic]
apiKey="<NEW_RELIC_LICENSE_KEY>"    # Mandatory Configuration.
region="<NEW_RELIC_REGION>"         # Optional Configuration ('us' or 'eu'). Default value is 'us'
tracingSamplerType="const"          # Optional Configuration. Default value is 'const'
tracingSamplerParam=1               # Optional Configuration. Default value is 1
tracingReporterFlushInterval=15000  # Optional Configuration. Default value is 15000 milliseconds
tracingReporterBufferSize=10000     # Optional Configuration. Default value is 10000
metricReporterFlushInterval=15000   # Optional Configuration. Default value is 15000 milliseconds
metricReporterClientTimeout=10000   # Optional Configuration. Default value is 10000 milliseconds
isTraceLoggingEnabled=false         # Optional Configuration. Default value is false
isPayloadLoggingEnabled=false       # Optional Configuration. Default value is false

[ballerinax.newrelic.additionalAttributes]      # Optional Configuration. Add custom attributes (key & value pair) to metrics
key1 = "<VALUE_1>"
key2 = "<VALUE_2>"

Users can also configure multiple API keys for different New Relic user accounts as given below.

Copy
[ballerinax.newrelic]
apiKey=["<NEW_RELIC_LICENSE_KEY_1>", "<NEW_RELIC_LICENSE_KEY_2>"]   # Mandatory Configuration.

User can configure the environment variable BALLERINA_NEW_RELIC_API_KEY instead of apiKey in Config.toml. If both are configured, apiKey in Config.toml will be overwritten by the environment variable value. Environment variable can be configured for either a single user or multiple users.

For a single user account:

  • Linux/Unix: export BALLERINA_NEW_RELIC_API_KEY="<NEW_RELIC_LICENSE_KEY>"
  • Windows: set BALLERINA_NEW_RELIC_API_KEY="<NEW_RELIC_LICENSE_KEY>"

For multiple user accounts:

  • Linux/Unix: export BALLERINA_NEW_RELIC_API_KEY="<NEW_RELIC_LICENSE_KEY_1>, <NEW_RELIC_LICENSE_KEY_2>"
  • Windows: set BALLERINA_NEW_RELIC_API_KEY="<NEW_RELIC_LICENSE_KEY_1>, <NEW_RELIC_LICENSE_KEY_2>"

Observe Metrics in New Relic

Instead of using prometheus as an intermediate metric reporter that remote writes the metrics to New Relic, Ballerina New Relic Observability Extension directly publishes metrics to New Relic on the following metric API https://metric-api.newrelic.com/metric/v1.

Instrumentation of metrics is done using the com.newrelic.telemetry.

Available Metrics

The exporter provides the following metrics.

Metric NameDescription
response_time_seconds_valueResponse time of a HTTP request in seconds
response_time_seconds_maxMaximum response time of a HTTP request
response_time_seconds_minMinimum response time of a HTTP request
response_time_seconds_meanAverage response time of a HTTP request
response_time_seconds_stdDevStandard deviation of response time of a HTTP request
response_time_secondsSummary of HTTP request-response times across various time frames and quantiles
response_time_nanoseconds_total_valueResponse time of a HTTP request in nano seconds
requests_total_valueTotal number of requests
response_errors_total_valueTotal number of response errors
inprogress_requests_valueTotal number of inprogress requests
kafka_publishers_valueNumber of publishers in kafka
kafka_consumers_valueNumber of consumers in kafka
kafka_errors_valueNumber of errors happened while publishing in kafka

Observe Traces in New Relic

Ballerina New Relic Observability Extension directly publishes traces to New Relic on the following trace API https://otlp.nr-data.net:4317. Traces are published to New Relic on OpenTelemetry format.

Instrumentation of traces is done using the io.opentelemetry and GRPC protocol is used send traces.

Import

import ballerinax/newrelic;Copy

Other versions

See more...

Metadata

Released date: 4 days ago

Version: 1.1.0


Compatibility

Platform: java25

Ballerina version: 2201.14.0

GraalVM compatible: Yes


Pull count

Total: 6726

Current verison: 1


Weekly downloads



Keywords

Type/Driver

Area/Developer Tools

Vendor/New Relic

Observability

tracing

metrics