• Stars
    star
    39
  • Rank 670,673 (Top 14 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Java library for sending telemetry data to New Relic

New Relic Open Source community project banner.

New Relic Java Telemetry SDK

The New Relic Java Telemetry SDK is an easy way to send data to New Relic. The SDK currently supports sending the MELT telemetry data types (Metrics, Events, Logs, and Traces) via the following APIs:

Why is this cool?

Send data to New Relic! No agent required.

Our Telemetry SDK tries to be helpful, so your job of sending telemetry data to New Relic can be done in the right way, easily. We've covered all of the basics for you so you can focus on writing feature code directly related to your business need or interest.

Why would you want to use the telemetry SDK?

We imagine you (or your customers) are interested in the telemetry data, generated by your tool, framework, or code, in New Relic. You can write an exporter to do so! Check out the telemetry_examples module to get started.

For the most recently published version, see Releases

Installation

In order to send metrics or spans to New Relic, you will need a New Relic license key for the account to which you want to send data.

Maven dependencies:

    <dependency>
      <groupId>com.newrelic.telemetry</groupId>
      <artifactId>telemetry-core</artifactId>
      <version>0.16.0</version>
    </dependency>
    <dependency>
      <groupId>com.newrelic.telemetry</groupId>
      <artifactId>telemetry-http-okhttp</artifactId>
      <version>0.16.0</version>
    </dependency>

Gradle dependencies:

implementation("com.newrelic.telemetry:telemetry-core:0.16.0")
implementation("com.newrelic.telemetry:telemetry-http-okhttp:0.16.0")

Take a look at the example code in the telemetry_examples module. We recommend looking at the TelemetryClientExample first.

Note: If you do not want to include okhttp as a transitive dependency, you will need to provide a custom implementation of the com.newrelic.telemetry.http.HttpPoster interface, rather than using the com.newrelic.telemetry:telemetry-http-okhttp library.

Usage

Logging

The Telemetry SDK uses slf4j for all logging. Having a slf4j implementation in your application is required in order to see log information. See the slf4j documentation for details.

Enabling audit logging

The various builders for the Telemetry SDK components include an option to enableAuditLogging. Enabling this option will cause the SDK to product additional logging at DEBUG level. This logging includes the details of every payload sent to the New Relic APIs, and the responses from those APIs.

WARNING: If you enable audit logging, all the data in your spans and metrics will be sent to your logging system. It is recommended that you only enable audit logging when absolutely necessary.

Use license key

The various builders for the Telemetry SDK components include an option to useLicenseKey. Enabling this option will cause the SDK to inform the API endpoints the key you provided is a New Relic license key.

For developers:

Requirements

  • Java 11 or greater
  • For IDEA:
  • Docker & docker-compose must be installed for integration testing

Find and use your data

Tips on how to find and query your data in New Relic:

For general querying information, see:

Building

CI builds are run on Github Actions: build badge

The project uses Java 11 and gradle 6 for building, and the gradle wrapper is provided.

To compile, run the tests and build the jars:

$ ./gradlew build

Testing

End-to-end integration tests are included. They are implemented with the testcontainers library; mock-server provides the backend.

There are two modes to run the integration tests.

  • Run with gradle: $ ./gradlew integration_test:test
  • Run the integration test classes in IDEA directly. It should "just work".

Code style

This project uses the google-java-format code style, and it is easily applied via an included gradle plugin:

$ ./gradlew googleJavaFormat verifyGoogleJavaFormat

Please be sure to run the formatter before committing any changes. There is a pre-commit-hook.sh which can be applied automatically before commits by moving it into .git/hooks/pre-commit.

Module structure:

telemetry_core

This is the core module for sending dimensional metrics and spans to New Relic. It contains low level APIs as well as higher level "best practice" implementations that compose interactions with the lower level modules. The library is published under maven coordinates:

com.newrelic.telemetry:telemetry-core

In order to send metrics and spans to New Relic, you will also need a New Relic license key for the account to which you want to send data.

telemetry-http-java11

This is an implementation of the required http client interface using Java 11 JDK classes as the underlying library. The telemetry-http-java11 library is published under the maven coordinates:

com.newrelic.telemetry:telemetry-http-java11

telemetry-http-okhttp

This is an implementation of the required http client interface using okhttp as the underlying library. The telemetry-http-okhttp library is published under the maven coordinates:

com.newrelic.telemetry:telemetry-http-okhttp

telemetry_examples

Example code for using the metrics and telemetry APIs.

integration_test

Integration test module. Uses docker-compose based tests to test the SDK end-to-end.

Retries

As described here, the TelemetryClient makes use of a default backoff strategy when it encounters data ingest errors. Specifically, this strategy tries again after 1 second, then doubles the wait after each attempt until a max wait of 15 seconds is reached. After 10 failed attempts, data is dropped and a message is logged.

The backoff strategy is not currently pluggable. Please file an issue or submit a pull request if you need greater control over this behavior.

Support

New Relic hosts and moderates an online forum where customers can interact with New Relic employees as well as other customers to get help and share best practices. Like all official New Relic open source projects, there's a related Community topic in the New Relic Explorers Hub: Java Agent Forum Topics.

Contribute

We encourage your contributions to improve New Relic Java Telemetry SDK! Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.

If you have any questions, or to execute our corporate CLA (which is required if your contribution is on behalf of a company), drop us an email at [email protected].

A note about vulnerabilities

As noted in our security policy, New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.

If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through HackerOne.

If you would like to contribute to this project, review these guidelines.

To all contributors, we thank you! Without your contribution, this project would not be what it is today. We also host a community project page dedicated to New Relic Telemetry SDK (Java).

Limitations

The New Relic Telemetry APIs are rate limited. Please reference the documentation for New Relic Metric API and New Relic Trace API requirements and limits on the specifics of the rate limits.

License

The New Relic Java Telemetry SDK is licensed under the Apache 2.0 License.

The New Relic Java Telemetry SDK also uses source code from third party libraries. Full details on which libraries are used and the terms under which they are licensed can be found in the third party notices document.

More Repositories

1

centurion

A mass deployment tool for Docker fleets
Ruby
1,744
star
2

newrelic-ruby-agent

New Relic RPM Ruby Agent
Ruby
1,180
star
3

node-newrelic

New Relic Node.js agent code base. Developers are welcome to create pull requests here, please see our contributing guidelines. For New Relic technical support, please go to http://support.newrelic.com.
JavaScript
927
star
4

go-agent

New Relic Go Agent
Go
719
star
5

rusty-hog

A suite of secret scanners built in Rust for performance. Based on TruffleHog (https://github.com/dxa4481/truffleHog) which is written in Python.
Rust
388
star
6

sidecar

Gossip-based service discovery. Docker native, but supports static discovery, too.
Go
259
star
7

elixir_agent

New Relic's Open Source Elixir Agent
Elixir
251
star
8

terraform-provider-newrelic

Terraform provider for New Relic
Go
199
star
9

rpm_contrib

Extra Instrumentation for the New Relic RPM Gem
192
star
10

newrelic-java-agent

The New Relic Java agent
Java
183
star
11

docs-website

Source code for @newrelic docs. We welcome pull requests and questions on our docs!
MDX
164
star
12

newrelic-python-agent

New Relic Python Agent
Python
156
star
13

newrelic_aws_cloudwatch_plugin

New Relic AWS Cloudwatch Plugin
Ruby
154
star
14

check_docker

A Go Nagios check for Docker
Go
126
star
15

newrelic-cli

The New Relic Command Line Interface
Go
121
star
16

newrelic_api

Documentation, Active Resource Helper, and test code for the RPM REST API
Ruby
119
star
17

opensource-website

Source code for New Relic's Opensource site.
JavaScript
105
star
18

nri-flex

An application-agnostic, all-in-one New Relic integration integration
Go
104
star
19

newrelic-php-agent

The New Relic PHP Agent
C
103
star
20

infrastructure-agent

New Relic Infrastructure Agent
Go
102
star
21

newrelic-quickstarts

New Relic One quickstarts help accelerate your New Relic journey by providing immediate value for your specific use cases.
TypeScript
102
star
22

infrastructure-agent-ansible

Ansible role for installing New Relic Infrastructure agent
Python
95
star
23

helm-charts

Helm charts for New Relic applications
Smarty
93
star
24

nr1-workshop

Self-paced training workshop for the NR1 CLI/SDK
JavaScript
86
star
25

newrelic-opentelemetry-examples

Examples for sending OpenTelemetry sourced data to New Relic.
Java
85
star
26

newrelic_mysql_java_plugin

MySQL Metrics Plugin
Java
79
star
27

newrelic-dotnet-agent

The New Relic .NET language agent.
C#
74
star
28

newrelic-node-nextjs

New Relic Next.js instrumentation for the Node Agent
JavaScript
71
star
29

newrelic-lambda-extension

An AWS Lambda Extension to collect, enhance and transport telemetry to New Relic for AWS Lambda functions without requiring an external transport such as CloudWatch Logs or Kinesis.
Go
68
star
30

newrelic-client-go

New Relic Client for the Go programming language
Go
68
star
31

newrelic-browser-agent

New Relic Browser Agent
HTML
63
star
32

entity-definitions

The definition files contained in this repository are mappings between the telemetry attributes NewRelic ingests, and the entities users can interact with. If you have telemetry from any source that is not supported out of the box, you can propose a mapping for it by opening a PR.
JavaScript
62
star
33

node-native-metrics

Optional native module for collecting low-level Node & V8 metrics
C++
58
star
34

k8s-webhook-cert-manager

Generate certificate suitable for use with any Kubernetes Mutating Webhook.
Shell
58
star
35

c-sdk

New Relic C SDK
C
57
star
36

newrelic-node-apollo-server-plugin

JavaScript
53
star
37

deployment-marker-action

Github Action for recording a Deployment Marker in New Relic
Shell
50
star
38

absinthe-schema-stitching-example

Absinthe Schema Stitching Example
Elixir
49
star
39

aws-log-ingestion

AWS Serverless Application that sends log data from CloudWatch Logs to New Relic Infrastructure - Cloud Integrations.
Python
48
star
40

nr1-cloud-optimize

NR1 Cloud Optimize allows you to Identify right-sizing opportunities and potential savings of your AWS, GCP, and Azure instances across your cloud environment.
JavaScript
47
star
41

serverless-newrelic-lambda-layers

A Serverless plugin to install New Relic's AWS Lambda layers without requiring a code change.
TypeScript
46
star
42

newrelic-lambda-cli

A CLI to install the New Relic AWS Lambda integration and layers.
Python
45
star
43

infra-integrations-sdk

New Relic Infrastructure Integrations SDK
Go
45
star
44

go_nagios

Go lang package for writing Nagios checks
Go
43
star
45

newrelic-kubernetes-operator

Operator to create New Relic configuration in Kubernetes
Go
42
star
46

dPerf

Distributed Mobile CPU Profiling
Objective-C
41
star
47

newrelic-telemetry-sdk-go

Go library for sending telemetry data to New Relic
Go
40
star
48

developer-website

Source code for the New Relic Developer Site.
MDX
39
star
49

newrelic-diagnostics-cli

NrDiag is a command line diagnostics tool for New Relic Products that was created by and is maintained by New Relic Global Technical Support
Go
37
star
50

el-dorado-ui

Graph db query and rendering suitable for visualization of complex process structures
Ruby
37
star
51

newrelic-ruby-kata

Using New Relic and Heroku, see how many things you can find and fix to make this app perform fast!
Ruby
35
star
52

micrometer-registry-newrelic

ARCHIVED. TO SEND MICROMETER METRICS TO NEW RELIC, FOLLOW THE DIRECTION IN THE README.md. Micrometer registry implementation that sends data to New Relic as dimensional metrics.
Java
35
star
53

newrelic_microsoft_sqlserver_plugin

New Relic Microsoft SQL Server Plugin
C#
33
star
54

nri-prometheus

Fetch metrics in the Prometheus metrics inside or outside Kubernetes and send them to the New Relic Metrics platform.
Go
33
star
55

nri-kubernetes

New Relic integration for Kubernetes
Go
33
star
56

nr1-status-pages

NR1 Status Pages allows you to collect and display the statuses of key dependencies in one place.
JavaScript
33
star
57

papers

Validates licenses of your Rails dependencies against a whitelist
Ruby
31
star
58

opentelemetry-exporter-go

New Relic's Golang OpenTelemetry Exporter
Go
30
star
59

nr-openai-observability

Easy to install OpenAI GPT monitoring tool.
Python
30
star
60

tutone

Generate Golang code from GraphQL schema introspection
Go
30
star
61

extends_newrelic_rpm

Gems that extend New Relic's Ruby agent (newrelic_rpm), linked via git submodules
Ruby
29
star
62

newrelic_plugin

New Relic Ruby Plugin Agent SDK
Ruby
29
star
63

newrelic-jfr-core

JFR library that adapts JFR events to the New Relic Telemetry SDK
Java
29
star
64

newrelic-telemetry-sdk-python

A python library to send data to New Relic!
Python
29
star
65

infrastructure-agent-chef

Chef cookbook for installing New Relic Infrastructure agent
Ruby
28
star
66

nrjmx

Command line tool to connect to a JMX server and retrieve the MBeans it exposes.
Java
28
star
67

fluentd-examples

Sample FluentD configs
27
star
68

newrelic-lambda-layers

Source code and utilities to build and publish New Relic's public AWS Lambda layers.
Shell
27
star
69

dkenv

A docker version switcher
Go
26
star
70

newrelic-unix-monitor

Monitoring service for Unix (AIX, Linux, HP-UX, MacOS, Solaris) systems
Java
26
star
71

marlowe

Experimental project for investigating interesting visualizations of APM data
JavaScript
25
star
72

futurestack14_badge

Source code for the badges from New Relic's FutureStack 2014 conference
Squirrel
24
star
73

nr-jenkins-plugin

Jenkins Plugin to send metrics to New Relic
Java
24
star
74

newrelic-telemetry-sdk-rust

Rust library for sending telemetry data to New Relic
Rust
23
star
75

k8s-metadata-injection

Kubernetes metadata injection for New Relic APM to make a linkage between APM and Infrastructure data.
Go
23
star
76

newrelic-fluent-bit-output

A Fluent Bit output plugin that sends logs to New Relic
Go
22
star
77

newrelic-monolog-logenricher-php

Monolog components to enable New Relic Logs
PHP
22
star
78

agent_sdk_samples

Sample wrappers and code for the New Relic Agent SDK
C
22
star
79

wiki-sync-action

A GitHub Action that synchronizes the contents of a directory to the repository's Wiki.
Shell
22
star
80

nri-nginx

New Relic Infrastructure Nginx Integration
Go
21
star
81

nr1-slo-r

NR1 SLO-R allows you to define, calculate and report on service-level objective (SLO) attainment.
JavaScript
21
star
82

newrelic-airflow-plugin

Send airflow metrics to New Relic!
Python
20
star
83

newrelic-python-kata

Newrelic Python Kata
Python
20
star
84

newrelic_plugins_chef

Ruby
20
star
85

metrics_publish_java

New Relic Java Plugin Agent SDK
Java
20
star
86

newrelic-node-log-extensions

Source for the New Relic Node.js log framework extensions
JavaScript
20
star
87

newrelic-cordova-plugin

A Cordova plugin for the New Relic Mobile SDKs
JavaScript
19
star
88

newrelic-logenricher-dotnet

Extensions supporting New Relic Logging (Logs In Context)
C#
19
star
89

nr1-learn-nrql

NR1 learn NRQL helps New Relic Customers quickly learn our custom query language - NRQL
JavaScript
19
star
90

newrelic-cordova-ios

A PhoneGap / Cordova plugin for New Relic's iOS SDK
Objective-C
19
star
91

open-install-library

New Relic's open instrumentation installation recipe database and service
Shell
19
star
92

quickstarts-synthetics-library

Repositories containing example/templated synthetic scripts for use in New Relic.
JavaScript
19
star
93

gatsby-theme-newrelic

Source code for New Relic's Gatsby site theme.
JavaScript
19
star
94

nr1-browser-analyzer

NR1 Browser Analyzer allows you to understand the impact and performance of your website.
JavaScript
18
star
95

nr1-quickstarts

[ARCHIVED] Community repository of New Relic dashboards, alerts, and installation instructions.
JavaScript
18
star
96

supervisor-remote-logging

Use supervisord to relay your application's stdout/stderr to syslog.
Python
18
star
97

webinar

Contains the sample code for the "Best Practices for Measuring Your Code Pipeline" webinar
18
star
98

infrastructure-bundle

New Relic Infrastructure containerised agent bundle
Go
17
star
99

ruby-metaprogramming-challenge

A fun metaprogramming challenge created at New Relic
Ruby
16
star
100

newrelic_plugins_puppet

Puppet
16
star