4
4
#if NETFRAMEWORK
5
5
using System . Net . Http ;
6
6
#endif
7
+ using Microsoft . Extensions . Configuration ;
7
8
using OpenTelemetry . Exporter . OpenTelemetryProtocol . Implementation ;
8
9
using OpenTelemetry . Exporter . OpenTelemetryProtocol . Implementation . ExportClient ;
9
10
using OpenTelemetry . Exporter . OpenTelemetryProtocol . Implementation . Transmission ;
@@ -130,16 +131,34 @@ public void AppendPathIfNotPresent_TracesPath_AppendsCorrectly(string inputUri,
130
131
}
131
132
132
133
[ Theory ]
133
- [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcTraceExportClient ) , false , 10000 ) ]
134
- [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpTraceExportClient ) , false , 10000 ) ]
135
- [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpTraceExportClient ) , true , 8000 ) ]
136
- [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcMetricsExportClient ) , false , 10000 ) ]
137
- [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpMetricsExportClient ) , false , 10000 ) ]
138
- [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpMetricsExportClient ) , true , 8000 ) ]
139
- [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcLogExportClient ) , false , 10000 ) ]
140
- [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpLogExportClient ) , false , 10000 ) ]
141
- [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpLogExportClient ) , true , 8000 ) ]
142
- public void GetTransmissionHandler_InitializesCorrectExportClientAndTimeoutValue ( OtlpExportProtocol protocol , Type exportClientType , bool customHttpClient , int expectedTimeoutMilliseconds )
134
+ [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcTraceExportClient ) , false , 10000 , null ) ]
135
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpTraceExportClient ) , false , 10000 , null ) ]
136
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpTraceExportClient ) , true , 8000 , null ) ]
137
+ [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcMetricsExportClient ) , false , 10000 , null ) ]
138
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpMetricsExportClient ) , false , 10000 , null ) ]
139
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpMetricsExportClient ) , true , 8000 , null ) ]
140
+ [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcLogExportClient ) , false , 10000 , null ) ]
141
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpLogExportClient ) , false , 10000 , null ) ]
142
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpLogExportClient ) , true , 8000 , null ) ]
143
+ [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcTraceExportClient ) , false , 10000 , "in_memory" ) ]
144
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpTraceExportClient ) , false , 10000 , "in_memory" ) ]
145
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpTraceExportClient ) , true , 8000 , "in_memory" ) ]
146
+ [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcMetricsExportClient ) , false , 10000 , "in_memory" ) ]
147
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpMetricsExportClient ) , false , 10000 , "in_memory" ) ]
148
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpMetricsExportClient ) , true , 8000 , "in_memory" ) ]
149
+ [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcLogExportClient ) , false , 10000 , "in_memory" ) ]
150
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpLogExportClient ) , false , 10000 , "in_memory" ) ]
151
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpLogExportClient ) , true , 8000 , "in_memory" ) ]
152
+ [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcTraceExportClient ) , false , 10000 , "disk" ) ]
153
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpTraceExportClient ) , false , 10000 , "disk" ) ]
154
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpTraceExportClient ) , true , 8000 , "disk" ) ]
155
+ [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcMetricsExportClient ) , false , 10000 , "disk" ) ]
156
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpMetricsExportClient ) , false , 10000 , "disk" ) ]
157
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpMetricsExportClient ) , true , 8000 , "disk" ) ]
158
+ [ InlineData ( OtlpExportProtocol . Grpc , typeof ( OtlpGrpcLogExportClient ) , false , 10000 , "disk" ) ]
159
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpLogExportClient ) , false , 10000 , "disk" ) ]
160
+ [ InlineData ( OtlpExportProtocol . HttpProtobuf , typeof ( OtlpHttpLogExportClient ) , true , 8000 , "disk" ) ]
161
+ public void GetTransmissionHandler_InitializesCorrectHandlerExportClientAndTimeoutValue ( OtlpExportProtocol protocol , Type exportClientType , bool customHttpClient , int expectedTimeoutMilliseconds , string retryStrategy )
143
162
{
144
163
var exporterOptions = new OtlpExporterOptions ( ) { Protocol = protocol } ;
145
164
if ( customHttpClient )
@@ -150,28 +169,45 @@ public void GetTransmissionHandler_InitializesCorrectExportClientAndTimeoutValue
150
169
} ;
151
170
}
152
171
172
+ var configuration = new ConfigurationBuilder ( )
173
+ . AddInMemoryCollection ( new Dictionary < string , string > { [ ExperimentalOptions . OtlpRetryEnvVar ] = retryStrategy } )
174
+ . Build ( ) ;
175
+
153
176
if ( exportClientType == typeof ( OtlpGrpcTraceExportClient ) || exportClientType == typeof ( OtlpHttpTraceExportClient ) )
154
177
{
155
- var transmissionHandler = exporterOptions . GetTraceExportTransmissionHandler ( new ExperimentalOptions ( ) ) ;
178
+ var transmissionHandler = exporterOptions . GetTraceExportTransmissionHandler ( new ExperimentalOptions ( configuration ) ) ;
156
179
157
- AssertTransmissionHandlerProperties ( transmissionHandler , exportClientType , expectedTimeoutMilliseconds ) ;
180
+ AssertTransmissionHandler ( transmissionHandler , exportClientType , expectedTimeoutMilliseconds , retryStrategy ) ;
158
181
}
159
182
else if ( exportClientType == typeof ( OtlpGrpcMetricsExportClient ) || exportClientType == typeof ( OtlpHttpMetricsExportClient ) )
160
183
{
161
- var transmissionHandler = exporterOptions . GetMetricsExportTransmissionHandler ( new ExperimentalOptions ( ) ) ;
184
+ var transmissionHandler = exporterOptions . GetMetricsExportTransmissionHandler ( new ExperimentalOptions ( configuration ) ) ;
162
185
163
- AssertTransmissionHandlerProperties ( transmissionHandler , exportClientType , expectedTimeoutMilliseconds ) ;
186
+ AssertTransmissionHandler ( transmissionHandler , exportClientType , expectedTimeoutMilliseconds , retryStrategy ) ;
164
187
}
165
188
else
166
189
{
167
- var transmissionHandler = exporterOptions . GetLogsExportTransmissionHandler ( new ExperimentalOptions ( ) ) ;
190
+ var transmissionHandler = exporterOptions . GetLogsExportTransmissionHandler ( new ExperimentalOptions ( configuration ) ) ;
168
191
169
- AssertTransmissionHandlerProperties ( transmissionHandler , exportClientType , expectedTimeoutMilliseconds ) ;
192
+ AssertTransmissionHandler ( transmissionHandler , exportClientType , expectedTimeoutMilliseconds , retryStrategy ) ;
170
193
}
171
194
}
172
195
173
- private static void AssertTransmissionHandlerProperties < T > ( OtlpExporterTransmissionHandler < T > transmissionHandler , Type exportClientType , int expectedTimeoutMilliseconds )
196
+ private static void AssertTransmissionHandler < T > ( OtlpExporterTransmissionHandler < T > transmissionHandler , Type exportClientType , int expectedTimeoutMilliseconds , string retryStrategy )
174
197
{
198
+ if ( retryStrategy == "in_memory" )
199
+ {
200
+ Assert . True ( transmissionHandler is OtlpExporterRetryTransmissionHandler < T > ) ;
201
+ }
202
+ else if ( retryStrategy == "disk" )
203
+ {
204
+ Assert . True ( transmissionHandler is OtlpExporterPersistentStorageTransmissionHandler < T > ) ;
205
+ }
206
+ else
207
+ {
208
+ Assert . True ( transmissionHandler is OtlpExporterTransmissionHandler < T > ) ;
209
+ }
210
+
175
211
Assert . Equal ( exportClientType , transmissionHandler . ExportClient . GetType ( ) ) ;
176
212
177
213
Assert . Equal ( expectedTimeoutMilliseconds , transmissionHandler . TimeoutMilliseconds ) ;
0 commit comments