Skip to content

Commit 0f39fdb

Browse files
author
luk384090-cloud
committed
feat(headers): add SDK tracking headers to all DashScope requests
Every outbound DashScope request now carries three new headers: - x-dashscope-sdk-client: identifies the SDK ("java-sdk") - x-dashscope-sdk-version: current SDK version (from Version.version) - x-dashscope-sdk-session-id: a process-level UUID, generated once at class load and reused for the lifetime of the JVM These headers are set before user-supplied customHeaders are merged, so callers can override any of them if needed. Setting the environment variable DASHSCOPE_DISABLE_SDK_HEADERS=1 (or true) opts out entirely. Both HTTP (buildHttpHeaders) and WebSocket (buildWebSocketHeaders) paths are covered, so all API calls — including Generation, MultiModalConversation, image/video synthesis, TTS, etc. — will automatically include the tracking metadata.
1 parent 1849cfe commit 0f39fdb

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/main/java/com/alibaba/dashscope/protocol/DashScopeHeaders.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,15 @@ public static String userAgent(String customUserAgent) {
3333
return userAgent;
3434
}
3535

36-
/**
37-
* Check if SDK tracking headers are disabled via DASHSCOPE_DISABLE_SDK_HEADERS env var.
38-
*/
36+
/** Check if SDK tracking headers are disabled via DASHSCOPE_DISABLE_SDK_HEADERS env var. */
3937
private static boolean isSdkHeadersDisabled() {
4038
String disable = System.getenv("DASHSCOPE_DISABLE_SDK_HEADERS");
4139
return "1".equals(disable) || "true".equalsIgnoreCase(disable);
4240
}
4341

4442
/**
45-
* Add SDK tracking headers to the given map.
46-
* These headers are set first so that user-supplied customHeaders can override them.
43+
* Add SDK tracking headers to the given map. These headers are set first so that user-supplied
44+
* customHeaders can override them.
4745
*/
4846
private static void addSdkTrackingHeaders(Map<String, String> headers) {
4947
if (!isSdkHeadersDisabled()) {

0 commit comments

Comments
 (0)