Skip to content

(feat-351) add oltp headers#969

Open
hangweizhang wants to merge 1 commit intoagentscope-ai:mainfrom
hangweizhang:feat-351
Open

(feat-351) add oltp headers#969
hangweizhang wants to merge 1 commit intoagentscope-ai:mainfrom
hangweizhang:feat-351

Conversation

@hangweizhang
Copy link
Contributor

feat(studio): add OTLP headers support for authentication

Add support for configuring OTLP headers in agentscope-extensions-studio
to enable authentication with external tracing systems like Langfuse.

Changes:

  • Add otlpHeaders field to StudioConfig with getter method
  • Add addOtlpHeader() and otlpHeaders() builder methods to StudioConfig
  • Add corresponding methods to StudioManager.Builder for convenience
  • Pass configured headers to TelemetryTracer during initialization
  • Add comprehensive test cases for header configuration

This closes #351 by allowing users to configure authentication headers
when reporting trace data via OTLP to systems requiring authentication.

Example usage for Langfuse:

StudioManager.init()
    .studioUrl("https://cloud.langfuse.com")
    .tracingUrl("https://cloud.langfuse.com/api/public/otel/v1/traces")
    .addOtlpHeader("Authorization", "Basic " + base64Credentials)
    .initialize()
    .block();

@hangweizhang hangweizhang requested a review from a team March 15, 2026 05:03
@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../java/io/agentscope/core/studio/StudioManager.java 50.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@hangweizhang
Copy link
Contributor Author

@LearningGp thx for review this pr for support oltp headers #351

assertTrue(false, "Headers map should be immutable");
} catch (UnsupportedOperationException e) {
// Expected behavior - map is immutable
assertTrue(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest using assertThrows here.

* @param headers Map of header names to values
* @return This builder
*/
public Builder otlpHeaders(java.util.Map<String, String> headers) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Prefer import statements for consistency with the rest of the project.

* @param value The header value (e.g., "Basic dXNlcjpwYXNz")
* @return This builder
*/
public Builder addOtlpHeader(String key, String value) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest adding a null check here.

* @param value The header value (e.g., "Basic dXNlcjpwYXNz")
* @return This builder
*/
public Builder addOtlpHeader(String key, String value) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: agentscope-extensions-studio Support otlp headers.

2 participants