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

flask: create spans for CLI commands #2926

Open
codefromthecrypt opened this issue Oct 28, 2024 · 0 comments
Open

flask: create spans for CLI commands #2926

codefromthecrypt opened this issue Oct 28, 2024 · 0 comments

Comments

@codefromthecrypt
Copy link
Contributor

What problem do you want to solve?

app.cli.command are not instrumented

@app.cli.command()
def create_index():
    """Create or re-create the Elasticsearch index."""
    basedir = os.path.abspath(os.path.dirname(__file__))
    sys.path.append(f"{basedir}/../")

    from data import index_data

    index_data.main()

Describe the solution you'd like

I would like to see an internal (likely root) span with the same name as the function.

Describe alternatives you've considered

I would like to have an auto-instrumentation alternative to creating a span for an app.cli.command like so:

@app.cli.command()
# Currently, flask auto-instrumentation does not trace CLI commands
@tracer.start_as_current_span("create_index")
def create_index():
    """Create or re-create the Elasticsearch index."""
    basedir = os.path.abspath(os.path.dirname(__file__))
    sys.path.append(f"{basedir}/../")

    from data import index_data

    index_data.main()

Additional Context

No response

Would you like to implement a fix?

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant