Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ private static void initializeTraceRoot() {
System.getenv("TENCENT_SECRET_ID")); // Required: Get from environment
tencentCredentials.setSecretKey(
System.getenv("TENCENT_SECRET_KEY")); // Required: Get from environment
tencentCredentials.setRegion("ap-hongkong"); // Optional: defaults to ap-hongkong
tencentCredentials.setRegion("na-siliconvalley"); // Optional: defaults to ap-hongkong
tencentCredentials.setLogset(
System.getenv("TENCENT_LOGSET")); // Optional: CLS logset name (like AWS log group)
tencentCredentials.setTraceToken(
System.getenv("TRACE_TOKEN")); // Required: Tencent APM trace token for authentication
tencentCredentials.setOtlpEndpoint(
System.getenv("TENCENT_APM_ENDPOINT")); // Optional: Custom APM endpoint (overrides default pattern)

// Set credentials on config
config.setTencentCredentials(tencentCredentials);
Expand Down
32 changes: 21 additions & 11 deletions src/main/java/ai/traceroot/sdk/tracer/TraceRootTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,31 @@ private void prepareAwsConfig() {
private void prepareTencentConfig() {
// For Tencent, we use the configured credentials and construct the OTLP endpoint
if (config.getTencentCredentials() != null) {
String region = config.getTencentCredentials().getRegion();
if (region == null) {
region = TraceRootConstants.TENCENT_DEFAULT_REGION; // Default region
}
String tencentOtlpEndpoint = config.getTencentCredentials().getOtlpEndpoint();

// Construct the endpoint based on the region
String tencentOtlpEndpoint =
String.format(TraceRootConstants.TENCENT_APM_ENDPOINT_PATTERN, region);
// Only construct endpoint from pattern if not already specified
if (tencentOtlpEndpoint == null || tencentOtlpEndpoint.isEmpty()) {
String region = config.getTencentCredentials().getRegion();
if (region == null) {
region = TraceRootConstants.TENCENT_DEFAULT_REGION; // Default region
}

config.getTencentCredentials().setOtlpEndpoint(tencentOtlpEndpoint);
config.setOtlpEndpoint(tencentOtlpEndpoint);
// Construct the endpoint based on the region
tencentOtlpEndpoint =
String.format(TraceRootConstants.TENCENT_APM_ENDPOINT_PATTERN, region);

if (config.isTracerVerbose()) {
logger.debug("[TraceRoot] Tencent Cloud APM endpoint configured: {}", tencentOtlpEndpoint);
config.getTencentCredentials().setOtlpEndpoint(tencentOtlpEndpoint);

if (config.isTracerVerbose()) {
logger.debug("[TraceRoot] Tencent Cloud APM endpoint auto-configured: {}", tencentOtlpEndpoint);
}
} else {
if (config.isTracerVerbose()) {
logger.debug("[TraceRoot] Using user-specified Tencent Cloud APM endpoint: {}", tencentOtlpEndpoint);
}
}

config.setOtlpEndpoint(tencentOtlpEndpoint);
} else {
logger.error("[TraceRoot] Tencent provider selected but no Tencent credentials configured");
}
Expand Down