Skip to content

Allow calling mark() functions when not tracing#18

Merged
zooba merged 2 commits intomainfrom
issue17
Jun 4, 2025
Merged

Allow calling mark() functions when not tracing#18
zooba merged 2 commits intomainfrom
issue17

Conversation

@zooba
Copy link
Copy Markdown
Member

@zooba zooba commented Jun 4, 2025

This allows code to use them unconditionally, and only have to deal with a warning if tracing is not activated.
Adds is_active() function to allow for testing tracing state.
Fixes #17

@zooba zooba requested a review from Copilot June 4, 2025 15:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the behavior of the mark functions to allow calling them even when tracing is not active and only issue warnings instead of raising exceptions. Key changes include:

  • Adding an is_active() function to check the tracing state.
  • Modifying the mark(), mark_range(), and _mark_stack() functions to issue RuntimeWarning when tracing is disabled.
  • Adding new tests to verify the new warning-based behavior.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/test_etw.py Added tests to verify that mark functions warn when not active.
src/etwtrace/init.py Updated mark functions to warn instead of raising errors and added is_active().
Comments suppressed due to low confidence (3)

src/etwtrace/init.py:177

  • Update the documentation for 'mark' to state that when the global tracer is not enabled, the function now issues a RuntimeWarning instead of raising a RuntimeError.
def mark(name):

src/etwtrace/init.py:191

  • Clarify the docstring for 'mark_range' to explain that it warns and returns a _NullRange when the global tracer is not enabled.
def mark_range(name):

src/etwtrace/init.py:201

  • Update the documentation for '_mark_stack' to indicate that it now issues a warning when the global tracer is not enabled rather than raising an exception.
def _mark_stack(mark):

@zooba zooba enabled auto-merge (squash) June 4, 2025 18:57
@finnagin finnagin self-requested a review June 4, 2025 21:48
@zooba zooba merged commit f0dd53c into main Jun 4, 2025
6 checks passed
@zooba zooba deleted the issue17 branch June 4, 2025 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Call mark() when not tracing

3 participants