Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in RichConsoleSpanExporter #771

Closed
trondhindenes opened this issue Oct 24, 2021 · 2 comments · Fixed by #782
Closed

Bug in RichConsoleSpanExporter #771

trondhindenes opened this issue Oct 24, 2021 · 2 comments · Fixed by #782
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@trondhindenes
Copy link

Describe your environment
Python 3.9.7, Snippet from pipenv graph:

opentelemetry-exporter-richconsole==0.25b2
  - opentelemetry-api [required: ~=1.3, installed: 1.10a0]
  - opentelemetry-sdk [required: ~=1.3, installed: 1.10a0]
    - opentelemetry-api [required: ==1.10a0, installed: 1.10a0]
  - opentelemetry-semantic-conventions [required: ==0.25b2, installed: 0.25b2]
  - rich [required: >=10.0.0, installed: 10.12.0]
    - colorama [required: >=0.4.0,<0.5.0, installed: 0.4.4]
    - commonmark [required: >=0.9.0,<0.10.0, installed: 0.9.1]
    - pygments [required: >=2.6.0,<3.0.0, installed: 2.10.0]

Steps to reproduce
Given this code:

from opentelemetry import trace
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.exporter.richconsole import RichConsoleSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.sdk.trace.export import ConsoleSpanExporter

APP_SERVICE_NAME = "fastapi-goofing"

trace.set_tracer_provider(
    TracerProvider(
        resource=Resource.create({SERVICE_NAME: APP_SERVICE_NAME})
    )
)

rich_console_exporter = RichConsoleSpanExporter(
    service_name=APP_SERVICE_NAME,
)


console_exporter = ConsoleSpanExporter(
    service_name=APP_SERVICE_NAME
)

trace.get_tracer_provider().add_span_processor(
    BatchSpanProcessor(rich_console_exporter)
    #BatchSpanProcessor(console_exporter)
)
tracer = trace.get_tracer(__name__)

with tracer.start_as_current_span("foo"):
    with tracer.start_as_current_span("bar"):
        with tracer.start_as_current_span("baz"):
            print("Hello world from OpenTelemetry Python!")


The RichConsoleSpanExporter throws this error:

Exception while exporting Span batch.
Traceback (most recent call last):
  File "/home/trond/Documents/projects/fastapi-goofring/.venv/lib/python3.9/site-packages/opentelemetry/sdk/trace/export/__init__.py", line 331, in _export_batch
    self.span_exporter.export(self.spans_list[:idx])  # type: ignore
  File "/home/trond/Documents/projects/fastapi-goofring/.venv/lib/python3.9/site-packages/opentelemetry/exporter/richconsole/__init__.py", line 166, in export
    child = parents[span.parent.span_id].add(
AttributeError: 'NoneType' object has no attribute 'span_id'

If I replace the Rich exporter with the regular Console exporter, everything runs nicely without problems

What is the expected behavior?
Code runs without exceptions

What is the actual behavior?
Exception is thrown

Additional context

@trondhindenes trondhindenes added the bug Something isn't working label Oct 24, 2021
@owais owais added good first issue Good for newcomers help wanted Extra attention is needed labels Oct 24, 2021
@ocelotl ocelotl changed the title big in RichConsoleSpanExporter Bug in RichConsoleSpanExporter Oct 25, 2021
@lzchen
Copy link
Contributor

lzchen commented Oct 26, 2021

@tonybaloney fyi

@tonybaloney
Copy link
Contributor

@tonybaloney fyi

Thanks for the report. Will fix today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants