[GraphListener] how to retrieve the build node from `onNewHead(FlowNode)`

18 views
Skip to first unread message

Cyrille Le Clerc

unread,
Jan 23, 2021, 9:20:59 AM1/23/21
to Jenkins Developers
Dear community,

Context: I'm trying to implement an OpenTelemetry instrumentation of Jenkins, starting injecting distributed traces in job executions. I have a PoC on https://github.com/cyrille-leclerc/opentelemetry-plugin and I'm discussing with Jeff Pearce at integrating OpenTelemetry in the Jenkins Job and Stage Monitoring plugin.

Question: How can I retrieve the build node hostname/ip on which a step is executing from GraphListener#onNewHead()?
I have tried many APIs (Computer.currentComputer(), flowNode.getExecution()...) byt I have not found anything so far.

Cyrille


Jesse Glick

unread,
Jan 23, 2021, 4:27:24 PM1/23/21
to Jenkins Dev
On Sat, Jan 23, 2021 at 9:21 AM 'Cyrille Le Clerc' via Jenkins Developers <jenkin...@googlegroups.com> wrote:
I have tried many APIs (Computer.currentComputer(),

`Computer.currentComputer` only works for traditional project types. If you have a `StepListener` you can inspect `StepContext.get(Computer.class)`. It would not be simple to get a hostname from a `Computer`—why would you care anyway, in a containerized world?—but you could easily get the node name. 

Cyrille Le Clerc

unread,
Jan 24, 2021, 5:09:14 PM1/24/21
to jenkin...@googlegroups.com


> If you have a `StepListener` you can inspect `StepContext.get(Computer.class)`.

Thanks this works well. I'm now wondering if I should prefer StepListener#notifyOfNewStep() or GraphListener#onNewHead() to capture the beginning of execution of each pipeline step. I may prefer StepListener#notifyOfNewStep() as I also have access to the StepContext.

>  It would not be simple to get a hostname from a `Computer`—why would you care anyway, in a containerized world?—but you could easily get the node name. 

You are right, I simplified saying "hostname". APM agents usually collect various different information on the running process to identify the underlying infrastructure (hostname, IP address, cloud vendors introspection APIs...). Exemple with OpenTelemetry for AWS here.

Cyrille.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/4djUDF4IW9Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3qeG-qSigndsOSqj65H6%2BZXr6W9%2BrJ1cC5b0_Fsrzb1w%40mail.gmail.com.


--
Cyrille Le Clerc
Product Management Director, Observability
Paris, France
Reply all
Reply to author
Forward
0 new messages