本文整理汇总了Java中zipkin2.reporter.Sender类的典型用法代码示例。如果您正苦于以下问题:Java Sender类的具体用法?Java Sender怎么用?Java Sender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sender类属于zipkin2.reporter包,在下文中一共展示了Sender类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sender
import zipkin2.reporter.Sender; //导入依赖的package包/类
@Bean
Sender sender(DynamicProperties dynamicProperties) {
apiVersion = dynamicProperties.getStringProperty(CONFIG_TRACING_COLLECTOR_API_VERSION,
CONFIG_TRACING_COLLECTOR_API_V2).toLowerCase();
// use default value if the user set value is invalid
if (apiVersion.compareTo(CONFIG_TRACING_COLLECTOR_API_V1) != 0){
apiVersion = CONFIG_TRACING_COLLECTOR_API_V2;
}
String path = MessageFormat.format(CONFIG_TRACING_COLLECTOR_PATH, apiVersion);
return OkHttpSender.create(
dynamicProperties.getStringProperty(
CONFIG_TRACING_COLLECTOR_ADDRESS,
DEFAULT_TRACING_COLLECTOR_ADDRESS)
.trim()
.replaceAll("/+$", "")
.concat(path));
}
示例2: createSender
import zipkin2.reporter.Sender; //导入依赖的package包/类
@Override protected Sender createSender() throws Exception {
RabbitMQSender result = RabbitMQSender.newBuilder()
.queue("zipkin-jmh")
.addresses("localhost:5672").build();
CheckResult check = result.check();
if (!check.ok()) {
throw new AssumptionViolatedException(check.error().getMessage(), check.error());
}
channel = result.get().createChannel();
channel.queueDelete(result.queue());
channel.queueDeclare(result.queue(), false, true, true, null);
Thread.sleep(500L);
new Thread(() -> {
try {
channel.basicConsume(result.queue(), true, new DefaultConsumer(channel));
} catch (IOException e) {
e.printStackTrace();
}
}).start();
return result;
}
示例3: createAndRegister
import zipkin2.reporter.Sender; //导入依赖的package包/类
/**
* Creates and registers the Zipkin Trace exporter to the OpenCensus library. Only one Zipkin
* exporter can be registered at any point.
*
* @param encoder Usually {@link SpanBytesEncoder#JSON_V2}
* @param sender Often, but not necessarily an http sender. This could be Kafka or SQS.
* @param serviceName the {@link Span#localServiceName() local service name} of the process.
* @throws IllegalStateException if a Zipkin exporter is already registered.
*/
public static void createAndRegister(
SpanBytesEncoder encoder, Sender sender, String serviceName) {
synchronized (monitor) {
checkState(handler == null, "Zipkin exporter is already registered.");
Handler newHandler = new ZipkinExporterHandler(encoder, sender, serviceName);
handler = newHandler;
register(Tracing.getExportComponent().getSpanExporter(), newHandler);
}
}
示例4: zipkinReporter
import zipkin2.reporter.Sender; //导入依赖的package包/类
@Bean
Reporter<Span> zipkinReporter(Sender sender) {
if (apiVersion.compareTo(CONFIG_TRACING_COLLECTOR_API_V1) == 0){
return AsyncReporter.builder(sender).build(SpanBytesEncoder.JSON_V1);
}
return AsyncReporter.builder(sender).build();
}
示例5: reporter
import zipkin2.reporter.Sender; //导入依赖的package包/类
/**
* Accepts a sender so you can plug-in any standard one. Returns a Reporter so you can also
* replace with a standard one.
*/
@Bean
@ConditionalOnMissingBean
public Reporter<Span> reporter(
SpanMetricReporter spanMetricReporter,
ZipkinProperties zipkin,
Sender sender
) {
return AsyncReporter.builder(sender)
.queuedMaxSpans(1000) // historical constraint. Note: AsyncReporter supports memory bounds
.messageTimeout(zipkin.getMessageTimeout(), TimeUnit.SECONDS)
.metrics(new ReporterMetricsAdapter(spanMetricReporter))
.build(zipkin.getEncoder());
}
示例6: kafkaSender
import zipkin2.reporter.Sender; //导入依赖的package包/类
@Bean Sender kafkaSender(KafkaProperties config) {
Map<String, Object> properties = config.buildProducerProperties();
properties.put("key.serializer", ByteArraySerializer.class.getName());
properties.put("value.serializer", ByteArraySerializer.class.getName());
// Kafka expects the input to be a String, but KafkaProperties returns a list
Object bootstrapServers = properties.get("bootstrap.servers");
if (bootstrapServers instanceof List) {
properties.put("bootstrap.servers", join((List) bootstrapServers));
}
return KafkaSender.newBuilder()
.topic(this.topic)
.overrides(properties)
.build();
}
示例7: restTemplateSender
import zipkin2.reporter.Sender; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public Sender restTemplateSender(ZipkinProperties zipkin,
ZipkinRestTemplateCustomizer zipkinRestTemplateCustomizer) {
RestTemplate restTemplate = new ZipkinRestTemplateWrapper(zipkin, this.extractor);
zipkinRestTemplateCustomizer.customize(restTemplate);
return new RestTemplateSender(restTemplate, zipkin.getBaseUrl(), zipkin.getEncoder());
}
示例8: rabbitSender
import zipkin2.reporter.Sender; //导入依赖的package包/类
@Bean Sender rabbitSender(CachingConnectionFactory connectionFactory, RabbitProperties config) {
return RabbitMQSender.newBuilder()
.connectionFactory(connectionFactory.getRabbitConnectionFactory())
.queue(this.queue)
.addresses(config.determineAddresses())
.build();
}
示例9: ZipkinExporterHandler
import zipkin2.reporter.Sender; //导入依赖的package包/类
ZipkinExporterHandler(SpanBytesEncoder encoder, Sender sender, String serviceName) {
this.encoder = encoder;
this.sender = sender;
this.localEndpoint = produceLocalEndpoint(serviceName);
}
示例10: setSender
import zipkin2.reporter.Sender; //导入依赖的package包/类
public void setSender(Sender sender) {
this.sender = sender;
}
示例11: sender
import zipkin2.reporter.Sender; //导入依赖的package包/类
/** Configuration for how to send spans to Zipkin */
@Bean Sender sender() {
return OkHttpSender.create("http://127.0.0.1:9411/api/v2/spans");
}
示例12: ReporterManager
import zipkin2.reporter.Sender; //导入依赖的package包/类
/**
* Constructor
*
* @param reporter
* Reporter to manage
* @param sender
* Sender to manage
*/
public ReporterManager(@Nonnull final AsyncReporter<?> reporter,
@Nonnull final Sender sender) {
this.reporter = Objects.requireNonNull(reporter);
this.sender = Objects.requireNonNull(sender);
}