This repository has been archived by the owner on Apr 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
/
ConfigurationTests.cs
586 lines (498 loc) Β· 23.5 KB
/
ConfigurationTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Jaeger.Metrics;
using Jaeger.Samplers;
using Jaeger.Senders;
using Jaeger.Util;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Configuration;
using NSubstitute;
using NSubstitute.ReceivedExtensions;
using OpenTracing;
using OpenTracing.Noop;
using OpenTracing.Propagation;
using OpenTracing.Util;
using Xunit;
using static Jaeger.Configuration;
namespace Jaeger.Tests
{
public class ConfigurationTests : IDisposable
{
private const string TestProperty = "TestProperty";
private readonly ILoggerFactory _loggerFactory;
public ConfigurationTests()
{
_loggerFactory = NullLoggerFactory.Instance;
ClearProperties();
}
public void Dispose()
{
ClearProperties();
}
private void ClearProperties()
{
// Explicitly clear all properties
ClearProperty(Configuration.JaegerAgentHost);
ClearProperty(Configuration.JaegerAgentPort);
ClearProperty(Configuration.JaegerReporterLogSpans);
ClearProperty(Configuration.JaegerReporterMaxQueueSize);
ClearProperty(Configuration.JaegerReporterFlushInterval);
ClearProperty(Configuration.JaegerSamplerType);
ClearProperty(Configuration.JaegerSamplerParam);
ClearProperty(Configuration.JaegerSamplerManagerHostPort);
ClearProperty(Configuration.JaegerSamplingEndpoint);
ClearProperty(Configuration.JaegerServiceName);
ClearProperty(Configuration.JaegerTags);
ClearProperty(Configuration.JaegerTraceId128Bit);
ClearProperty(Configuration.JaegerEndpoint);
ClearProperty(Configuration.JaegerAuthToken);
ClearProperty(Configuration.JaegerUser);
ClearProperty(Configuration.JaegerPassword);
ClearProperty(Configuration.JaegerPropagation);
ClearProperty(TestProperty);
// Reset opentracing's global tracer
FieldInfo field = typeof(GlobalTracer).GetField("_tracer", BindingFlags.Instance | BindingFlags.NonPublic);
field.SetValue(GlobalTracer.Instance, NoopTracerFactory.Create());
}
private void ClearProperty(string name)
{
Environment.SetEnvironmentVariable(name, null);
}
private void SetProperty(string name, string value)
{
Environment.SetEnvironmentVariable(name, value, EnvironmentVariableTarget.Process);
}
[Fact]
public void TestFromEnv()
{
SetProperty(Configuration.JaegerServiceName, "Test");
Assert.NotNull(Configuration.FromEnv(_loggerFactory).GetTracer());
Assert.False(GlobalTracer.IsRegistered());
}
[Fact]
public void TestFromIConfig()
{
var arrayDict = new Dictionary<string, string>
{
{Configuration.JaegerServiceName, "Test"},
};
var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(arrayDict)
.Build();
Assert.NotNull(Configuration.FromIConfiguration(_loggerFactory, configuration).GetTracer());
Assert.False(GlobalTracer.IsRegistered());
}
[Fact]
public void TestSamplerConstFromEnv()
{
SetProperty(Configuration.JaegerSamplerType, ConstSampler.Type);
SetProperty(Configuration.JaegerSamplerParam, "1");
SamplerConfiguration samplerConfig = SamplerConfiguration.FromEnv(_loggerFactory);
Assert.Equal(ConstSampler.Type, samplerConfig.Type);
Assert.Equal(1, samplerConfig.Param);
}
[Fact]
public void TestSamplerConstFromIConfiguration()
{
var arrayDict = new Dictionary<string, string>
{
{Configuration.JaegerSamplerType, ConstSampler.Type},
{Configuration.JaegerSamplerParam, "1"}
};
var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(arrayDict)
.Build();
SamplerConfiguration samplerConfig = SamplerConfiguration.FromIConfiguration(_loggerFactory, configuration);
Assert.Equal(ConstSampler.Type, samplerConfig.Type);
Assert.Equal(1, samplerConfig.Param);
}
[Fact]
public void TestSamplerConstInvalidParam()
{
SetProperty(Configuration.JaegerSamplerType, ConstSampler.Type);
SetProperty(Configuration.JaegerSamplerParam, "X");
SamplerConfiguration samplerConfig = SamplerConfiguration.FromEnv(_loggerFactory);
Assert.Equal(ConstSampler.Type, samplerConfig.Type);
Assert.Null(samplerConfig.Param);
}
[Fact]
public void TestReporterConfigurationFromEnv()
{
SetProperty(Configuration.JaegerReporterLogSpans, "true");
SetProperty(Configuration.JaegerAgentHost, "MyHost");
SetProperty(Configuration.JaegerAgentPort, "1234");
SetProperty(Configuration.JaegerReporterFlushInterval, "500");
SetProperty(Configuration.JaegerReporterMaxQueueSize, "1000");
ReporterConfiguration reporterConfig = ReporterConfiguration.FromEnv(_loggerFactory);
Assert.True(reporterConfig.LogSpans);
Assert.Equal("MyHost", reporterConfig.SenderConfig.AgentHost);
Assert.Equal(1234, reporterConfig.SenderConfig.AgentPort);
Assert.Equal(TimeSpan.FromMilliseconds(500), reporterConfig.FlushInterval);
Assert.Equal(1000, reporterConfig.MaxQueueSize);
}
[Fact]
public void TestReporterConfigurationFromIConfiguration()
{
var arrayDict = new Dictionary<string, string>
{
{Configuration.JaegerSamplerType, ConstSampler.Type},
{Configuration.JaegerSamplerParam, "1"},
{Configuration.JaegerReporterLogSpans, "true"},
{Configuration.JaegerAgentHost, "MyHost"},
{Configuration.JaegerAgentPort, "1234"},
{Configuration.JaegerReporterFlushInterval, "500"},
{Configuration.JaegerReporterMaxQueueSize, "1000"}
};
var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(arrayDict)
.Build();
ReporterConfiguration reporterConfig = ReporterConfiguration.FromIConfiguration(_loggerFactory, configuration);
Assert.True(reporterConfig.LogSpans);
Assert.Equal("MyHost", reporterConfig.SenderConfig.AgentHost);
Assert.Equal(1234, reporterConfig.SenderConfig.AgentPort);
Assert.Equal(TimeSpan.FromMilliseconds(500), reporterConfig.FlushInterval);
Assert.Equal(1000, reporterConfig.MaxQueueSize);
}
[Fact]
public void TestReporterConfigurationInvalidFlushInterval()
{
SetProperty(Configuration.JaegerReporterFlushInterval, "X");
ReporterConfiguration reporterConfig = ReporterConfiguration.FromEnv(_loggerFactory);
Assert.Null(reporterConfig.FlushInterval);
}
[Fact]
public void TestReporterConfigurationInvalidLogSpans()
{
SetProperty(Configuration.JaegerReporterLogSpans, "X");
ReporterConfiguration reporterConfig = ReporterConfiguration.FromEnv(_loggerFactory);
Assert.False(reporterConfig.LogSpans);
}
[Fact]
public void TestTracerUseTraceIdHigh()
{
SetProperty(Configuration.JaegerServiceName, "Test");
SetProperty(Configuration.JaegerTraceId128Bit, "1");
Tracer tracer = (Tracer)Configuration.FromEnv(_loggerFactory).GetTracer();
Assert.True(tracer.UseTraceId128Bit);
}
[Fact]
public void TestTracerInvalidUseTraceIdHigh()
{
SetProperty(Configuration.JaegerServiceName, "Test");
SetProperty(Configuration.JaegerTraceId128Bit, "X");
Tracer tracer = (Tracer)Configuration.FromEnv(_loggerFactory).GetTracer();
Assert.False(tracer.UseTraceId128Bit);
}
[Fact]
public void TestTracerTagslist()
{
SetProperty(Configuration.JaegerServiceName, "Test");
SetProperty(Configuration.JaegerTags, "testTag1=testValue1, testTag2 = testValue2");
Tracer tracer = (Tracer)Configuration.FromEnv(_loggerFactory).GetTracer();
Assert.Equal("testValue1", tracer.Tags["testTag1"]);
Assert.Equal("testValue2", tracer.Tags["testTag2"]);
}
[Fact]
public void TestTracerTagslistFormatError()
{
SetProperty(Configuration.JaegerServiceName, "Test");
SetProperty(Configuration.JaegerTags, "testTag1, testTag2 = testValue2");
Tracer tracer = (Tracer)Configuration.FromEnv(_loggerFactory).GetTracer();
Assert.Equal("testValue2", tracer.Tags["testTag2"]);
}
[Fact]
public void TestTracerTagsSubstitutionDefault()
{
SetProperty(Configuration.JaegerServiceName, "Test");
SetProperty(Configuration.JaegerTags, "testTag1=${" + TestProperty + ":hello}");
Tracer tracer = (Tracer)Configuration.FromEnv(_loggerFactory).GetTracer();
Assert.Equal("hello", tracer.Tags["testTag1"]);
}
[Fact]
public void TestTracerTagsSubstitutionSpecified()
{
SetProperty(Configuration.JaegerServiceName, "Test");
SetProperty(TestProperty, "goodbye");
SetProperty(Configuration.JaegerTags, "testTag1=${" + TestProperty + ":hello}");
Tracer tracer = (Tracer)Configuration.FromEnv(_loggerFactory).GetTracer();
Assert.Equal("goodbye", tracer.Tags["testTag1"]);
}
[Fact]
public void TestSenderWithEndpointWithoutAuthData()
{
SetProperty(Configuration.JaegerEndpoint, "https://jaeger-collector:14268/api/traces");
ISender sender = Configuration.SenderConfiguration.FromEnv(_loggerFactory).GetSender();
Assert.True(sender is HttpSender);
}
[Fact]
public void TestSenderWithAgentDataFromEnv()
{
SetProperty(Configuration.JaegerAgentHost, "jaeger-agent");
SetProperty(Configuration.JaegerAgentPort, "6832");
Assert.Throws<SocketException>(() => Configuration.SenderConfiguration.FromEnv(_loggerFactory).GetSender());
}
[Fact]
public void TestSenderBackwardsCompatibilityGettingAgentHostAndPort()
{
SetProperty(Configuration.JaegerAgentHost, "jaeger-agent");
SetProperty(Configuration.JaegerAgentPort, "6832");
Assert.Equal("jaeger-agent", Configuration.ReporterConfiguration.FromEnv(_loggerFactory).SenderConfig.AgentHost);
Assert.Equal(6832, Configuration.ReporterConfiguration.FromEnv(_loggerFactory).SenderConfig.AgentPort);
}
[Fact]
public void TestNoNullPointerOnNullSender()
{
var reporterConfiguration = new Configuration.ReporterConfiguration(_loggerFactory);
Assert.Null(reporterConfiguration.SenderConfig.AgentHost);
Assert.Null(reporterConfiguration.SenderConfig.AgentPort);
}
[Fact(Skip="Java is using the Builder for this and it is deprecated.")]
public void TestCustomSender()
{
String endpoint = "https://custom-sender-endpoint:14268/api/traces";
SetProperty(Configuration.JaegerEndpoint, "https://jaeger-collector:14268/api/traces");
CustomSender customSender = new CustomSender(endpoint);
Configuration.SenderConfiguration senderConfiguration = new Configuration.SenderConfiguration(_loggerFactory);
//senderConfiguration.Sender = customSender;
Assert.Equal(endpoint, ((CustomSender)senderConfiguration.GetSender()).Endpoint);
}
[Fact]
public void TestSenderWithBasicAuthUsesHttpSender()
{
Configuration.SenderConfiguration senderConfiguration = new Configuration.SenderConfiguration(_loggerFactory)
.WithEndpoint("https://jaeger-collector:14268/api/traces")
.WithAuthUsername("username")
.WithAuthPassword("password");
Assert.True(senderConfiguration.GetSender() is HttpSender);
}
[Fact]
public void TestSenderWithAuthTokenUsesHttpSender()
{
Configuration.SenderConfiguration senderConfiguration = new Configuration.SenderConfiguration(_loggerFactory)
.WithEndpoint("https://jaeger-collector:14268/api/traces")
.WithAuthToken("authToken");
Assert.True(senderConfiguration.GetSender() is HttpSender);
}
[Fact]
public void TestSenderWithAllPropertiesReturnsHttpSender()
{
SetProperty(Configuration.JaegerEndpoint, "https://jaeger-collector:14268/api/traces");
SetProperty(Configuration.JaegerAgentHost, "jaeger-agent");
SetProperty(Configuration.JaegerAgentPort, "6832");
Assert.True(Configuration.SenderConfiguration.FromEnv(_loggerFactory).GetSender() is HttpSender);
}
[Fact]
public void TestPropagationB3OnlyFromConfig()
{
TraceId traceId = new TraceId(1234);
SpanId spanId = new SpanId(5678);
TestTextMap textMap = new TestTextMap();
SpanContext spanContext = new SpanContext(traceId, spanId, new SpanId(0), (byte)0);
CodecConfiguration codecConfiguration = new CodecConfiguration(_loggerFactory)
.WithPropagation(Configuration.Propagation.B3);
ITracer tracer = new Configuration("Test", _loggerFactory)
.WithCodec(codecConfiguration)
.GetTracer();
tracer.Inject(spanContext, BuiltinFormats.TextMap, textMap);
Assert.NotNull(textMap.Get("X-B3-TraceId"));
Assert.NotNull(textMap.Get("X-B3-SpanId"));
Assert.Null(textMap.Get("uber-trace-id"));
SpanContext extractedContext = (SpanContext)tracer.Extract(BuiltinFormats.TextMap, textMap);
Assert.Equal(traceId, extractedContext.TraceId);
Assert.Equal(spanId, extractedContext.SpanId);
}
[Fact]
public void TestPropagationB3OnlyFromEnv()
{
SetProperty(Configuration.JaegerPropagation, "b3");
SetProperty(Configuration.JaegerServiceName, "Test");
TraceId traceId = new TraceId(1234);
SpanId spanId = new SpanId(5678);
TestTextMap textMap = new TestTextMap();
SpanContext spanContext = new SpanContext(traceId, spanId, new SpanId(0), (byte)0);
ITracer tracer = Configuration.FromEnv(_loggerFactory).GetTracer();
tracer.Inject(spanContext, BuiltinFormats.TextMap, textMap);
Assert.NotNull(textMap.Get("X-B3-TraceId"));
Assert.NotNull(textMap.Get("X-B3-SpanId"));
Assert.Null(textMap.Get("uber-trace-id"));
SpanContext extractedContext = (SpanContext)tracer.Extract(BuiltinFormats.TextMap, textMap);
Assert.Equal(traceId, extractedContext.TraceId);
Assert.Equal(spanId, extractedContext.SpanId);
}
[Fact]
public void TestPropagationJaegerAndB3FromConfig()
{
TraceId traceId = new TraceId(1234);
SpanId spanId = new SpanId(5678);
TestTextMap textMap = new TestTextMap();
SpanContext spanContext = new SpanContext(traceId, spanId, new SpanId(0), (byte)0);
CodecConfiguration codecConfiguration = new CodecConfiguration(_loggerFactory)
.WithPropagation(Configuration.Propagation.Jaeger)
.WithPropagation(Configuration.Propagation.B3);
ITracer tracer = new Configuration("Test", _loggerFactory)
.WithCodec(codecConfiguration)
.GetTracer();
tracer.Inject(spanContext, BuiltinFormats.TextMap, textMap);
Assert.NotNull(textMap.Get("uber-trace-id"));
Assert.NotNull(textMap.Get("X-B3-TraceId"));
Assert.NotNull(textMap.Get("X-B3-SpanId"));
SpanContext extractedContext = (SpanContext)tracer.Extract(BuiltinFormats.TextMap, textMap);
Assert.Equal(traceId, extractedContext.TraceId);
Assert.Equal(spanId, extractedContext.SpanId);
}
[Fact]
public void TestPropagationJaegerAndB3FromEnv()
{
SetProperty(Configuration.JaegerPropagation, "jaeger,b3");
SetProperty(Configuration.JaegerServiceName, "Test");
TraceId traceId = new TraceId(1234);
SpanId spanId = new SpanId(5678);
TestTextMap textMap = new TestTextMap();
SpanContext spanContext = new SpanContext(traceId, spanId, new SpanId(0), (byte)0);
ITracer tracer = Configuration.FromEnv(_loggerFactory).GetTracer();
tracer.Inject(spanContext, BuiltinFormats.TextMap, textMap);
Assert.NotNull(textMap.Get("uber-trace-id"));
Assert.NotNull(textMap.Get("X-B3-TraceId"));
Assert.NotNull(textMap.Get("X-B3-SpanId"));
SpanContext extractedContext = (SpanContext)tracer.Extract(BuiltinFormats.TextMap, textMap);
Assert.Equal(traceId, extractedContext.TraceId);
Assert.Equal(spanId, extractedContext.SpanId);
}
[Fact]
public void TestPropagationDefault()
{
SetProperty(Configuration.JaegerServiceName, "Test");
TestTextMap textMap = new TestTextMap();
SpanContext spanContext = new SpanContext(new TraceId(1234), new SpanId(5678), new SpanId(0), (byte)0);
Configuration.FromEnv(_loggerFactory).GetTracer().Inject(spanContext, BuiltinFormats.TextMap, textMap);
Assert.NotNull(textMap.Get("uber-trace-id"));
Assert.Null(textMap.Get("X-B3-TraceId"));
Assert.Null(textMap.Get("X-B3-SpanId"));
}
[Fact]
public void TestPropagationValidFormat()
{
SetProperty(Configuration.JaegerPropagation, "jaeger,invalid");
SetProperty(Configuration.JaegerServiceName, "Test");
TestTextMap textMap = new TestTextMap();
SpanContext spanContext = new SpanContext(new TraceId(1234), new SpanId(5678), new SpanId(0), (byte)0);
Configuration.FromEnv(_loggerFactory).GetTracer().Inject(spanContext, BuiltinFormats.TextMap, textMap);
// Check that jaeger context still available even though invalid format specified
Assert.NotNull(textMap.Get("uber-trace-id"));
}
[Fact]
public void TestUseTraceId128BitFromEnv()
{
SetProperty(Configuration.JaegerServiceName, "Test");
SetProperty(Configuration.JaegerTraceId128Bit, "true");
Tracer tracer = (Tracer)Configuration.FromEnv(_loggerFactory).GetTracer();
Assert.True(tracer.UseTraceId128Bit);
}
[Fact]
public void TestUseTraceId128BitFromConfig()
{
Tracer tracer = (Tracer)new Configuration("Test", _loggerFactory)
.WithTraceId128Bit(true)
.GetTracer();
Assert.True(tracer.UseTraceId128Bit);
}
[Fact]
public void TestNoServiceName()
{
Assert.Throws<ArgumentException>(() => new Configuration(null, _loggerFactory));
}
[Fact]
public async Task TestDefaultTracer()
{
Configuration configuration = new Configuration("name", _loggerFactory);
Assert.NotNull(configuration.GetTracer());
Assert.NotNull(configuration.GetTracer());
await configuration.CloseTracerAsync(CancellationToken.None);
}
[Fact]
public void TestUnknownSampler()
{
SamplerConfiguration samplerConfiguration = new SamplerConfiguration(_loggerFactory);
samplerConfiguration.WithType("unknown");
Assert.Throws<NotSupportedException>(() => new Configuration("name", _loggerFactory)
.WithSampler(samplerConfiguration)
.GetTracer());
}
[Fact]
public void TestConstSampler()
{
SamplerConfiguration samplerConfiguration = new SamplerConfiguration(_loggerFactory)
.WithType(ConstSampler.Type);
ISampler sampler = samplerConfiguration.GetSampler("name",
new MetricsImpl(NoopMetricsFactory.Instance));
Assert.True(sampler is ConstSampler);
}
[Fact]
public void TestProbabilisticSampler()
{
SamplerConfiguration samplerConfiguration = new SamplerConfiguration(_loggerFactory)
.WithType(ProbabilisticSampler.Type);
ISampler sampler = samplerConfiguration.GetSampler("name",
new MetricsImpl(NoopMetricsFactory.Instance));
Assert.True(sampler is ProbabilisticSampler);
}
[Fact]
public void TestRateLimitingSampler()
{
SamplerConfiguration samplerConfiguration = new SamplerConfiguration(_loggerFactory)
.WithType(RateLimitingSampler.Type);
ISampler sampler = samplerConfiguration.GetSampler("name",
new MetricsImpl(NoopMetricsFactory.Instance));
Assert.True(sampler is RateLimitingSampler);
}
[Fact]
public void TestDeprecatedSamplerManagerHostPort()
{
ILoggerFactory loggerFactory = Substitute.For<ILoggerFactory>();
ILogger logger = Substitute.For<ILogger>();
loggerFactory.CreateLogger<Configuration>().Returns(logger);
SetProperty(Configuration.JaegerSamplerManagerHostPort, HttpSamplingManager.DefaultHostPort);
SamplerConfiguration samplerConfiguration = SamplerConfiguration.FromEnv(loggerFactory);
ISampler sampler = samplerConfiguration.GetSampler("name",
new MetricsImpl(NoopMetricsFactory.Instance));
Assert.True(sampler is RemoteControlledSampler);
loggerFactory.Received(1).CreateLogger<Configuration>();
logger.Received(1).Log(LogLevel.Warning, Arg.Any<EventId>(), Arg.Any<object>(), null, Arg.Any<Func<object, Exception, string>>());
}
internal class TestTextMap : ITextMap
{
private Dictionary<string, string> _values = new Dictionary<string, string>();
public void Set(String key, String value)
{
_values[key] = value;
}
public String Get(String key)
{
return _values.TryGetValue(key, out var value) ? value : null;
}
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
{
return _values.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return _values.GetEnumerator();
}
}
private class CustomSender : HttpSender
{
public string Endpoint { get; }
public CustomSender(string endpoint)
: base(endpoint)
{
Endpoint = endpoint;
}
}
}
}