Minor refactoring (#1169)

* Minor refactoring across multiple instrumentation libraries

* Reformat using black

* Put span_kind back in aws_lambda

Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
This commit is contained in:
Artem Rys
2022-12-03 14:11:06 +01:00
committed by GitHub
parent 538c655830
commit 155fc46596
7 changed files with 9 additions and 10 deletions

View File

@ -287,9 +287,12 @@ def _instrument(
span_kind = None
try:
if lambda_event["Records"][0]["eventSource"] in set(
["aws:sqs", "aws:s3", "aws:sns", "aws:dynamodb"]
):
if lambda_event["Records"][0]["eventSource"] in {
"aws:sqs",
"aws:s3",
"aws:sns",
"aws:dynamodb",
}:
# See more:
# https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html
# https://docs.aws.amazon.com/lambda/latest/dg/with-sns.html

View File

@ -178,8 +178,6 @@ class BotoInstrumentor(BaseInstrumentor):
)
def _patched_auth_request(self, original_func, instance, args, kwargs):
operation_name = None
frame = currentframe().f_back
operation_name = None
while frame:

View File

@ -130,7 +130,7 @@ class ElasticsearchInstrumentor(BaseInstrumentor):
def _instrument(self, **kwargs):
"""
Instruments elasticsearch module
Instruments Elasticsearch module
"""
tracer_provider = kwargs.get("tracer_provider")
tracer = get_tracer(__name__, __version__, tracer_provider)

View File

@ -266,7 +266,6 @@ _excluded_urls_from_env = get_excluded_urls("FLASK")
def get_default_span_name():
span_name = ""
try:
span_name = flask.request.url_rule.rule
except AttributeError:

View File

@ -194,7 +194,7 @@ class CommandTracer(monitoring.CommandListener):
def _get_span_dict_key(event):
if event.connection_id is not None:
return (event.request_id, event.connection_id)
return event.request_id, event.connection_id
return event.request_id

View File

@ -142,7 +142,6 @@ def _instrument(
):
def _traced_execute_command(func, instance, args, kwargs):
query = _format_command_args(args)
name = ""
if len(args) > 0 and args[0]:
name = args[0]
else:

View File

@ -78,7 +78,7 @@ from typing import Collection, Dict, Iterable, List, Optional
import psutil
# FIXME Remove this pyling disabling line when Github issue is cleared
# FIXME Remove this pylint disabling line when Github issue is cleared
# pylint: disable=no-name-in-module
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.instrumentation.system_metrics.package import _instruments