Giter VIP home page Giter VIP logo

opentelemetry-exporter-java's Introduction

New Relic OpenTelemetry span exporter

An OpenTelemetry reporter for sending spans to New Relic using the New Relic Java Telemetry SDK. For the juicy details on how OpenTelemetry spans are mapped to New Relic spans, see documentation in Our exporter specifications documentation

How to use

To send spans to New Relic, you will need an Insights Insert API Key.

Note: There is an example BasicExample.java
in the test source code hierarchy that matches this example code. It should be considered as the canonical code for this example, since OpenTelemetry internal SDK APIs are still a work in progress.

  1. Create a NewRelicSpanExporter
    NewRelicSpanExporter exporter = NewRelicSpanExporter.newBuilder()
        .apiKey(System.getenv("INSIGHTS_INSERT_KEY"))
        .commonAttributes(new Attributes().put("service.name", "best service ever")).build();
  1. Build the OpenTelemetry BatchSpansProcessor with the NewRelicSpanExporter
    BatchSpansProcessor spanProcessor = BatchSpansProcessor.newBuilder(exporter).build();
  1. Add the span processor to the default TracerSdkFactory
    TracerSdkFactory tracerSdkFactory = (TracerSdkFactory) OpenTelemetry.getTracerFactory();
    tracerSdkFactory.addSpanProcessor(spanProcessor);
  1. Create the OpenTelemetry Tracer and use it for recording spans.
    Tracer tracer = OpenTelemetry.getTracerFactory().get("sample-app", "1.0");
    
    Span span = tracer.spanBuilder("testSpan").setSpanKind(Kind.INTERNAL).startSpan();
    try (Scope scope = tracer.withSpan(span)) {
      //do some work
      Thread.sleep(1000);
      span.end();
    }
  1. Find your spans in New Relic One: go to https://one.newrelic.com/ and select Distributed Tracing.

Find and use your data

For tips on how to find and query your data in New Relic, see Find trace/span data.

For general querying information, see:

Gradle

build.gradle:

repositories {
    maven {
        url = "https://oss.sonatype.org/content/repositories/snapshots"
    }
}
implementation("com.newrelic.telemetry:opentelemetry-exporters-newrelic:0.2.0-SNAPSHOT")
implementation("io.opentelemetry:opentelemetry-sdk:0.2.0")
implementation("com.newrelic.telemetry:telemetry-core:0.3.2")
implementation("com.newrelic.telemetry:telemetry-http-okhttp:0.3.2")

Building

CI builds are run on Azure Pipelines: Build status

The project uses gradle 5 for building, and the gradle wrapper is provided.

To compile, run the tests and build the jar:

$ ./gradlew build

Contributing

Full details are available in our CONTRIBUTING.md file. We'd love to get your contributions to improve the New Relic OpenTelemetry exporter! Keep in mind 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. To execute our corporate CLA, which is required if your contribution is on behalf of a company, or if you have any questions, please drop us an email at [email protected].

opentelemetry-exporter-java's People

Contributors

breedx-nr avatar jkwatson avatar xixiapdx avatar zuluecho9 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.