@@ -288,21 +288,31 @@ private void prepareAwsConfig() {
288288 private void prepareTencentConfig () {
289289 // For Tencent, we use the configured credentials and construct the OTLP endpoint
290290 if (config .getTencentCredentials () != null ) {
291- String region = config .getTencentCredentials ().getRegion ();
292- if (region == null ) {
293- region = TraceRootConstants .TENCENT_DEFAULT_REGION ; // Default region
294- }
291+ String tencentOtlpEndpoint = config .getTencentCredentials ().getOtlpEndpoint ();
295292
296- // Construct the endpoint based on the region
297- String tencentOtlpEndpoint =
298- String .format (TraceRootConstants .TENCENT_APM_ENDPOINT_PATTERN , region );
293+ // Only construct endpoint from pattern if not already specified
294+ if (tencentOtlpEndpoint == null || tencentOtlpEndpoint .isEmpty ()) {
295+ String region = config .getTencentCredentials ().getRegion ();
296+ if (region == null ) {
297+ region = TraceRootConstants .TENCENT_DEFAULT_REGION ; // Default region
298+ }
299299
300- config .getTencentCredentials ().setOtlpEndpoint (tencentOtlpEndpoint );
301- config .setOtlpEndpoint (tencentOtlpEndpoint );
300+ // Construct the endpoint based on the region
301+ tencentOtlpEndpoint =
302+ String .format (TraceRootConstants .TENCENT_APM_ENDPOINT_PATTERN , region );
302303
303- if (config .isTracerVerbose ()) {
304- logger .debug ("[TraceRoot] Tencent Cloud APM endpoint configured: {}" , tencentOtlpEndpoint );
304+ config .getTencentCredentials ().setOtlpEndpoint (tencentOtlpEndpoint );
305+
306+ if (config .isTracerVerbose ()) {
307+ logger .debug ("[TraceRoot] Tencent Cloud APM endpoint auto-configured: {}" , tencentOtlpEndpoint );
308+ }
309+ } else {
310+ if (config .isTracerVerbose ()) {
311+ logger .debug ("[TraceRoot] Using user-specified Tencent Cloud APM endpoint: {}" , tencentOtlpEndpoint );
312+ }
305313 }
314+
315+ config .setOtlpEndpoint (tencentOtlpEndpoint );
306316 } else {
307317 logger .error ("[TraceRoot] Tencent provider selected but no Tencent credentials configured" );
308318 }
0 commit comments