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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Cyrille Le Clerc-3
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


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/fd22eeb0-2334-4080-8cdc-6e6d9aaf97cen%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

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

Jesse Glick-4
On Sat, Jan 23, 2021 at 9:21 AM 'Cyrille Le Clerc' via Jenkins Developers <[hidden email]> 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. 

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3qeG-qSigndsOSqj65H6%2BZXr6W9%2BrJ1cC5b0_Fsrzb1w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

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

Cyrille Le Clerc-3


> 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.

On Sat, Jan 23, 2021 at 10:27 PM Jesse Glick <[hidden email]> wrote:
On Sat, Jan 23, 2021 at 9:21 AM 'Cyrille Le Clerc' via Jenkins Developers <[hidden email]> 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. 

--
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 [hidden email].
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

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAC0pbn5im9po40Z4T8HLJjumbSjH3BUSJmG1wB6aQUW0ZiF4oA%40mail.gmail.com.