New Relic OpenTelemetry Exporter
Project description
New Relic OpenTelemetry Python Exporter
An OpenTelemetry exporter for sending spans to New Relic using the New Relic Python Telemetry SDK. Currently, spans as of OpenTelemetry v0.15b0 are supported. For details on how OpenTelemetry data is mapped to New Relic data, see documentation in our exporter specifications documentation.
Installation
To start, the opentelemetry-ext-newrelic package must be installed. To install through pip:
$ pip install opentelemetry-ext-newrelic
If that fails, download the library from its GitHub page and install it using:
$ python setup.py install
Getting Started
In order to use the exporter, you will need to set the NEW_RELIC_INSERT_KEY environment variable with your Insights Insert API Key.
Using the span exporter
The following code sample assumes you have set the NEW_RELIC_INSERT_KEY environment variable and installed the following packages:
opentelemetry-ext-newrelic
import os
from opentelemetry import trace
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry_ext_newrelic import NewRelicSpanExporter
from opentelemetry.sdk.trace import TracerProvider
trace.set_tracer_provider(
TracerProvider(resource=Resource.create({"service.name": "otel-python"}))
)
trace.get_tracer_provider().add_span_processor(
BatchExportSpanProcessor(
NewRelicSpanExporter(
os.environ["NEW_RELIC_INSERT_KEY"],
),
schedule_delay_millis=500,
)
)
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("foo"):
with tracer.start_as_current_span("bar"):
print("Hello World from OpenTelemetry Python!")
Using the span exporter with auto-instrumentation
The following code sample assumes you have set the NEW_RELIC_INSERT_KEY environment variable and installed the following packages:
opentelemetry-ext-newrelic
opentelemetry-instrumentation-flask
flask
import os
from opentelemetry import trace
from opentelemetry.instrumentation.flask import FlaskInstrumentor
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry_ext_newrelic import NewRelicSpanExporter
from flask import Flask
app = Flask(__name__)
FlaskInstrumentor().instrument_app(app)
trace.set_tracer_provider(
TracerProvider(resource=Resource.create({"service.name": "otel-python-flask"}))
)
trace.get_tracer_provider().add_span_processor(
BatchExportSpanProcessor(
NewRelicSpanExporter(os.environ["NEW_RELIC_INSERT_KEY"]),
schedule_delay_millis=500,
)
)
@app.route("/")
def hello_world():
return "Hello World!"
@app.route("/error")
def raise_500():
raise RuntimeError("Something happened!")
if __name__ == "__main__":
app.run(port=8080)
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: - Query New Relic data - Intro to NRQL
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. You can find this project’s topic/threads here:
Support Channels
New Relic Documentation: Comprehensive guidance for using our platform
New Relic Community: The best place to engage in troubleshooting questions
New Relic Developer: Resources for building a custom observability applications
New Relic University: A range of online training for New Relic users of every level
Contributing
We encourage your contributions to improve opentelemetry-exporter-python! 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. If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.
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.
License
opentelemetry-exporter-python is licensed under the Apache 2.0 License.
Limitations
The New Relic Telemetry APIs are rate limited. Please reference the documentation for New Relic Trace API requirements and limits on the specifics of the rate limits.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file opentelemetry-ext-newrelic-0.1.1.tar.gz
.
File metadata
- Download URL: opentelemetry-ext-newrelic-0.1.1.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2610dfd5c69d63c87a124009f7fd188293737be241dff66972e88f3816b2d19b |
|
MD5 | 37f0d05c67d20782d97092a2169ff259 |
|
BLAKE2b-256 | fc35bb15eabf1aa1794f6a39fc024e6e0b672df8a3844c8de0a863926c51422f |
File details
Details for the file opentelemetry_ext_newrelic-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: opentelemetry_ext_newrelic-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 386718c0ed28d0f45ff65bcd28f869048f92f454dcc612492c8f31bcb7d5529c |
|
MD5 | 2cf7ae73e7e426278c39fe501da86688 |
|
BLAKE2b-256 | cae3edac1c4259e0cf61294cb99c92d5e21fad718154f0f53b62cecfc5115265 |