mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-28 20:52:57 +08:00
Sync with Remove time_ns from API (#342)
This commit is contained in:
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -6,7 +6,7 @@ on:
|
||||
- 'release/*'
|
||||
pull_request:
|
||||
env:
|
||||
CORE_REPO_SHA: 10dc3a8bc031d5b355f62a698094a03eedb2a8ee
|
||||
CORE_REPO_SHA: d3694fc520f8542b232fd1065133286f4591dcec
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
@ -21,7 +21,7 @@ from opentelemetry.context import Context, attach, detach, set_value
|
||||
from opentelemetry.sdk.trace import Span, SpanProcessor
|
||||
from opentelemetry.sdk.trace.export import SpanExporter
|
||||
from opentelemetry.trace import INVALID_TRACE_ID
|
||||
from opentelemetry.util.time import time_ns
|
||||
from opentelemetry.util._time import _time_ns
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -127,9 +127,9 @@ class DatadogExportSpanProcessor(SpanProcessor):
|
||||
break
|
||||
|
||||
# substract the duration of this export call to the next timeout
|
||||
start = time_ns()
|
||||
start = _time_ns()
|
||||
self.export()
|
||||
end = time_ns()
|
||||
end = _time_ns()
|
||||
duration = (end - start) / 1e9
|
||||
timeout = self.schedule_delay_millis / 1e3 - duration
|
||||
|
||||
|
@ -58,8 +58,8 @@ from opentelemetry.instrumentation.utils import (
|
||||
)
|
||||
from opentelemetry.propagate import extract
|
||||
from opentelemetry.trace.status import Status
|
||||
from opentelemetry.util._time import _time_ns
|
||||
from opentelemetry.util.http import get_excluded_urls, get_traced_request_attrs
|
||||
from opentelemetry.util.time import time_ns
|
||||
|
||||
_logger = getLogger(__name__)
|
||||
|
||||
@ -108,7 +108,7 @@ class _InstrumentedFalconAPI(falcon.API):
|
||||
if _excluded_urls.url_disabled(env.get("PATH_INFO", "/")):
|
||||
return super().__call__(env, start_response)
|
||||
|
||||
start_time = time_ns()
|
||||
start_time = _time_ns()
|
||||
|
||||
token = context.attach(extract(otel_wsgi.carrier_getter, env))
|
||||
span = self._tracer.start_span(
|
||||
|
@ -56,8 +56,8 @@ from opentelemetry import context, trace
|
||||
from opentelemetry.instrumentation.flask.version import __version__
|
||||
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
||||
from opentelemetry.propagate import extract
|
||||
from opentelemetry.util._time import _time_ns
|
||||
from opentelemetry.util.http import get_excluded_urls
|
||||
from opentelemetry.util.time import time_ns
|
||||
|
||||
_logger = getLogger(__name__)
|
||||
|
||||
@ -85,7 +85,7 @@ def _rewrapped_app(wsgi_app):
|
||||
# In theory, we could start the span here and use
|
||||
# update_name later but that API is "highly discouraged" so
|
||||
# we better avoid it.
|
||||
wrapped_app_environ[_ENVIRON_STARTTIME_KEY] = time_ns()
|
||||
wrapped_app_environ[_ENVIRON_STARTTIME_KEY] = _time_ns()
|
||||
|
||||
def _start_response(status, response_headers, *args, **kwargs):
|
||||
if not _excluded_urls.url_disabled(flask.request.url):
|
||||
|
@ -1,3 +1,17 @@
|
||||
# Copyright The OpenTelemetry Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from logging import getLogger
|
||||
|
||||
from pyramid.events import BeforeTraversal
|
||||
@ -9,8 +23,8 @@ import opentelemetry.instrumentation.wsgi as otel_wsgi
|
||||
from opentelemetry import context, trace
|
||||
from opentelemetry.instrumentation.pyramid.version import __version__
|
||||
from opentelemetry.propagate import extract
|
||||
from opentelemetry.util._time import _time_ns
|
||||
from opentelemetry.util.http import get_excluded_urls
|
||||
from opentelemetry.util.time import time_ns
|
||||
|
||||
TWEEN_NAME = "opentelemetry.instrumentation.pyramid.trace_tween_factory"
|
||||
SETTING_TRACE_ENABLED = "opentelemetry-pyramid.trace_enabled"
|
||||
@ -112,7 +126,7 @@ def trace_tween_factory(handler, registry):
|
||||
return handler(request)
|
||||
|
||||
request.environ[_ENVIRON_ENABLED_KEY] = True
|
||||
request.environ[_ENVIRON_STARTTIME_KEY] = time_ns()
|
||||
request.environ[_ENVIRON_STARTTIME_KEY] = _time_ns()
|
||||
|
||||
try:
|
||||
response = handler(request)
|
||||
|
@ -35,6 +35,7 @@ Usage
|
||||
tornado.ioloop.IOLoop.current().start()
|
||||
"""
|
||||
|
||||
|
||||
from collections import namedtuple
|
||||
from functools import partial
|
||||
from logging import getLogger
|
||||
@ -54,8 +55,8 @@ from opentelemetry.instrumentation.utils import (
|
||||
from opentelemetry.propagate import extract
|
||||
from opentelemetry.propagators.textmap import DictGetter
|
||||
from opentelemetry.trace.status import Status
|
||||
from opentelemetry.util._time import _time_ns
|
||||
from opentelemetry.util.http import get_excluded_urls, get_traced_request_attrs
|
||||
from opentelemetry.util.time import time_ns
|
||||
|
||||
from .client import fetch_async # pylint: disable=E0401
|
||||
|
||||
@ -148,7 +149,7 @@ def _wrap(cls, method_name, wrapper):
|
||||
|
||||
|
||||
def _prepare(tracer, func, handler, args, kwargs):
|
||||
start_time = time_ns()
|
||||
start_time = _time_ns()
|
||||
request = handler.request
|
||||
if _excluded_urls.url_disabled(request.uri):
|
||||
return func(*args, **kwargs)
|
||||
@ -225,7 +226,7 @@ def _finish_span(tracer, handler, error=None):
|
||||
if isinstance(error, tornado.web.HTTPError):
|
||||
status_code = error.status_code
|
||||
if not ctx and status_code == 404:
|
||||
ctx = _start_span(tracer, handler, time_ns())
|
||||
ctx = _start_span(tracer, handler, _time_ns())
|
||||
if status_code != 404:
|
||||
finish_args = (
|
||||
type(error),
|
||||
|
@ -20,7 +20,7 @@ from opentelemetry import trace
|
||||
from opentelemetry.instrumentation.utils import http_status_to_status_code
|
||||
from opentelemetry.propagate import inject
|
||||
from opentelemetry.trace.status import Status
|
||||
from opentelemetry.util.time import time_ns
|
||||
from opentelemetry.util._time import _time_ns
|
||||
|
||||
|
||||
def _normalize_request(args, kwargs):
|
||||
@ -40,7 +40,7 @@ def _normalize_request(args, kwargs):
|
||||
|
||||
|
||||
def fetch_async(tracer, func, _, args, kwargs):
|
||||
start_time = time_ns()
|
||||
start_time = _time_ns()
|
||||
|
||||
# Return immediately if no args were provided (error)
|
||||
# or original_request is set (meaning we are in a redirect step).
|
||||
|
Reference in New Issue
Block a user