Skip to content

Commit 7325afb

Browse files
authored
Sonarqube integration (#337)
* adding sonarqube integration * fixing Sonarqube Reliability bugs * remove log message which was causing an infinite loop when debug is on in PY2
1 parent 1313608 commit 7325afb

File tree

11 files changed

+49
-17
lines changed

11 files changed

+49
-17
lines changed

.github/workflows/sonarqube.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build
2+
on:
3+
push:
4+
branches:
5+
- master # or the name of your main branch
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
- uses: sonarsource/sonarqube-scan-action@master
17+
env:
18+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
19+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
20+
# If you wish to fail your job when the Quality Gate is red, uncomment the
21+
# following lines. This would typically be used to fail a deployment.
22+
# We do not recommend to use this in a pull request. Prefer using pull request
23+
# decoration instead.
24+
# - uses: sonarsource/sonarqube-quality-gate-action@master
25+
# timeout-minutes: 5
26+
# env:
27+
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

instana/instrumentation/django/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def process_response(self, request, response):
8484
if request.iscope is not None:
8585
request.iscope.close()
8686
request.iscope = None
87-
return response
87+
return response
8888

8989
def process_exception(self, request, exception):
9090
from django.http.response import Http404

instana/instrumentation/flask/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,5 @@ def handle_user_exception_with_instana(wrapped, instance, argv, kwargs):
7474
flask.g.scope = None
7575
except:
7676
logger.debug("handle_user_exception_with_instana:", exc_info=True)
77-
finally:
78-
return response
77+
78+
return response

instana/instrumentation/flask/vanilla.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def before_request_with_instana(*argv, **kwargs):
5151
span.set_tag("http.path_tpl", path_tpl)
5252
except:
5353
logger.debug("Flask before_request", exc_info=True)
54-
finally:
55-
return None
54+
55+
return None
5656

5757

5858
def after_request_with_instana(response):
@@ -78,7 +78,7 @@ def after_request_with_instana(response):
7878
if scope is not None:
7979
scope.close()
8080
flask.g.scope = None
81-
return response
81+
return response
8282

8383

8484
def teardown_request_with_instana(*argv, **kwargs):

instana/instrumentation/grpcio.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def collect_tags(span, instance, argv, kwargs):
4242
span.set_tag('rpc.port', parts[1])
4343
except:
4444
logger.debug("grpc.collect_tags non-fatal error", exc_info=True)
45-
finally:
46-
return span
45+
return span
4746

4847

4948
@wrapt.patch_function_wrapper('grpc._channel', '_UnaryUnaryMultiCallable.with_call')

instana/instrumentation/logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def log_with_instana(wrapped, instance, argv, kwargs):
4747
scope.span.mark_as_errored()
4848
except Exception:
4949
logger.debug('log_with_instana:', exc_info=True)
50-
finally:
51-
return wrapped(*argv, **kwargs)
50+
51+
return wrapped(*argv, **kwargs)
5252

5353

5454
logger.debug('Instrumenting logging')

instana/instrumentation/pep0249.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ def _collect_kvs(self, span, sql):
3535
span.set_tag('port', self._connect_params[1]['port'])
3636
except Exception as e:
3737
logger.debug(e)
38-
finally:
39-
return span
38+
return span
4039

4140
def execute(self, sql, params=None):
4241
active_tracer = get_active_tracer()

instana/instrumentation/redis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def collect_tags(span, instance, args, kwargs):
3232

3333
except:
3434
logger.debug("redis.collect_tags non-fatal error", exc_info=True)
35-
finally:
36-
return span
35+
36+
return span
3737

3838

3939
def execute_command_with_instana(wrapped, instance, args, kwargs):

instana/instrumentation/sqlalchemy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def receive_before_cursor_execute(**kw):
3838
scope.span.set_tag('sqlalchemy.url', url_regexp.sub('//', url))
3939
except Exception as e:
4040
logger.debug(e)
41-
finally:
42-
return
41+
return
4342

4443

4544
@event.listens_for(Engine, 'after_cursor_execute', named=True)

instana/util/traceutils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ def get_active_tracer():
2727
else:
2828
return None
2929
except Exception:
30-
logger.debug("error while getting active tracer: ", exc_info=True)
30+
# Do not try to log this with instana, as there is no active tracer and there will be an infinite loop at least
31+
# for PY2
3132
return None

0 commit comments

Comments
 (0)