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 · 1 comment · May be fixed by #2994
Open

flask: create spans for CLI commands #2926

codefromthecrypt opened this issue Oct 28, 2024 · 1 comment · May be fixed by #2994

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

@codefromthecrypt
Copy link
Contributor Author

looks like the way to fix this is actually more about click instrumentation than flask CLI. Adjusting the description accordingly

@xrmx xrmx linked a pull request Nov 12, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant