Skip to content

Make host and port configurable #8

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ requires = ["maturin>=0.12,<0.13"]
build-backend = "maturin"

[tool.maturin]
sdist-include = ["Cargo.lock"]
sdist-include = ["Cargo.lock"]

# Optional Dependencies
# ---------------------
objgraph = { version = ">=3.5.0", optional = true }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of test.py 🤷

25 changes: 22 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Stats {

/// The main reporter class.
#[pyclass]
#[pyo3(text_signature = "()")]
#[pyo3(text_signature = "(config, /)")]
struct Reporter {
span_sender: Sender<thrift_gen::jaeger::Span>,
process_sender: Sender<thrift_gen::jaeger::Process>,
Expand All @@ -80,14 +80,33 @@ struct Reporter {
#[pymethods]
impl Reporter {
#[new]
fn new() -> PyResult<Reporter> {
fn new(config: Option<&PyDict>) -> PyResult<Reporter> {
let mut agent_host_name: String = "127.0.0.1".to_string();
let mut agent_port: i32 = 6831;

if let Some(config) = config {
agent_host_name = config
.get_item("agent_host_name")
.unwrap()
.extract()
.unwrap_or("127.0.0.1".to_string());
agent_port = config
.get_item("agent_port")
.unwrap()
.extract()
.unwrap_or(6831);
}
println!(
"config agent_host_name={} config.agent_port={}",
agent_host_name, agent_port
);
// Set up the UDP transport
let socket = UdpSocket::bind(
&(49152..65535)
.map(|port| SocketAddr::from(([127, 0, 0, 1], port)))
.collect::<Vec<_>>()[..],
)?;
socket.connect("127.0.0.1:6831")?;
socket.connect(format!("{}:{}", agent_host_name, agent_port))?;

// We never read anything so this can be a no-op input protocol
let input_protocol = TCompactInputProtocol::new(empty());
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
# 'logging': True,
},
service_name="your-app-name",
service_name="rust-jaeger-python-client-test",
)

tracer = config.create_tracer(reporter, config.sampler)
Expand Down