Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDTEST-741] Add telemetry logs #280

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/datadog/ci/ext/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "datadog/core/telemetry/logging"

require_relative "git"
require_relative "environment/extractor"

Expand Down Expand Up @@ -73,6 +75,7 @@ def validate_repository_url(repo_url)
return if !repo_url.nil? && !repo_url.empty?

Datadog.logger.error("DD_GIT_REPOSITORY_URL is not set or empty; no repo URL was automatically extracted")
Core::Telemetry::Logger.error("DD_GIT_REPOSITORY_URL is not set or empty; no repo URL was automatically extracted")
end

def validate_git_sha(git_sha)
Expand All @@ -89,6 +92,7 @@ def validate_git_sha(git_sha)
end

Datadog.logger.error(message)
Core::Telemetry::Logger.error(message)
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/ci/ext/environment/providers/github_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "json"

require "datadog/core/telemetry/logging"
require "datadog/core/utils/url"

require_relative "base"
Expand Down Expand Up @@ -96,6 +97,8 @@ def additional_tags
result
rescue => e
Datadog.logger.error("Failed to extract additional tags from GitHub Actions: #{e}")
Core::Telemetry::Logger.report(e, description: "Failed to extract additional tags from GitHub Actions")

{}
end

Expand Down
2 changes: 2 additions & 0 deletions lib/datadog/ci/test_optimisation/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "pp"

require "datadog/core/telemetry/logging"
require "datadog/core/utils/forking"

require_relative "../ext/test"
Expand Down Expand Up @@ -224,6 +225,7 @@ def load_datadog_cov!
Datadog.logger.debug("Loaded Datadog code coverage collector, using coverage mode: #{code_coverage_mode}")
rescue LoadError => e
Datadog.logger.error("Failed to load coverage collector: #{e}. Code coverage will not be collected.")
Core::Telemetry::Logger.report(e, description: "Failed to load coverage collector")

@code_coverage_enabled = false
end
Expand Down
15 changes: 14 additions & 1 deletion lib/datadog/ci/test_visibility/transport.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require "datadog/core/environment/identity"
require "datadog/core/telemetry/logging"
require "datadog/core/utils/only_once"

require_relative "serializers/factories/test_level"
require_relative "../ext/app_types"
Expand All @@ -15,6 +17,10 @@ module TestVisibility
class Transport < Datadog::CI::Transport::EventPlatformTransport
attr_reader :serializers_factory, :dd_env

def self.log_once
@log_once ||= Datadog::Core::Utils::OnlyOnce.new
end

def initialize(
api:,
dd_env:,
Expand Down Expand Up @@ -64,8 +70,15 @@ def encode_span(trace, span)

encoded
else
Datadog.logger.warn("Invalid event skipped: #{serializer} Errors: #{serializer.validation_errors}")
message = "Invalid event skipped: #{serializer} Errors: #{serializer.validation_errors}"
Datadog.logger.warn(message)
CI::Transport::Telemetry.endpoint_payload_dropped(1, endpoint: telemetry_endpoint_tag)

# log invalid message once as error to internal telemetry
self.class.log_once.run do
Core::Telemetry::Logger.error(message)
end
Comment on lines +77 to +80
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


nil
end
end
Expand Down
3 changes: 3 additions & 0 deletions sig/datadog/ci/test_visibility/transport.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module Datadog
attr_reader serializers_factory: singleton(Datadog::CI::TestVisibility::Serializers::Factories::TestLevel) | singleton(Datadog::CI::TestVisibility::Serializers::Factories::TestSuiteLevel)
attr_reader dd_env: String?

self.@log_once: Datadog::Core::Utils::OnlyOnce
def self.log_once: () -> Datadog::Core::Utils::OnlyOnce

@dd_env: String?
@serializers_factory: singleton(Datadog::CI::TestVisibility::Serializers::Factories::TestLevel) | singleton(Datadog::CI::TestVisibility::Serializers::Factories::TestSuiteLevel)

Expand Down
Loading