forked from open-telemetry/opentelemetry-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for automatic instrumentation and injection
Fixes open-telemetry#300
- Loading branch information
Showing
7 changed files
with
97 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2019, 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. | ||
|
||
"OpenTelemetry extension specification" | ||
|
||
from abc import ABC, abstractmethod | ||
|
||
|
||
class OpenTelemetryExtension(ABC): | ||
"OpenTelemetry extension base class" | ||
|
||
@abstractmethod | ||
def patch(self, *args, **kwargs): | ||
"Monkey patch a OpenTelemetry extension" | ||
|
||
pass |
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
25 changes: 25 additions & 0 deletions
25
opentelemetry-sdk/src/opentelemetry/sdk/initialize/sitecustomize.py
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,25 @@ | ||
from pkg_resources import iter_entry_points | ||
from logging import getLogger | ||
|
||
_LOGGER = getLogger(__file__) | ||
|
||
|
||
for entry_point in iter_entry_points( | ||
group='opentelemetry_extension' | ||
): | ||
|
||
try: | ||
|
||
entry_point.load()().patch() | ||
|
||
except Exception as error: | ||
|
||
_LOG.warning( | ||
( | ||
"Unable to patch extension {extension}, this " | ||
"error happened while attempting to patch: " | ||
"{error}. Execution may continue but no " | ||
"automatic instrumentation will be performed on " | ||
"{extension}." | ||
).format(extension=entry_point.name, error=error) | ||
) |
Empty file.
18 changes: 18 additions & 0 deletions
18
opentelemetry-sdk/src/opentelemetry/sdk/scripts/opentelemetry_python_autoagent.py
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,18 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from sys import exit, argv | ||
from os import execl | ||
import os | ||
from os.path import dirname, join | ||
from distutils.spawn import find_executable | ||
|
||
|
||
def run(): | ||
|
||
os.environ['PYTHONPATH'] = join(dirname(__file__), 'initialize') | ||
|
||
python3 = find_executable('python3') | ||
|
||
execl(python3, python3, argv[1]) | ||
|
||
exit(0) |