-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1355 from erikoqvist/add_opentelemetry_tracing
Add OpenTelemetry tracing
- Loading branch information
Showing
15 changed files
with
492 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import functools | ||
|
||
from flask import session | ||
|
||
try: | ||
from opentelemetry import trace | ||
from opentelemetry.trace import INVALID_SPAN | ||
|
||
def create_span(view): | ||
@functools.wraps(view) | ||
def wrapped_view(**kwargs): | ||
current_span = trace.get_current_span() | ||
if current_span != INVALID_SPAN: | ||
if session.get("user") is None: | ||
current_span.set_attribute("username", "unknown") | ||
else: | ||
current_span.set_attribute("username", session.get("user")) | ||
return view(**kwargs) | ||
|
||
return wrapped_view | ||
except ImportError: | ||
def create_span(view): | ||
@functools.wraps(view) | ||
def wrapped_view(**kwargs): | ||
return view(**kwargs) | ||
|
||
return wrapped_view |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.