1818import com .azure .core .http .HttpHeaderName ;
1919import com .azure .core .http .HttpHeaders ;
2020import com .azure .core .util .logging .ClientLogger ;
21+ import io .opentelemetry .api .metrics .Meter ;
2122import io .opentelemetry .api .trace .Tracer ;
2223
2324import reactor .core .publisher .Mono ;
@@ -36,6 +37,7 @@ public final class VoiceLiveAsyncClient {
3637 private final String apiVersion ;
3738 private final HttpHeaders additionalHeaders ;
3839 private final Tracer tracer ;
40+ private final Meter meter ;
3941 private final Boolean enableContentRecording ;
4042
4143 /**
@@ -62,12 +64,18 @@ public final class VoiceLiveAsyncClient {
6264 */
6365 VoiceLiveAsyncClient (URI endpoint , KeyCredential keyCredential , String apiVersion , HttpHeaders additionalHeaders ,
6466 Tracer tracer , Boolean enableContentRecording ) {
67+ this (endpoint , keyCredential , apiVersion , additionalHeaders , tracer , null , enableContentRecording );
68+ }
69+
70+ VoiceLiveAsyncClient (URI endpoint , KeyCredential keyCredential , String apiVersion , HttpHeaders additionalHeaders ,
71+ Tracer tracer , Meter meter , Boolean enableContentRecording ) {
6572 this .endpoint = Objects .requireNonNull (endpoint , "'endpoint' cannot be null" );
6673 this .keyCredential = Objects .requireNonNull (keyCredential , "'keyCredential' cannot be null" );
6774 this .tokenCredential = null ;
6875 this .apiVersion = Objects .requireNonNull (apiVersion , "'apiVersion' cannot be null" );
6976 this .additionalHeaders = additionalHeaders != null ? additionalHeaders : new HttpHeaders ();
7077 this .tracer = tracer ;
78+ this .meter = meter ;
7179 this .enableContentRecording = enableContentRecording ;
7280 }
7381
@@ -96,12 +104,18 @@ public final class VoiceLiveAsyncClient {
96104 */
97105 VoiceLiveAsyncClient (URI endpoint , TokenCredential tokenCredential , String apiVersion ,
98106 HttpHeaders additionalHeaders , Tracer tracer , Boolean enableContentRecording ) {
107+ this (endpoint , tokenCredential , apiVersion , additionalHeaders , tracer , null , enableContentRecording );
108+ }
109+
110+ VoiceLiveAsyncClient (URI endpoint , TokenCredential tokenCredential , String apiVersion ,
111+ HttpHeaders additionalHeaders , Tracer tracer , Meter meter , Boolean enableContentRecording ) {
99112 this .endpoint = Objects .requireNonNull (endpoint , "'endpoint' cannot be null" );
100113 this .keyCredential = null ;
101114 this .tokenCredential = Objects .requireNonNull (tokenCredential , "'tokenCredential' cannot be null" );
102115 this .apiVersion = Objects .requireNonNull (apiVersion , "'apiVersion' cannot be null" );
103116 this .additionalHeaders = additionalHeaders != null ? additionalHeaders : new HttpHeaders ();
104117 this .tracer = tracer ;
118+ this .meter = meter ;
105119 this .enableContentRecording = enableContentRecording ;
106120 }
107121
@@ -116,7 +130,7 @@ public Mono<VoiceLiveSessionAsyncClient> startSession(String model) {
116130 Objects .requireNonNull (model , "'model' cannot be null" );
117131
118132 return Mono .fromCallable (() -> convertToWebSocketEndpoint (endpoint , model )).flatMap (wsEndpoint -> {
119- VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , model );
133+ VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , model , null );
120134 return session .connect (additionalHeaders ).thenReturn (session );
121135 });
122136 }
@@ -129,7 +143,7 @@ public Mono<VoiceLiveSessionAsyncClient> startSession(String model) {
129143 */
130144 public Mono <VoiceLiveSessionAsyncClient > startSession () {
131145 return Mono .fromCallable (() -> convertToWebSocketEndpoint (endpoint , null )).flatMap (wsEndpoint -> {
132- VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , null );
146+ VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , null , null );
133147 return session .connect (additionalHeaders ).thenReturn (session );
134148 });
135149 }
@@ -149,7 +163,7 @@ public Mono<VoiceLiveSessionAsyncClient> startSession(String model, VoiceLiveReq
149163 return Mono
150164 .fromCallable (() -> convertToWebSocketEndpoint (endpoint , model , requestOptions .getCustomQueryParameters ()))
151165 .flatMap (wsEndpoint -> {
152- VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , model );
166+ VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , model , null );
153167 // Merge additional headers with custom headers from requestOptions
154168 HttpHeaders mergedHeaders = mergeHeaders (additionalHeaders , requestOptions .getCustomHeaders ());
155169 return session .connect (mergedHeaders ).thenReturn (session );
@@ -170,7 +184,7 @@ public Mono<VoiceLiveSessionAsyncClient> startSession(VoiceLiveRequestOptions re
170184 return Mono
171185 .fromCallable (() -> convertToWebSocketEndpoint (endpoint , null , requestOptions .getCustomQueryParameters ()))
172186 .flatMap (wsEndpoint -> {
173- VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , null );
187+ VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , null , null );
174188 // Merge additional headers with custom headers from requestOptions
175189 HttpHeaders mergedHeaders = mergeHeaders (additionalHeaders , requestOptions .getCustomHeaders ());
176190 return session .connect (mergedHeaders ).thenReturn (session );
@@ -193,7 +207,7 @@ public Mono<VoiceLiveSessionAsyncClient> startSession(AgentSessionConfig agentCo
193207
194208 return Mono .fromCallable (() -> convertToWebSocketEndpoint (endpoint , null , agentConfig .toQueryParameters ()))
195209 .flatMap (wsEndpoint -> {
196- VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , null );
210+ VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , null , agentConfig );
197211 return session .connect (additionalHeaders ).thenReturn (session );
198212 });
199213 }
@@ -223,7 +237,7 @@ public Mono<VoiceLiveSessionAsyncClient> startSession(AgentSessionConfig agentCo
223237 }
224238
225239 return Mono .fromCallable (() -> convertToWebSocketEndpoint (endpoint , null , mergedParams )).flatMap (wsEndpoint -> {
226- VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , null );
240+ VoiceLiveSessionAsyncClient session = createSessionClient (wsEndpoint , null , agentConfig );
227241 // Merge additional headers with custom headers from requestOptions
228242 HttpHeaders mergedHeaders = mergeHeaders (additionalHeaders , requestOptions .getCustomHeaders ());
229243 return session .connect (mergedHeaders ).thenReturn (session );
@@ -237,11 +251,14 @@ public Mono<VoiceLiveSessionAsyncClient> startSession(AgentSessionConfig agentCo
237251 * @param model The model name, used for tracing span names.
238252 * @return A new VoiceLiveSessionAsyncClient instance.
239253 */
240- private VoiceLiveSessionAsyncClient createSessionClient (URI wsEndpoint , String model ) {
254+ private VoiceLiveSessionAsyncClient createSessionClient (URI wsEndpoint , String model ,
255+ AgentSessionConfig agentSessionConfig ) {
241256 if (keyCredential != null ) {
242- return new VoiceLiveSessionAsyncClient (wsEndpoint , keyCredential , tracer , model , enableContentRecording );
257+ return new VoiceLiveSessionAsyncClient (wsEndpoint , keyCredential , tracer , meter , model ,
258+ enableContentRecording , agentSessionConfig );
243259 } else {
244- return new VoiceLiveSessionAsyncClient (wsEndpoint , tokenCredential , tracer , model , enableContentRecording );
260+ return new VoiceLiveSessionAsyncClient (wsEndpoint , tokenCredential , tracer , meter , model ,
261+ enableContentRecording , agentSessionConfig );
245262 }
246263 }
247264
0 commit comments