Skip to content

Commit 0917dad

Browse files
authored
Sync with Remove time_ns from API (#342)
1 parent 9ef4410 commit 0917dad

File tree

7 files changed

+30
-15
lines changed
  • .github/workflows
  • exporter/opentelemetry-exporter-datadog/src/opentelemetry/exporter/datadog
  • instrumentation
    • opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon
    • opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask
    • opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid
    • opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado

7 files changed

+30
-15
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- 'release/*'
77
pull_request:
88
env:
9-
CORE_REPO_SHA: 10dc3a8bc031d5b355f62a698094a03eedb2a8ee
9+
CORE_REPO_SHA: d3694fc520f8542b232fd1065133286f4591dcec
1010

1111
jobs:
1212
build:

exporter/opentelemetry-exporter-datadog/src/opentelemetry/exporter/datadog/spanprocessor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from opentelemetry.sdk.trace import Span, SpanProcessor
2222
from opentelemetry.sdk.trace.export import SpanExporter
2323
from opentelemetry.trace import INVALID_TRACE_ID
24-
from opentelemetry.util.time import time_ns
24+
from opentelemetry.util._time import _time_ns
2525

2626
logger = logging.getLogger(__name__)
2727

@@ -127,9 +127,9 @@ def worker(self):
127127
break
128128

129129
# substract the duration of this export call to the next timeout
130-
start = time_ns()
130+
start = _time_ns()
131131
self.export()
132-
end = time_ns()
132+
end = _time_ns()
133133
duration = (end - start) / 1e9
134134
timeout = self.schedule_delay_millis / 1e3 - duration
135135

instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def on_get(self, req, resp):
5858
)
5959
from opentelemetry.propagate import extract
6060
from opentelemetry.trace.status import Status
61+
from opentelemetry.util._time import _time_ns
6162
from opentelemetry.util.http import get_excluded_urls, get_traced_request_attrs
62-
from opentelemetry.util.time import time_ns
6363

6464
_logger = getLogger(__name__)
6565

@@ -108,7 +108,7 @@ def __call__(self, env, start_response):
108108
if _excluded_urls.url_disabled(env.get("PATH_INFO", "/")):
109109
return super().__call__(env, start_response)
110110

111-
start_time = time_ns()
111+
start_time = _time_ns()
112112

113113
token = context.attach(extract(otel_wsgi.carrier_getter, env))
114114
span = self._tracer.start_span(

instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def hello():
5656
from opentelemetry.instrumentation.flask.version import __version__
5757
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
5858
from opentelemetry.propagate import extract
59+
from opentelemetry.util._time import _time_ns
5960
from opentelemetry.util.http import get_excluded_urls
60-
from opentelemetry.util.time import time_ns
6161

6262
_logger = getLogger(__name__)
6363

@@ -85,7 +85,7 @@ def _wrapped_app(wrapped_app_environ, start_response):
8585
# In theory, we could start the span here and use
8686
# update_name later but that API is "highly discouraged" so
8787
# we better avoid it.
88-
wrapped_app_environ[_ENVIRON_STARTTIME_KEY] = time_ns()
88+
wrapped_app_environ[_ENVIRON_STARTTIME_KEY] = _time_ns()
8989

9090
def _start_response(status, response_headers, *args, **kwargs):
9191
if not _excluded_urls.url_disabled(flask.request.url):

instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
from logging import getLogger
216

317
from pyramid.events import BeforeTraversal
@@ -9,8 +23,8 @@
923
from opentelemetry import context, trace
1024
from opentelemetry.instrumentation.pyramid.version import __version__
1125
from opentelemetry.propagate import extract
26+
from opentelemetry.util._time import _time_ns
1227
from opentelemetry.util.http import get_excluded_urls
13-
from opentelemetry.util.time import time_ns
1428

1529
TWEEN_NAME = "opentelemetry.instrumentation.pyramid.trace_tween_factory"
1630
SETTING_TRACE_ENABLED = "opentelemetry-pyramid.trace_enabled"
@@ -112,7 +126,7 @@ def trace_tween(request):
112126
return handler(request)
113127

114128
request.environ[_ENVIRON_ENABLED_KEY] = True
115-
request.environ[_ENVIRON_STARTTIME_KEY] = time_ns()
129+
request.environ[_ENVIRON_STARTTIME_KEY] = _time_ns()
116130

117131
try:
118132
response = handler(request)

instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def get(self):
3535
tornado.ioloop.IOLoop.current().start()
3636
"""
3737

38+
3839
from collections import namedtuple
3940
from functools import partial
4041
from logging import getLogger
@@ -54,8 +55,8 @@ def get(self):
5455
from opentelemetry.propagate import extract
5556
from opentelemetry.propagators.textmap import DictGetter
5657
from opentelemetry.trace.status import Status
58+
from opentelemetry.util._time import _time_ns
5759
from opentelemetry.util.http import get_excluded_urls, get_traced_request_attrs
58-
from opentelemetry.util.time import time_ns
5960

6061
from .client import fetch_async # pylint: disable=E0401
6162

@@ -148,7 +149,7 @@ def _wrap(cls, method_name, wrapper):
148149

149150

150151
def _prepare(tracer, func, handler, args, kwargs):
151-
start_time = time_ns()
152+
start_time = _time_ns()
152153
request = handler.request
153154
if _excluded_urls.url_disabled(request.uri):
154155
return func(*args, **kwargs)
@@ -225,7 +226,7 @@ def _finish_span(tracer, handler, error=None):
225226
if isinstance(error, tornado.web.HTTPError):
226227
status_code = error.status_code
227228
if not ctx and status_code == 404:
228-
ctx = _start_span(tracer, handler, time_ns())
229+
ctx = _start_span(tracer, handler, _time_ns())
229230
if status_code != 404:
230231
finish_args = (
231232
type(error),

instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from opentelemetry.instrumentation.utils import http_status_to_status_code
2121
from opentelemetry.propagate import inject
2222
from opentelemetry.trace.status import Status
23-
from opentelemetry.util.time import time_ns
23+
from opentelemetry.util._time import _time_ns
2424

2525

2626
def _normalize_request(args, kwargs):
@@ -40,7 +40,7 @@ def _normalize_request(args, kwargs):
4040

4141

4242
def fetch_async(tracer, func, _, args, kwargs):
43-
start_time = time_ns()
43+
start_time = _time_ns()
4444

4545
# Return immediately if no args were provided (error)
4646
# or original_request is set (meaning we are in a redirect step).

0 commit comments

Comments
 (0)