Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

OT Bridge - Initial implementation #6

Closed
wants to merge 103 commits into from
Closed

Commits on Oct 23, 2019

  1. Configuration menu
    Copy the full SHA
    3e495b9 View commit details
    Browse the repository at this point in the history
  2. Test OT shim

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    18a71c1 View commit details
    Browse the repository at this point in the history
  3. Rename wrapper classes

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    4745eca View commit details
    Browse the repository at this point in the history
  4. Add missing stubs

    Add missing stubs for fully implementing the Span and Scope classes
    from OpenTracing.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    16d5126 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ebfbcd2 View commit details
    Browse the repository at this point in the history
  6. Add TODO

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    fea256c View commit details
    Browse the repository at this point in the history
  7. Test setting span name

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    ad0ac64 View commit details
    Browse the repository at this point in the history
  8. Run black

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    3830cfc View commit details
    Browse the repository at this point in the history
  9. Re-organize imports

    - Explicitly use opentracing.* to make OpenTracing imports easily
    distinguishable.
    - Leave OpenTelemetry class names as-is.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    564c1f2 View commit details
    Browse the repository at this point in the history
  10. Make start_active_span() a context manager

    Since start_span() is a context manager and since we want the
    OpenTelemetry Span to stop when the SpanWrapper stops, we need to
    turn start_active_span() into a context manager and yield the
    ScopeWrapper rather than return it.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    bb72218 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    419c6f4 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    d6f5224 View commit details
    Browse the repository at this point in the history
  13. Implement set_tag

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    af35112 View commit details
    Browse the repository at this point in the history
  14. Implement start_span

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    2ce0fb8 View commit details
    Browse the repository at this point in the history
  15. Refactor basic shim test

    Move type test to a separate method because it's not related to
    start_active_span().
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    3cf9fa3 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    aa7024a View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    4361e48 View commit details
    Browse the repository at this point in the history
  18. Handle explicit parent

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    ac128bb View commit details
    Browse the repository at this point in the history
  19. Add TODOs

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    d60927b View commit details
    Browse the repository at this point in the history
  20. Implement SpanContextWrapper

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    8a759cd View commit details
    Browse the repository at this point in the history
  21. Add TODOs

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    190b480 View commit details
    Browse the repository at this point in the history
  22. Run Black

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    941d629 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    ecb3026 View commit details
    Browse the repository at this point in the history
  24. Add baggage method stub

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    db05d6c View commit details
    Browse the repository at this point in the history
  25. Implement active_span()

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    9efa7c5 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    1fe644d View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    43bbac8 View commit details
    Browse the repository at this point in the history
  28. Separate parent-child tests

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    c53ff56 View commit details
    Browse the repository at this point in the history
  29. Run Black

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    5e5e6cf View commit details
    Browse the repository at this point in the history
  30. Ignore "format" argument in inject/extract

    The inject() and extract() methods on opentracing.Tracer have an
    argument called "format", which clashes with a Python builtin. We
    can't rename the argument in the subclass without generating W0221.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    fe41317 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    1bdf9a7 View commit details
    Browse the repository at this point in the history
  32. Sort imports

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    550b461 View commit details
    Browse the repository at this point in the history
  33. Remove TODO

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    13433b2 View commit details
    Browse the repository at this point in the history
  34. Verify child span's parent field is correct

    Verify the `parent` field of the child span is set to the parent span
    object.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    26908a3 View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    d1f1afc View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    b16650b View commit details
    Browse the repository at this point in the history
  37. Make active_span return a wrapped span

    We can't return an OTel object to the consumer of the OT API.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    d398c8c View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    f214aa7 View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    89ec88c View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    cdf42b9 View commit details
    Browse the repository at this point in the history
  41. Implement log_kv

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    ac45a5c View commit details
    Browse the repository at this point in the history
  42. Handle event name in log_kv()

    Since the OpenTelemetry API expects an event name and the OpenTracing
    API doesn't provide this information, we use a helper function to
    derive an event name from the key-value pairs passed to the
    `log_kv()` method.
    
    The helper function is adapted from the Java OpenTracing bridge
    implementation:
    https://github.com/open-telemetry/opentelemetry-java/blob/2379965a97c306f160de510d47daaaa77ef32550/opentracing_shim/src/main/java/io/opentelemetry/opentracingshim/SpanShim.java#L152
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    a21f490 View commit details
    Browse the repository at this point in the history
  43. Remove unused context manager methods

    `__enter__()` and `__exit__()` on `SpanWrapper` aren't needed because
    the same methods on the base class `opentracing.Span` do what we need
    them to do when `SpanWrapper` is used as a context manager.
    
    `__enter__()` and `__exit__()` on `ScopeWrapper` aren't needed
    because we use the `@contextmanager` decorator on
    `start_active_span(). When the `with start_active_span()` block ends,
    the `with` block in the *implementation* of `start_active_span()`
    ends as well, which in turn makes the `with` block in OpenTelemetry's
    `start_span()` end, which makes the `finally` block in `use_span()`
    run, which calls `end()` on the OpenTelemetry span.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    b9c8ae3 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    5bf6592 View commit details
    Browse the repository at this point in the history
  45. Configuration menu
    Copy the full SHA
    5eba267 View commit details
    Browse the repository at this point in the history
  46. Refactor tests

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    29e75a9 View commit details
    Browse the repository at this point in the history
  47. Implement ScopeManager

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    1537c52 View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    25ceeca View commit details
    Browse the repository at this point in the history
  49. Configuration menu
    Copy the full SHA
    f1e4cba View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    4bf91c1 View commit details
    Browse the repository at this point in the history
  51. Wrap context in start_span()

    We shouldn't return an OpenTelemetry object to OpenTracing API calls.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    6f9d22c View commit details
    Browse the repository at this point in the history
  52. Raise exception on invalid parent type

    According to the OpenTracing API, `child_of` can only be of type
    `Span` or `SpanContext`. In the shim these are represented as
    `SpanWrapper` and `SpanContextWrapper`, respectively. In case we
    receive a different type in `child_of`, it's safer to bail out than
    to try to set an unexpected object as the span's parent.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    a3cb8b0 View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    b726baf View commit details
    Browse the repository at this point in the history
  54. Add TODO

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    74735d5 View commit details
    Browse the repository at this point in the history
  55. Add TODOs

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    cfa9ff8 View commit details
    Browse the repository at this point in the history
  56. Implement references

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    1c68052 View commit details
    Browse the repository at this point in the history
  57. Add TODO

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    af038a2 View commit details
    Browse the repository at this point in the history
  58. Handle tags on span creation

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    e57b5f0 View commit details
    Browse the repository at this point in the history
  59. Configuration menu
    Copy the full SHA
    0d15ec6 View commit details
    Browse the repository at this point in the history
  60. Configuration menu
    Copy the full SHA
    efa0f0c View commit details
    Browse the repository at this point in the history
  61. Overall refactor

    - Reorder tests.
    - Replace `otel_*` properties with `unwrap()` method.
    - Use correct type in `tracer` argument of `ScopeManagerWrapper`.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    f45ef7b View commit details
    Browse the repository at this point in the history
  62. Test explicit span finish

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    a4cce55 View commit details
    Browse the repository at this point in the history
  63. Configuration menu
    Copy the full SHA
    1901cec View commit details
    Browse the repository at this point in the history
  64. Use context manager where possible

    Use a `with` statement to finish spans automatically where possible,
    i.e. when not testing things which require explicit calling to
    `span.finish()`.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    1f8fd20 View commit details
    Browse the repository at this point in the history
  65. Disable too-many-public-methods Pylint check

    We have many methods because we have many tests.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    45ed0b9 View commit details
    Browse the repository at this point in the history
  66. Update README

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    c32c278 View commit details
    Browse the repository at this point in the history
  67. Configuration menu
    Copy the full SHA
    92b760f View commit details
    Browse the repository at this point in the history
  68. Handle time conversion between OT and OTel

    Handle time format differences between OpenTracing and OpenTelemetry.
    OpenTracing expects time values in seconds since the epoch represented
    as floats. OpenTelemetry expects time values in nanoseconds since the
    epoch represented as ints.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    b6abe12 View commit details
    Browse the repository at this point in the history
  69. Configuration menu
    Copy the full SHA
    fca38ad View commit details
    Browse the repository at this point in the history
  70. Return self for call chaining on SpanWrapper

    Return `self` from all "setter" methods on `SpanWrapper` to allow
    call chaining.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    e04c073 View commit details
    Browse the repository at this point in the history
  71. Remove type hints

    It seems we cannot consistently use Python type hints in the
    OpenTracing shim since we rely on the `opentracing` library which
    doesn't contain type hints, nor does it have PEP 561 compliant stub
    packages or a module on typeshed.
    
    Rather than including partial typing information it's better not to
    include typing information at all.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    ca8146f View commit details
    Browse the repository at this point in the history
  72. Add TODO

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    a263f18 View commit details
    Browse the repository at this point in the history
  73. Configuration menu
    Copy the full SHA
    b1f362f View commit details
    Browse the repository at this point in the history
  74. Configuration menu
    Copy the full SHA
    fe77380 View commit details
    Browse the repository at this point in the history
  75. Clean up OpenTracing inheritance

    In some cases we had duplicated logic from the base class' `__init__`
    method. In others we had overridden methods with the same logic as
    the equivalent methods in the base class.
    
    We clean up the above and add comments to help understand some of the
    inheritance-related choices.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    0252f6c View commit details
    Browse the repository at this point in the history
  76. Configuration menu
    Copy the full SHA
    442dd5c View commit details
    Browse the repository at this point in the history
  77. Handle inaccuracies in time conversions

    Due to the differences between decimal and binary float
    representations, some time values yield "surprising" results when
    performing float arithmetic operations to convert seconds to
    nanoseconds and vice versa.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    8fd39ef View commit details
    Browse the repository at this point in the history
  78. Configuration menu
    Copy the full SHA
    9453625 View commit details
    Browse the repository at this point in the history
  79. Rename package to opentelemetry-opentracing-shim

    "ot" isn't clear enough and could lead to confusion.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    78183cc View commit details
    Browse the repository at this point in the history
  80. Configuration menu
    Copy the full SHA
    4f88e7c View commit details
    Browse the repository at this point in the history
  81. Don't override active_span on TracerWrapper

    If the user passes a custom ScopeManager, we want the TracerWrapper
    to call `active_span` on the custom ScopeManager.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    8a7c1a7 View commit details
    Browse the repository at this point in the history
  82. Configuration menu
    Copy the full SHA
    cbe971b View commit details
    Browse the repository at this point in the history
  83. Don't raise on unimplemented methods

    Log a warning instead in order not to break application code.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    97f3734 View commit details
    Browse the repository at this point in the history
  84. Configuration menu
    Copy the full SHA
    0017eee View commit details
    Browse the repository at this point in the history
  85. Let the OTel implementation create event timestamps

    Let the OTel implementation create event timestamps instead of
    generating a timestamp in the shim, i.e. outside of OpenTelemetry.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    c644c10 View commit details
    Browse the repository at this point in the history
  86. Refactor scope handling

    - Remove an unnecessary context manager layers.
    - Allow creating `ContextWrapper` objects either from a `SpanWrapper`
      or from a `Span` context manager.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    55e692a View commit details
    Browse the repository at this point in the history
  87. Configuration menu
    Copy the full SHA
    9210853 View commit details
    Browse the repository at this point in the history
  88. Clean up test setup

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    cb41689 View commit details
    Browse the repository at this point in the history
  89. Configuration menu
    Copy the full SHA
    04d44e3 View commit details
    Browse the repository at this point in the history
  90. Don't allow using arbitrary scope managers

    Until we figure out how to handle unsupported frameworks (e.g.
    gevent), we remove the `scope_manager` argument of `create_tracer`
    to avoid breaking the OpenTelemetry context propagation.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    add02e7 View commit details
    Browse the repository at this point in the history
  91. Remove unnecessary comments.

    These are obvious and therefore unnecessary.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    c2b03a7 View commit details
    Browse the repository at this point in the history
  92. Remove TODO

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    ecfd2b8 View commit details
    Browse the repository at this point in the history
  93. Don't accept scalar values in references argument

    The API docs are clear about the `references` argument being a list.
    We don't try to compensate for wrong argument types elsewhere, so no
    reason to do that here.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    3a78b2c View commit details
    Browse the repository at this point in the history
  94. Rename XWrapper to XShim

    Not all classes in the shim are actually wrappers, which makes the
    XWrapper naming convention confusing. XShim is more neutral.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    10f72ac View commit details
    Browse the repository at this point in the history
  95. Configuration menu
    Copy the full SHA
    aee40a3 View commit details
    Browse the repository at this point in the history
  96. Append exception info to span

    In the OpenTracing API, when an exception occurs while a span is
    active, information about the exception is added to the span as logs
    and a tag is added as well. We re-add this functionality to the shim
    since we've overridden the `__exit__()` method in which it lives.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    f2e91c8 View commit details
    Browse the repository at this point in the history
  97. Refactor ScopeShim

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    f093ee1 View commit details
    Browse the repository at this point in the history
  98. Don't validate parent type

    Validating the parent type complicates the logic of `start_span()`.
    Since the OpenTracing API clearly specifies the valid types for a
    parent span, it's the user's responsibility to specify a valid
    parent.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    1f4cc3c View commit details
    Browse the repository at this point in the history
  99. Verify ScopeShim.close() deactivates span

    Verify that calling `close()` on a `ScopeShim` deactivates the span
    in the OpenTelemetry tracer.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    970ce6a View commit details
    Browse the repository at this point in the history
  100. Wrap span context properly

    We shouldn't return OpenTelemetry objects to the OpenTracing API.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    fc12138 View commit details
    Browse the repository at this point in the history
  101. Configuration menu
    Copy the full SHA
    fc6f34e View commit details
    Browse the repository at this point in the history
  102. Add TODO

    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    7860f55 View commit details
    Browse the repository at this point in the history
  103. Rename tracer argument of create_tracer()

    Make it clearer that the provided tracer object should be an
    OpenTelemetry tracer, not an OpenTracing tracer.
    johananl committed Oct 23, 2019
    Configuration menu
    Copy the full SHA
    082183a View commit details
    Browse the repository at this point in the history