API Reference

Trace Exporter

class opencensus_ext_newrelic.trace.DefaultTransport(exporter, grace_period=None, max_batch_size=600, wait_period=5.0)[source]

Bases: opencensus.common.transports.async_.AsyncTransport

stop()[source]

Terminate the background thread

class opencensus_ext_newrelic.trace.NewRelicTraceExporter(insert_key, service_name, transport=<class 'opencensus_ext_newrelic.trace.DefaultTransport'>, host=None, port=443)[source]

Bases: opencensus.trace.base_exporter.Exporter

Export Span data to the New Relic platform

This class is responsible for marshalling trace data to the New Relic platform.

Parameters
  • insert_key (str) – Insights insert key

  • service_name (str) – (optional) The name of the entity to report spans into. Defaults to “Python Application”.

  • transport (opencensus.common.transports.base.Transport) – (optional) Class for creating new transport objects. It should extend from the base_exporter opencensus.common.transports.base.Transport type and implement opencensus.common.transports.base.Transport.export(). Defaults to an async transport sending data every 5 seconds. The other option is opencensus.common.transports.async.AsyncTransport.

  • host (int) – (optional) Override the host for the API endpoint.

  • port – (optional) Override the port for the API endpoint.

Usage:

>>> import os
>>> from opencensus_ext_newrelic import NewRelicTraceExporter
>>> insert_key = os.environ.get("NEW_RELIC_INSERT_KEY")
>>> trace_exporter = NewRelicTraceExporter(
...     insert_key, service_name="My Service")
>>> trace_exporter.stop()
emit(span_datas)[source]

Immediately marshal span data to the tracing backend

Parameters

span_datas (list) – list of opencensus.trace.span_data.SpanData to emit

export(span_datas)[source]

Export the trace. Send trace to transport, and transport will call exporter.emit() to actually send the trace to the specified tracing backend.

Parameters

span_datas (list) – list of opencensus.trace.span_data.SpanData to export.

stop()[source]

Terminate the exporter and any background threads

Stats Exporter

class opencensus_ext_newrelic.stats.NewRelicStatsExporter(insert_key, service_name, interval=5, host=None, port=443)[source]

Bases: object

Export Metric data to the New Relic platform

This class is responsible for marshalling metric data to the New Relic platform.

Parameters
  • insert_key (str) – Insights insert key

  • interval (int or float) – (optional) Metrics will be sent every interval seconds. Default is 5 seconds.

  • host (str) – (optional) Override the host for the API endpoint.

  • port (int) – (optional) Override the port for the API endpoint.

Usage:

>>> import os
>>> from opencensus_ext_newrelic import NewRelicStatsExporter
>>> insert_key = os.environ.get("NEW_RELIC_INSERT_KEY")
>>> stats_exporter = NewRelicStatsExporter(
...     insert_key, service_name="My Service")
>>> stats_exporter.stop()
export_metrics(metrics)[source]

Immediately send all metric data to the monitoring backend.

Parameters

metrics (opencensus.metrics.export.metric.Metric) – list of Metric objects to send to the monitoring backend

on_register_view(view)[source]

Called when a view is registered with the view manager

Parameters

view (opencensus.stats.view.View) – View object to register

stop()[source]

Terminate the exporter background thread