From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mOaULAHDK2aa5jwAWB0awg (envelope-from ) for ; Fri, 26 Apr 2024 11:06:41 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=lists.lttng.org header.i=@lists.lttng.org header.a=rsa-sha256 header.s=default header.b=G30sO6Bh; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A6F761E0C1; Fri, 26 Apr 2024 11:06:41 -0400 (EDT) Received: from lists.lttng.org (lists.lttng.org [167.114.26.123]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 03AC61E092 for ; Fri, 26 Apr 2024 11:06:39 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.lttng.org; s=default; t=1714143998; bh=0+724M0r3OJI4iokV9Xzjyhn2N/GCcSC2Rns7JpfeSc=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=G30sO6BhW77jr2cMTgQWOUkOsi7x+if2rGJCEnRoxHdiETIFyjZsdWxUUBCuFbPiv jlaLDVNK1ss8QqytVWv7TS5gpSdwbmDdRTxCYn6dwYdzUjO/O9aQPRPrBpgE3Tj8AR 6EiNorHqQ3uSl3P1kfwDGYLixs0bYSHGgjH1A4yUkCqb1b35+1yyOTtG2GshP0f+Vm KUUMlOgteFjG2Xp/CgAkxHHgHLcpkqBA619fLOKzJFuHZjSea/DOE8JNAhYS8nBDnO PeWi0GRhGgetd7MNyBRlafurUwUJw12Y0lR0NAt90ujxVLBWs3dmSfETTEPevhvpGg J7WIwl3Cegk6g== Received: from lists-lttng01.efficios.com (localhost [IPv6:::1]) by lists.lttng.org (Postfix) with ESMTP id 4VQwzf2s48z2jvN; Fri, 26 Apr 2024 11:06:38 -0400 (EDT) Received: from simark.ca (simark.ca [158.69.221.121]) by lists.lttng.org (Postfix) with ESMTPS id 4VQwzc369Vz2jvM for ; Fri, 26 Apr 2024 11:06:36 -0400 (EDT) Received: from [10.0.0.11] (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id BB9AA1E092; Fri, 26 Apr 2024 10:57:59 -0400 (EDT) Message-ID: <52708661-b095-4f23-bfc7-9eb8c89f0cbe@simark.ca> Date: Fri, 26 Apr 2024 10:57:59 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: "Wu, Yannan" , Kienan Stewart , "lttng-dev@lists.lttng.org" References: <03304ae9731e474db911b8ef6703cf69@amazon.com> <8c49688cb4bb43009b5ba1f6fb8e32cf@amazon.com> Content-Language: en-US In-Reply-To: <8c49688cb4bb43009b5ba1f6fb8e32cf@amazon.com> Subject: Re: [lttng-dev] [babeltrace2]about python self-defined plugin loading X-BeenThere: lttng-dev@lists.lttng.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: LTTng development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via lttng-dev Reply-To: Simon Marchi Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: lttng-dev-bounces@lists.lttng.org Sender: "lttng-dev" On 2024-04-26 09:56, Wu, Yannan via lttng-dev wrote: > Hihi, Kienan, > > I finally find a workaround. I could success with the following code: > file_name = "bt_plugin_latency_filter.py" > current_directory=os.getcwd() > > file_path = os.path.join(current_directory, file_name) > pset=bt2.find_plugins_in_path(file_path) > > forplugininpset: > if plugin.name=="latency_filter"andhasattr(plugin,"filter_component_classes"): > > latency_filter_comp_cls=plugin.filter_component_classes['LatencyFilter'] > > But loading the whole directory, it just doesnt work from command line. > Amanda So, since this works, it confirms that your babeltrace build has support for Python plugins. Then there's no reason for your original example using babeltrace-fun-plugins/my-first-components not to work. When running the command: babeltrace2 --plugin-path . -c source.demo.MyFirstSource -c sink.demo.MyFirstSink is your working directory babeltrace-fun-plugins/my-first-component? `--plugin-path .` refers to the current working directory, so it must be the directory that directly contains the `bt_plugin_*.py` file. I made an example with docker to show it working, hopefully this can help you figure out what's wrong on your side. Put this inside a `Dockerfile` file: ``` FROM debian:12 RUN apt-get -y update RUN apt-get -y full-upgrade RUN apt-get -y install babeltrace2 git RUN git clone https://github.com/simark/babeltrace-fun-plugins.git WORKDIR /babeltrace-fun-plugins/my-first-components ENTRYPOINT babeltrace2 --plugin-path . -c source.demo.MyFirstSource -c sink.demo.MyFirstSink ``` Then, do either (whatever works for you): $ docker buildx build -t bt2-example . $ docker build -t bt2-example . And finally: $ docker run -it bt2-example Stream beginning event my-event, timestamp 123 Stream end This last command runs babeltrace2, loading the Python plugin from babeltrace-fun-plugins/my-first-components. Finally, to investigate more in depth, you can increase the log level of babeltrace2, like so: $ babeltrace2 --log-level DEBUG --plugin-path . -c source.demo.MyFirstSource -c sink.demo.MyFirstSink This will output all sorts of things about babeltrace looking for plugins and trying to load them. Simon _______________________________________________ lttng-dev mailing list lttng-dev@lists.lttng.org https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev