Skip to content

Commit

Permalink
Update Version of opentelemetry (#10046)
Browse files Browse the repository at this point in the history
* Update Version

* tracer

* update shared reqs

* trace_source

* some changes

* fix test

* readme

* changelog

* Delete opentelemetry_span

* typo

* minor change

* pin version

* fix rebase
  • Loading branch information
rakshith91 authored Mar 6, 2020
1 parent 78c88c1 commit bec3f56
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions sdk/core/azure-core-tracing-opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

### Features

- Pinned opentelemetry-api to version 0.3a0
- Pinned opentelemetry-api to version 0.4a0

## 1.0.0b1 Unreleased
## 1.0.0b1

### Features

Expand Down
8 changes: 4 additions & 4 deletions sdk/core/azure-core-tracing-opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ exporter = AzureMonitorSpanExporter(
# Regular open telemetry usage from here, see https://github.com/open-telemetry/opentelemetry-python
# for details
from opentelemetry import trace
from opentelemetry.sdk.trace import Tracer
from opentelemetry.sdk.trace import TracerSource
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor

# Simple console exporter
exporter = ConsoleSpanExporter()

trace.set_preferred_tracer_implementation(lambda T: Tracer())
tracer = trace.tracer()
tracer.add_span_processor(
trace.set_preferred_tracer_implementation(lambda T: TracerSource())
tracer = trace.get_tracer(__name__)
tracer.tracer_source().add_span_processor(
SimpleExportSpanProcessor(exporter)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
# ------------------------------------
"""Implements azure.core.tracing.AbstractSpan to wrap OpenTelemetry spans."""

from opentelemetry.trace import Span, Link, Tracer, SpanKind as OpenTelemetrySpanKind, tracer
from opentelemetry.context import Context
from opentelemetry import trace
from opentelemetry.trace import Span, Link, Tracer, SpanKind as OpenTelemetrySpanKind
from opentelemetry.context import with_current_context
from opentelemetry.propagators import extract, inject

from azure.core.tracing import SpanKind, HttpSpanMixin # pylint: disable=no-name-in-module
Expand Down Expand Up @@ -208,7 +209,7 @@ def get_current_tracer(cls):
"""
Get the current tracer from the execution context. Return None otherwise.
"""
return tracer()
return trace.get_tracer(__name__, __version__)

@classmethod
def change_context(cls, span):
Expand Down Expand Up @@ -244,4 +245,4 @@ def with_current_context(cls, func):
:param func: The function that will be run in the new context
:return: The target the pass in instead of the function
"""
return Context.with_current_context(func)
return with_current_context(func)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-e ../../../tools/azure-sdk-tools
../azure-core
opentelemetry-sdk==0.3a0
opentelemetry-sdk==0.4a0
2 changes: 1 addition & 1 deletion sdk/core/azure-core-tracing-opentelemetry/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
],
python_requires=">=3.5.0",
install_requires=[
'opentelemetry-api==0.3a0',
'opentelemetry-api==0.4a0',
'azure-core<2.0.0,>=1.0.0',
],
extras_require={
Expand Down
6 changes: 3 additions & 3 deletions sdk/core/azure-core-tracing-opentelemetry/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# Licensed under the MIT License.
# ------------------------------------
from opentelemetry import trace
from opentelemetry.sdk.trace import Tracer
from opentelemetry.sdk.trace import TracerSource

import pytest


@pytest.fixture(scope="session")
def tracer():
trace.set_preferred_tracer_implementation(lambda T: Tracer())
return trace.tracer()
trace.set_preferred_tracer_source_implementation(lambda T: TracerSource())
return trace.get_tracer(__name__)
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_no_span_passed_in_with_no_environ(self, tracer):

def test_span(self, tracer):
with tracer.start_as_current_span("Root") as parent:
assert OpenTelemetrySpan.get_current_tracer() is tracer
assert OpenTelemetrySpan.get_current_tracer().source is tracer.source
with OpenTelemetrySpan() as wrapped_span:
assert wrapped_span.span_instance is tracer.get_current_span()

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/azure/core/tracing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from ._abstract_span import AbstractSpan, SpanKind, HttpSpanMixin
from azure.core.tracing._abstract_span import AbstractSpan, SpanKind, HttpSpanMixin

__all__ = [
"AbstractSpan", "SpanKind", "HttpSpanMixin"
Expand Down
2 changes: 1 addition & 1 deletion shared_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ six>=1.6
opencensus>=0.6.0
opencensus-ext-threading
opencensus-ext-azure>=0.3.1
opentelemetry-api==0.3a0
opentelemetry-api==0.4a0
#override azure-eventhub-checkpointstoreblob msrest>=0.6.10
#override azure-eventhub-checkpointstoreblob azure-core<2.0.0,>=1.2.2
#override azure-eventhub-checkpointstoreblob-aio msrest>=0.6.10
Expand Down

0 comments on commit bec3f56

Please sign in to comment.