Package: opentelemetry-ext-newrelic
New Relic OpenTelemetry Python ExporterAnOpenTelemetryexporter 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 inour exporter specifications
documentation.InstallationTo start, theopentelemetry-ext-newrelicpackage must be installed.
To install through pip:$pipinstallopentelemetry-ext-newrelicIf that fails, download the library from its GitHub page and install it
using:$pythonsetup.pyinstallGetting StartedIn order to use the exporter, you will need to set theNEW_RELIC_INSERT_KEYenvironment variable with yourInsights Insert
API
Key.Using the span exporterThe following code sample assumes you have set theNEW_RELIC_INSERT_KEYenvironment variable and installed the
following packages:opentelemetry-ext-newrelicimportosfromopentelemetryimporttracefromopentelemetry.sdk.resourcesimportResourcefromopentelemetry.sdk.trace.exportimportBatchExportSpanProcessorfromopentelemetry_ext_newrelicimportNewRelicSpanExporterfromopentelemetry.sdk.traceimportTracerProvidertrace.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__)withtracer.start_as_current_span("foo"):withtracer.start_as_current_span("bar"):print("Hello World from OpenTelemetry Python!")Using the span exporter with auto-instrumentationThe following code sample assumes you have set theNEW_RELIC_INSERT_KEYenvironment variable and installed the
following packages:opentelemetry-ext-newrelicopentelemetry-instrumentation-flaskflaskimportosfromopentelemetryimporttracefromopentelemetry.instrumentation.flaskimportFlaskInstrumentorfromopentelemetry.sdk.resourcesimportResourcefromopentelemetry.sdk.traceimportTracerProviderfromopentelemetry.sdk.trace.exportimportBatchExportSpanProcessorfromopentelemetry_ext_newrelicimportNewRelicSpanExporterfromflaskimportFlaskapp=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("/")defhello_world():return"Hello World!"@app.route("/error")defraise_500():raiseRuntimeError("Something happened!")if__name__=="__main__":app.run(port=8080)Find and use your dataFor tips on how to find and query your data in New Relic, seeFind
trace/span
data.For general querying information, see: -Query New Relic
data-Intro to
NRQLSupportNew 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 ChannelsNew Relic
Documentation:
Comprehensive guidance for using our platformNew Relic
Community: The
best place to engage in troubleshooting questionsNew Relic Developer: Resources
for building a custom observability applicationsNew Relic University: A range of
online training for New Relic users of every levelContributingWe 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 atopensource@newrelic.com.A note about vulnerabilitiesAs noted in oursecurity 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 throughHackerOne.Licenseopentelemetry-exporter-python is licensed under theApache
2.0License.LimitationsThe New Relic Telemetry APIs are rate limited. Please reference the
documentation forNew Relic Trace API requirements and
limitson the specifics of the rate limits.