Class: Skywalking::Reporter::Grpc

Inherits:
Protocol
  • Object
show all
Defined in:
lib/skywalking/reporter/grpc.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Grpc



22
23
24
25
26
27
28
# File 'lib/skywalking/reporter/grpc.rb', line 22

def initialize(config)
  @cfg = config
  @ms_client = Skywalking::Reporter::Client::GrpcClient::ManagementServiceGrpc.new(config)
  @trace_client = Skywalking::Reporter::Client::GrpcClient::TraceSegmentReportServiceGrpc.new(config)
  @send_properties_counter = 0
  @counter_mutex = Mutex.new
end

Instance Method Details

#report_heartbeatObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/skywalking/reporter/grpc.rb', line 30

def report_heartbeat
  @counter_mutex.synchronize do
    @send_properties_counter += 1
    if (@send_properties_counter.abs % @cfg[:properties_report_period_factor]).zero?
      @ms_client.report_instance_properties
    else
      @ms_client.report_heartbeat
    end
  end
end

#report_segment(enumerator) ⇒ Object



41
42
43
# File 'lib/skywalking/reporter/grpc.rb', line 41

def report_segment(enumerator)
  @trace_client.report_segment(enumerator)
end