-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
152 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module Datadog | ||
module Core | ||
module Telemetry | ||
# Module for sending telemetry logs to the global telemetry instance | ||
module Logger | ||
class << self | ||
def report(exception, level: :error, description: nil) | ||
instance&.report(exception, level: level, description: description) | ||
end | ||
|
||
def error(description) | ||
instance&.error(description) | ||
end | ||
|
||
private | ||
|
||
def instance | ||
Datadog.send(:components).telemetry | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Datadog | ||
module Core | ||
module Telemetry | ||
module Logger | ||
def self.report: (Exception exception, level: Symbol, ?description: String?) -> void | ||
|
||
def self.error: (String description) -> void | ||
|
||
private | ||
|
||
def self.instance: () -> Datadog::Core::Telemetry::Component? | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require 'spec_helper' | ||
|
||
require 'datadog/core/telemetry/logger' | ||
|
||
RSpec.describe Datadog::Core::Telemetry::Logger do | ||
describe '.report' do | ||
context 'when there is a telemetry component configured' do | ||
it do | ||
exception = StandardError.new | ||
telemetry = instance_double(Datadog::Core::Telemetry::Component) | ||
allow(Datadog.send(:components)).to receive(:telemetry).and_return(telemetry) | ||
expect(telemetry).to receive(:report).with(exception, level: :error, description: 'Oops...') | ||
|
||
expect do | ||
described_class.report(exception, level: :error, description: 'Oops...') | ||
end.not_to raise_error | ||
end | ||
|
||
context 'when only given an exception' do | ||
it do | ||
exception = StandardError.new | ||
telemetry = instance_double(Datadog::Core::Telemetry::Component) | ||
allow(Datadog.send(:components)).to receive(:telemetry).and_return(telemetry) | ||
expect(telemetry).to receive(:report).with(exception, level: :error, description: nil) | ||
|
||
expect do | ||
described_class.report(exception) | ||
end.not_to raise_error | ||
end | ||
end | ||
end | ||
|
||
context 'when there is no telemetry component configured' do | ||
it do | ||
exception = StandardError.new | ||
allow(Datadog.send(:components)).to receive(:telemetry).and_return(nil) | ||
|
||
expect do | ||
described_class.report(exception, level: :error, description: 'Oops...') | ||
end.not_to raise_error | ||
end | ||
end | ||
end | ||
|
||
describe '.error' do | ||
context 'when there is a telemetry component configured' do | ||
it do | ||
telemetry = instance_double(Datadog::Core::Telemetry::Component) | ||
allow(Datadog.send(:components)).to receive(:telemetry).and_return(telemetry) | ||
expect(telemetry).to receive(:error).with('description') | ||
|
||
expect { described_class.error('description') }.not_to raise_error | ||
end | ||
end | ||
|
||
context 'when there is no telemetry component configured' do | ||
it do | ||
allow(Datadog.send(:components)).to receive(:telemetry).and_return(nil) | ||
|
||
expect { described_class.error('description') }.not_to raise_error | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.