Skip to content

Add endpoint option to trace-plugin target property#2589

Open
lsk567 wants to merge 4 commits intomasterfrom
specify-endpoint
Open

Add endpoint option to trace-plugin target property#2589
lsk567 wants to merge 4 commits intomasterfrom
specify-endpoint

Conversation

@lsk567
Copy link
Collaborator

@lsk567 lsk567 commented Feb 4, 2026

Summary

  • Adds an optional endpoint field to the trace-plugin target property
  • When specified, generates setenv("TRACE_PLUGIN_ENDPOINT", "<url>", 1) in main() before lf_reactor_c_main(). The environment variable gets read by the trace plugin at runtime, allowing it to stream data to the right destination.

Usage

target C {
    tracing: true,
    trace-plugin: {
        package: "lf-trace-xronos",
        library: "lf::trace-impl",
        endpoint: "http://192.168.1.100:4317" // optional. Only needed when the trace dashboard runs on a separate machine.
    }
}

Test plan

  • Build and run an LF program with endpoint specified, verify the environment variable is set

🤖 Generated with Claude Code. Edited with ❤️ by @lsk567.

@lsk567 lsk567 added the enhancement Enhancement of existing feature label Feb 10, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for configuring an optional trace-plugin endpoint via the trace-plugin target property, so generated C code can pass the endpoint to the runtime trace plugin through an environment variable.

Changes:

  • Extend trace-plugin dictionary schema to accept an optional endpoint field.
  • Emit setenv("TRACE_PLUGIN_ENDPOINT", ...) early in generated C entrypoints when an endpoint is configured.
  • Conditionally include <stdlib.h> in generated C includes to support setenv().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
core/src/main/java/org/lflang/target/property/TracePluginProperty.java Adds endpoint to the trace-plugin dictionary spec and AST (de)serialization.
core/src/main/java/org/lflang/generator/c/CPreambleGenerator.java Conditionally includes <stdlib.h> when tracing is enabled and an endpoint is provided.
core/src/main/java/org/lflang/generator/c/CMainFunctionGenerator.java Generates setenv("TRACE_PLUGIN_ENDPOINT", ...) statements in generated main()/setup().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Use StringUtil.addDoubleQuotes() to properly escape the endpoint value
in the generated C string literal, preventing potential code injection.
Add #ifdef _WIN32 guard to use _putenv_s on Windows instead of the
POSIX-only setenv.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement of existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants