forked from pallets/click
-
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Would it be useful to flag this instrumentation package for asyncclick users?
Contrib repo with source code:
https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-asyncclick
PyPI:
https://pypi.org/project/opentelemetry-instrumentation-asyncclick/
pip install opentelemetry-instrumentation-asyncclick
Example usage:
import asyncio
import asyncclick
from opentelemetry.instrumentation.asyncclick import AsyncClickInstrumentor
AsyncClickInstrumentor().instrument()
@asyncclick.command()
async def hello():
asyncclick.echo(f'Hello world!')
if __name__ == "__main__":
asyncio.run(hello())
When this is configured with an exporter / receiver you get spans for each command with details like:
span_attributes = {
PROCESS_COMMAND_ARGS: sys.argv,
PROCESS_EXECUTABLE_NAME: sys.argv[0],
PROCESS_EXIT_CODE: 0,
PROCESS_PID: os.getpid(),
}
This can be useful for projects where you want to measure the latency of commands.
Metadata
Metadata
Assignees
Labels
No labels