Java Code Examples for zipkin2.reporter.okhttp3.OkHttpSender#create()
The following examples show how to use
zipkin2.reporter.okhttp3.OkHttpSender#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZipkinTraceFactory.java From pampas with Apache License 2.0 | 6 votes |
@Override public Tracer getTracer() { Sender sender = OkHttpSender.create("http://192.168.20.131:9411/api/v2/spans"); Reporter spanReporter = AsyncReporter.create(sender); // If you want to support baggage, indicate the fields you'd like to // whitelist, in this case "country-code" and "user-id". On the wire, // they will be prefixed like "baggage-country-code" Propagation.Factory propagationFactory = ExtraFieldPropagation.newFactoryBuilder(B3Propagation.FACTORY) .addPrefixedFields("baggage-", Arrays.asList("country-code", "user-id")) .build(); Tracing braveTracing = Tracing.newBuilder() .localServiceName("gateway") .propagationFactory(propagationFactory) .spanReporter(spanReporter) .build(); Tracer tracer = BraveTracer.create(braveTracing); return tracer; }
Example 2
Source File: OpenTracingUtil.java From problematic-microservices with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static void configureOpenTracing(Properties configuration, String serviceName) { Tracer tracer = null; String tracerName = configuration.getProperty("tracer"); if ("jaeger".equals(tracerName)) { SamplerConfiguration samplerConfig = new SamplerConfiguration().withType(ConstSampler.TYPE).withParam(1); SenderConfiguration senderConfig = new SenderConfiguration() .withAgentHost(configuration.getProperty("jaeger.reporter.host")) .withAgentPort(Integer.decode(configuration.getProperty("jaeger.reporter.port"))); ReporterConfiguration reporterConfig = new ReporterConfiguration().withLogSpans(true) .withFlushInterval(1000).withMaxQueueSize(10000).withSender(senderConfig); tracer = new Configuration(serviceName).withSampler(samplerConfig).withReporter(reporterConfig).getTracer(); } else if ("zipkin".equals(tracerName)) { OkHttpSender sender = OkHttpSender.create("http://" + configuration.getProperty("zipkin.reporter.host") + ":" + configuration.getProperty("zipkin.reporter.port") + "/api/v2/spans"); Reporter<Span> reporter = AsyncReporter.builder(sender).build(); tracer = BraveTracer .create(Tracing.newBuilder().localServiceName(serviceName).spanReporter(reporter).build()); } GlobalTracer.register(new DelegatingJfrTracer(tracer)); }
Example 3
Source File: TracingConfiguration.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@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)); }
Example 4
Source File: CatalogTracing.java From cxf with Apache License 2.0 | 6 votes |
public HttpTracing getHttpTracing() { HttpTracing result = httpTracing; if (result == null) { synchronized (this) { result = httpTracing; if (result == null) { sender = OkHttpSender.create("http://localhost:9411/api/v2/spans"); reporter = AsyncReporter.create(sender); result = createHttpTracing(serviceName, reporter); httpTracing = result; } } } return result; }
Example 5
Source File: ZipkinTraceFactory.java From pampas with Apache License 2.0 | 5 votes |
public static void main(String[] args) { byte[] arr = new byte[10]; Arrays.fill(arr, Byte.MAX_VALUE); try (Sender sender = OkHttpSender.create("http://192.168.20.131:9411/api/v2/spans")) { sender.sendSpans(Collections.singletonList(arr)); } catch (IOException e) { e.printStackTrace(); } }
Example 6
Source File: ZipkinTracer.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Override public Tracer getTracer(String serviceName) { String hostname = configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_HOST) != null ? configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_HOST) : TracingConstants.ZIPKIN_DEFAULT_HOST; int port = configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_PORT) != null ? Integer.parseInt(configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_PORT)) : TracingConstants.ZIPKIN_DEFAULT_PORT; boolean tracerLogEnabled = Boolean.parseBoolean(configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED) != null ? configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED) : TracingConstants.DEFAULT_TRACER_LOG_ENABLED); OkHttpSender sender = OkHttpSender.create("http://" + hostname + ":" + port + TracingConstants.ZIPKIN_API_CONTEXT); Tracer tracer = BraveTracer.create(Tracing.newBuilder() .localServiceName(serviceName) .spanReporter(AsyncReporter.builder(sender).build()) .propagationFactory(ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, TracingConstants.REQUEST_ID)) .build()); if (tracerLogEnabled) { Reporter reporter = new TracingReporter(LogFactory.getLog(TracingConstants.TRACER)); Tracer tracerR = new TracerR(tracer, reporter, new ThreadLocalScopeManager()); GlobalTracer.register(tracerR); return tracerR; } else { GlobalTracer.register(tracer); return tracer; } }
Example 7
Source File: TracingUtil.java From oxd with Apache License 2.0 | 5 votes |
private static Tracer createTracer(OxdServerConfiguration configuration, String componentName) { String tracerName = configuration.getTracer(); if (!configuration.getEnableTracing() || Strings.isNullOrEmpty(tracerName)) { return NoopTracerFactory.create(); } else if ("jaeger".equals(tracerName)) { Configuration.SamplerConfiguration samplerConfig = new Configuration.SamplerConfiguration() .withType(ConstSampler.TYPE) .withParam(1); Configuration.SenderConfiguration senderConfig = new Configuration.SenderConfiguration() .withAgentHost(configuration.getTracerHost()) .withAgentPort(configuration.getTracerPort()); Configuration.ReporterConfiguration reporterConfig = new Configuration.ReporterConfiguration() .withLogSpans(true) .withFlushInterval(1000) .withMaxQueueSize(10000) .withSender(senderConfig); return new Configuration(componentName) .withSampler(samplerConfig) .withReporter(reporterConfig) .getTracer(); } else if ("zipkin".equals(tracerName)) { OkHttpSender sender = OkHttpSender.create( "http://" + configuration.getTracerHost() + ":" + configuration.getTracerPort() + "/api/v1/spans"); Reporter<Span> reporter = AsyncReporter.builder(sender).build(); return BraveTracer.create(Tracing.newBuilder() .localServiceName(componentName) .spanReporter(reporter) .build()); } else { return NoopTracerFactory.create(); } }
Example 8
Source File: TracingConfiguration.java From txle with Apache License 2.0 | 4 votes |
@Bean Sender sender() { return OkHttpSender.create(zipkinServer); }
Example 9
Source File: TracingConfiguration.java From txle with Apache License 2.0 | 4 votes |
@Bean Sender sender() { return OkHttpSender.create(zipkinServer); }
Example 10
Source File: HttpZipkinCollectorConfiguration.java From jim-framework with Apache License 2.0 | 4 votes |
@Override public Sender getSender() { return OkHttpSender.create(super.getZipkinUrl()+"/api/v2/spans"); }
Example 11
Source File: TracingConfiguration.java From java-tutorial with Creative Commons Attribution Share Alike 4.0 International | 4 votes |
/** Configuration for how to send spans to Zipkin */ @Bean Sender sender() { return OkHttpSender.create("http://127.0.0.1:9411/api/v2/spans"); }
Example 12
Source File: TracingConfiguration.java From java-tutorial with Creative Commons Attribution Share Alike 4.0 International | 4 votes |
/** Configuration for how to send spans to Zipkin */ @Bean Sender sender() { return OkHttpSender.create("http://127.0.0.1:9411/api/v2/spans"); }
Example 13
Source File: OkHttpSenderBenchmarks.java From zipkin-reporter-java with Apache License 2.0 | 4 votes |
@Override Sender newHttpSender(String endpoint) { return OkHttpSender.create(endpoint); }
Example 14
Source File: TracingConfiguration.java From brave-webmvc-example with MIT License | 4 votes |
/** Configuration for how to send spans to Zipkin */ @Bean Sender sender() { return OkHttpSender.create("http://127.0.0.1:9411/api/v2/spans"); }
Example 15
Source File: TracingConfiguration.java From brave-webmvc-example with MIT License | 4 votes |
/** Configuration for how to send spans to Zipkin */ @Bean Sender sender() { return OkHttpSender.create("http://127.0.0.1:9411/api/v2/spans"); }