Source code for opencensus.trace.print_exporter
# Copyright 2017, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Export the trace spans by printing them out."""
from opencensus.common.transports import sync
from opencensus.trace import base_exporter
[docs]class PrintExporter(base_exporter.Exporter):
"""Export the spans by printing them.
:type transport: :class:`type`
:param transport: Class for creating new transport objects. It should
extend from the base_exporter :class:`.Transport` type
and implement :meth:`.Transport.export`. Defaults to
:class:`.SyncTransport`. The other option is
:class:`.AsyncTransport`.
"""
def __init__(self, transport=sync.SyncTransport):
self.transport = transport(self)
[docs] def emit(self, span_datas):
"""
:type span_datas: list of :class:
`~opencensus.trace.span_data.SpanData`
:param list of opencensus.trace.span_data.SpanData span_datas:
SpanData tuples to emit
"""
print(span_datas)
[docs] def export(self, span_datas):
"""
:type span_datas: list of :class:
`~opencensus.trace.span_data.SpanData`
:param list of opencensus.trace.span_data.SpanData span_datas:
SpanData tuples to export
"""
self.transport.export(span_datas)