Skip to content

Commit 31289bd

Browse files
ddyczekemdneto
andauthored
fix: make client.py runnable without CLI arguments (#4694)
* remove: unused import * add CLI parameter support with backward compatibility in client.py * add comment explaining parameter usage --------- Co-authored-by: Emídio Neto <[email protected]>
1 parent 8bca97d commit 31289bd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/examples/auto-instrumentation/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from sys import argv
15+
import sys
1616

1717
from requests import get
1818

@@ -31,16 +31,16 @@
3131
BatchSpanProcessor(ConsoleSpanExporter())
3232
)
3333

34-
35-
assert len(argv) == 2
34+
# Get parameter from command line argument or use default value "testing"
35+
param_value = sys.argv[1] if len(sys.argv) > 1 else "testing"
3636

3737
with tracer.start_as_current_span("client"):
3838
with tracer.start_as_current_span("client-server"):
3939
headers = {}
4040
inject(headers)
4141
requested = get(
4242
"http://localhost:8082/server_request",
43-
params={"param": argv[1]},
43+
params={"param": param_value},
4444
headers=headers,
4545
)
4646

0 commit comments

Comments
 (0)