New Relic Telemetry SDK
newrelic-telemetry-sdk-python provides a Python library for sending data into New Relic using the Python urllib3 library.
See dimensional metrics, events, logs, and spans/traces in New Relic, without having to use an agent!
Installing newrelic_telemetry_sdk
To start, the newrelic-telemetry-sdk package must be installed. To install through pip:
$ pip install newrelic-telemetry-sdk
If that fails, download the library from its GitHub page and install it using:
$ python setup.py install
Reporting your first metric
There are 3 different types of metrics:
GaugeMetric
CountMetric
SummaryMetric
Metric descriptions
Metric type |
Interval required |
Description |
Example |
|---|---|---|---|
Gauge |
No |
A single value at a single point in time. |
Room Temperature. |
Count |
Yes |
Track the total number of occurrences of an event. |
Number of errors that have occurred. |
Summary |
Yes |
Track count, sum, min, and max values over time. |
The summarized duration of 100 HTTP requests. |
Example
The example code assumes you’ve set the following environment variables:
NEW_RELIC_LICENSE_KEY
import os
import time
from newrelic_telemetry_sdk import GaugeMetric, CountMetric, SummaryMetric, MetricClient
metric_client = MetricClient(os.environ["NEW_RELIC_LICENSE_KEY"])
temperature = GaugeMetric("temperature", 78.6, {"units": "Farenheit"})
# Record that there have been 5 errors in the last 2 seconds
errors = CountMetric(name="errors", value=5, interval_ms=2000)
# Record a summary of 10 response times over the last 2 seconds
summary = SummaryMetric(
"responses", count=10, min=0.2, max=0.5, sum=4.7, interval_ms=2000
)
batch = [temperature, errors, summary]
response = metric_client.send_batch(batch)
response.raise_for_status()
print("Sent metrics successfully!")
Reporting your first event
Events represent a record of something that has occurred on a system being monitored. The example code assumes you’ve set the following environment variables:
NEW_RELIC_LICENSE_KEY
import os
import time
from newrelic_telemetry_sdk import Event, EventClient
# Record that a rate limit has been applied to an endpoint for an account
event = Event(
"RateLimit", {"path": "/v1/endpoint", "accountId": 1000, "rejectRatio": 0.1}
)
event_client = EventClient(os.environ["NEW_RELIC_LICENSE_KEY"])
response = event_client.send(event)
response.raise_for_status()
print("Event sent successfully!")
Reporting your first log message
Log messages are generated by applications, usually via the Python logging module. These messages are used to audit and diagnose issues with an operating application. The example code assumes you’ve set the following environment variables:
NEW_RELIC_LICENSE_KEY
import os
from newrelic_telemetry_sdk import Log, LogClient
log = Log("Hello World!")
log_client = LogClient(os.environ["NEW_RELIC_LICENSE_KEY"])
response = log_client.send(log)
response.raise_for_status()
print("Log sent successfully!")
Reporting your first span
Spans provide an easy way to time components of your code. The example code assumes you’ve set the following environment variables:
NEW_RELIC_LICENSE_KEY
import os
import time
from newrelic_telemetry_sdk import Span, SpanClient
with Span(name="sleep") as span:
time.sleep(0.5)
span_client = SpanClient(os.environ["NEW_RELIC_LICENSE_KEY"])
response = span_client.send(span)
response.raise_for_status()
print("Span sleep sent successfully!")
Find and use data
Tips on how to find and query your data in New Relic:
For general querying information, see:
Limitations
The New Relic Telemetry APIs are rate limited. Please reference the documentation for New Relic Metrics API and New Relic Trace API requirements and limits on the specifics of the rate limits.
Metadata
Release files for newrelic-telemetry-sdk 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| newrelic_telemetry_sdk-0.9.0.tar.gz | 43.6 kB | With provenance | Details for newrelic_telemetry_sdk-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| newrelic_telemetry_sdk-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for newrelic_telemetry_sdk-0.9.0-py3-none-any.whl |
Total release size: 67.7 kB
Release files / newrelic_telemetry_sdk-0.9.0.tar.gz
| Download URL | newrelic_telemetry_sdk-0.9.0.tar.gz |
|---|---|
| Size | 43.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1303d4167ee059481fd0d11e1d494a5ba5a63d1469c0c8f93804e01d4f5282e
|
|
BLAKE2b-256 checksum How to use checksums |
65acf519c87cb993f0bdcc1ed4585e669c495b252d627f9665508141002d80ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2025.
Transparency logRelease files / newrelic_telemetry_sdk-0.9.0-py3-none-any.whl
| Download URL | newrelic_telemetry_sdk-0.9.0-py3-none-any.whl |
|---|---|
| Size | 24.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ce9175c1d263470aef2ef32283d1d6a39c001b7f59a6f2b259405bf5342851f
|
|
BLAKE2b-256 checksum How to use checksums |
c74ef04747c6f97236bcd669ee8bfcd9fcfc0ea690a93e9621e6a43bba6959bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2025.
Transparency logSecurity for newrelic-telemetry-sdk 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for newrelic_telemetry_sdk-0.9.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.