# Buggy code
def _extract_logs_from_span(span):
    if span.time_events is None:
        return None

    logs = []
    for time_event in span.time_events:
        annotation = time_event.annotation
        if not annotation:
            continue
        fields = _extract_tags(annotation.attributes)

        fields.append(
            jaeger.Tag(
                key="message", vType=jaeger.TagType.STRING, vStr=annotation.description
            )
        )

        event_time = datetime.datetime.strptime(
            time_event.timestamp, ISO_DATETIME_REGEX
        )
        timestamp = calendar.timegm(event_time.timetuple()) * 1000

        logs.append(jaeger.Log(timestamp=timestamp, fields=fields))
    return logs


# Traceback (AttributeError)
Traceback (most recent call last):
File "main.py", line 37, in <module>
main()
File "main.py", line 33, in main
more_work()
File "/Users/tw/.local/share/virtualenvs/census-K4PTEclS/lib/python3.6/site-packages/opencensus/trace/span.py", line 251, in __exit__
self.context_tracer.end_span()
File "/Users/tw/.local/share/virtualenvs/census-K4PTEclS/lib/python3.6/site-packages/opencensus/trace/tracers/context_tracer.py", line 123, in end_span
self.exporter.export(span_datas)
File "/Users/tw/.local/share/virtualenvs/census-K4PTEclS/lib/python3.6/site-packages/opencensus/trace/exporters/jaeger_exporter.py", line 160, in export
self.transport.export(span_datas)
File "/Users/tw/.local/share/virtualenvs/census-K4PTEclS/lib/python3.6/site-packages/opencensus/trace/exporters/transports/sync.py", line 23, in export
self.exporter.emit(span_datas)
File "/Users/tw/.local/share/virtualenvs/census-K4PTEclS/lib/python3.6/site-packages/opencensus/trace/exporters/jaeger_exporter.py", line 140, in emit
jaeger_spans = self.translate_to_jaeger(span_datas)
File "/Users/tw/.local/share/virtualenvs/census-K4PTEclS/lib/python3.6/site-packages/opencensus/trace/exporters/jaeger_exporter.py", line 208, in translate_to_jaeger
logs = _extract_logs_from_span(span)
File "/Users/tw/.local/share/virtualenvs/census-K4PTEclS/lib/python3.6/site-packages/opencensus/trace/exporters/jaeger_exporter.py", line 283, in _extract_logs_from_span
fields = _extract_tags(annotation.attributes)
File "/Users/tw/.local/share/virtualenvs/census-K4PTEclS/lib/python3.6/site-packages/opencensus/trace/exporters/jaeger_exporter.py", line 302, in _extract_tags
for attribute_key, attribute_value in attr.items():
AttributeError: 'Attributes' object has no attribute 'items'

# Fixed code
def _extract_logs_from_span(span):
    if span.time_events is None:
        return None

    logs = []
    for time_event in span.time_events:
        annotation = time_event.annotation
        if not annotation:
            continue

        fields = []
        if annotation.attributes is not None:
            fields = _extract_tags(annotation.attributes.attributes)

        fields.append(
            jaeger.Tag(
                key="message", vType=jaeger.TagType.STRING, vStr=annotation.description
            )
        )

        event_time = datetime.datetime.strptime(
            time_event.timestamp, ISO_DATETIME_REGEX
        )
        timestamp = calendar.timegm(event_time.timetuple()) * 1000

        logs.append(jaeger.Log(timestamp=timestamp, fields=fields))
    return logs