Skip to content

Commit

Permalink
Fixing mypy.
Browse files Browse the repository at this point in the history
mypy needs re-exports called out explicitly in one of two ways:

* in the __all__ param
* using the "import y as x" syntax.

Modifying the imports to work in this fashion solves the issue.
  • Loading branch information
toumorokoshi committed May 5, 2020
1 parent 885228c commit aa128fe
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Empty file.
29 changes: 29 additions & 0 deletions opentelemetry-api/src/opentelemetry/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,35 @@
`set_tracer_provider`.
"""

__all__ = [
"DEFAULT_TRACE_OPTIONS",
"DEFAULT_TRACE_STATE",
"INVALID_SPAN",
"INVALID_SPAN_CONTEXT",
"INVALID_SPAN_ID",
"INVALID_TRACE_ID",
"DefaultSpan",
"DefaultTracer",
"DefaultTracerProvider",
"LazyLink",
"Link",
"LinkBase",
"ParentSpan",
"Span",
"SpanContext",
"SpanKind",
"TraceFlags",
"TraceState",
"TracerProvider",
"Tracer",
"format_span_id",
"format_trace_id",
"get_current_span",
"get_tracer",
"get_tracer_provider",
"set_tracer_provider",
]

import abc
import enum
import types as python_types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ def inject(
See `opentelemetry.trace.propagation.httptextformat.HTTPTextFormat.inject`
"""
span_context = trace.get_current_span(context).get_context()

span = trace.get_current_span(context)
if span is None:
return
span_context = span.get_context()
if span_context == trace.INVALID_SPAN_CONTEXT:
return
traceparent_string = "00-{:032x}-{:016x}-{:02x}".format(
Expand Down

0 comments on commit aa128fe

Please sign in to comment.