Example #1
0
        public KafkaReportingActor(ZipkinKafkaReportingOptions options)
        {
            Contract.Assert(options.Serializer != null);
            _options        = options;
            PendingMessages = new List <Span>(_options.MaximumBatchSize);

            Batching();
        }
Example #2
0
        /// <summary>
        ///     Performs all of the setup and initialization needed to get the Zipkin Kafka reporting engine up and running.
        /// </summary>
        /// <param name="options">The set of options for configuring timeouts and batch sizes.</param>
        /// <param name="actorSystem">
        ///     Optional. If using Akka.NET, you can hook your own <see cref="ActorSystem" /> into our
        ///     reporting engine.
        /// </param>
        /// <returns></returns>
        public static ZipkinKafkaSpanReporter Create(ZipkinKafkaReportingOptions options,
                                                     ActorSystem actorSystem = null)
        {
            // force this component to explode if the end-user screwed up the URI somehow.
            var weOwnActorSystem = false;

            if (actorSystem == null) // create our own ActorSystem if it doesn't already exist.
            {
                weOwnActorSystem = true;
                actorSystem      = ActorSystem.Create("pbzipkin",
                                                      options.DebugLogging ? DebugHocon : NormalHocon);
            }

            // spawn as a System actor, so in the event of being in a non-owned system our traces get shut down
            // only after all of the user-defined actors have terminated.
            var zipkinActor = actorSystem.AsInstanceOf <ExtendedActorSystem>().SystemActorOf(
                Props.Create(() => new KafkaReportingActor(options)),
                $"zipkin-tracing-kafka-{NameCounter.GetAndIncrement()}");

            return(new ZipkinKafkaSpanReporter(zipkinActor, weOwnActorSystem ? actorSystem : null));
        }