Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profiling #327

Merged
merged 32 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5c4d4ce
feat: initial profiling impl
seemk Jul 21, 2023
8e652d1
feat: better options
seemk Jul 24, 2023
8b2db33
chore: add todo
seemk Jul 24, 2023
34104c7
Merge branch 'main' into profiling-poc
seemk Sep 20, 2023
58fac5c
Merge branch 'main' into profiling-poc
seemk Oct 6, 2023
a335ce4
add tests
seemk Oct 12, 2023
aca9fa0
add debug logs
seemk Oct 30, 2023
f52bb88
fix logging, add additional warnings
seemk Oct 30, 2023
625e3f0
readd nonzero location and function ids, add stack frame count
seemk Oct 30, 2023
3f54b42
fix: format
seemk Oct 30, 2023
d259b7f
remove unused imports
seemk Oct 31, 2023
b5f9985
add stop_profiling, filtering of internal threads
seemk Nov 2, 2023
5cabb8f
feat: handle process forking, use logger provider
seemk Nov 7, 2023
8c278ea
chore: get rid of unnecessary imports
seemk Nov 7, 2023
2a0dfe0
stacktrace building without line lookups
seemk Nov 8, 2023
e12c363
account for processing time when scheduling next sampler sleep
seemk Nov 8, 2023
0823889
remove debug printout
seemk Nov 8, 2023
1c0ef19
tear down profiler thread on exit
seemk Nov 8, 2023
2f352ba
hack around process hang on exit
seemk Nov 8, 2023
b4f5db1
hack around shutdown
seemk Nov 8, 2023
7fcf304
get rid of logger provider dude to windows hangs
seemk Nov 8, 2023
e0ed42a
add check for register_at_fork
seemk Nov 8, 2023
858d80e
readd logger provider
seemk Nov 8, 2023
b437ec4
add comment about trace context to profiling tests
seemk Nov 9, 2023
463699d
rename call_stack_interval to call_stack_interval_millis
seemk Nov 9, 2023
68bf085
remove unused import
seemk Nov 9, 2023
6956fc6
pass explicit thread_states to to_log_record / encode_cpu_profile
seemk Nov 13, 2023
78c78d5
remove access to _profiler from _start_profiler_thread
seemk Nov 13, 2023
2e388e7
wrap context hooks
seemk Nov 13, 2023
cf0adf2
refactor Profiler into a class with methods (#355)
pmcollins Nov 14, 2023
4f1c0e0
lint
seemk Nov 14, 2023
0d7e223
Merge branch 'main' into profiling-poc
seemk Nov 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=zipkin_pb2.*
generated-members=zipkin_pb2.*,profile_pb2.*

# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
Expand Down Expand Up @@ -439,7 +439,8 @@ exclude-protected=_asdict,
_replace,
_source,
_make,
_Span
_Span,
_current_frames

# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
Expand All @@ -463,7 +464,7 @@ max-bool-expr=5
max-branches=12

# Maximum number of locals for function / method body.
max-locals=15
max-locals=30

# Maximum number of parents for a class (see R0901).
max-parents=7
Expand All @@ -475,7 +476,7 @@ max-public-methods=20
max-returns=6

# Maximum number of statements in function / method body.
max-statements=50
max-statements=100

# Minimum number of public methods for a class (see R0903).
min-public-methods=2
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ the test project's environment. Assuming the test project environment lives at
version of package in the test project.

```
make develop DEV_ENV=/path/to/test/project/venv
make develop DEV_VENV=/path/to/test/project/venv
```

This will install an editable version of the package in the test project. Any
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ splunk_distro = "splunk_otel.distro:_SplunkDistro"
[tool.poetry.dependencies]
cryptography=">=2.0,<=41.0.4"
python = "^3.7.2"
protobuf = "^4.23"
opentelemetry-api = "1.20.0"
opentelemetry-sdk = "1.20.0"
opentelemetry-instrumentation = "0.41b0"
Expand Down
4 changes: 4 additions & 0 deletions splunk_otel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
"""

from .defaults import _set_otel_defaults
from .util import _init_logger

_init_logger("splunk_otel")

_set_otel_defaults()

# pylint: disable=wrong-import-position
from .metrics import start_metrics # noqa: E402
from .profiling import start_profiling # noqa: E402
from .tracing import start_tracing # noqa: E402
from .version import __version__ # noqa: E402
17 changes: 12 additions & 5 deletions splunk_otel/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@

from splunk_otel.metrics import _configure_metrics
from splunk_otel.options import _Options
from splunk_otel.profiling import _start_profiling
from splunk_otel.profiling.options import _Options as ProfilingOptions
from splunk_otel.tracing import _configure_tracing
from splunk_otel.util import _is_truthy

otel_log_level = os.environ.get("OTEL_LOG_LEVEL", logging.INFO)

logger = logging.getLogger(__file__)
logger.setLevel(otel_log_level)
logger = logging.getLogger(__name__)


class _SplunkDistro(BaseDistro):
def __init__(self):
tracing_enabled = os.environ.get("OTEL_TRACE_ENABLED", True)
profiling_enabled = os.environ.get("SPLUNK_PROFILER_ENABLED", False)
self._tracing_enabled = _is_truthy(tracing_enabled)
self._profiling_enabled = _is_truthy(profiling_enabled)
if not self._tracing_enabled:
logger.info(
"tracing has been disabled with OTEL_TRACE_ENABLED=%s", tracing_enabled
Expand All @@ -47,8 +48,14 @@ def __init__(self):
)

def _configure(self, **kwargs: Dict[str, Any]) -> None:
options = _Options()

if self._tracing_enabled:
_configure_tracing(_Options())
_configure_tracing(options)

if self._profiling_enabled:
_start_profiling(ProfilingOptions(options.resource))
pmcollins marked this conversation as resolved.
Show resolved Hide resolved

if self._metrics_enabled:
_configure_metrics()

Expand Down
5 changes: 1 addition & 4 deletions splunk_otel/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@

from splunk_otel.util import _is_truthy

otel_log_level = os.environ.get("OTEL_LOG_LEVEL", logging.INFO)

logger = logging.getLogger(__file__)
logger.setLevel(otel_log_level)
logger = logging.getLogger(__name__)


def start_metrics() -> MeterProvider:
Expand Down
Loading
Loading