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

Enable Logging while disabling Forwarding & Instrumentation #1614

Closed
chriscz opened this issue Nov 10, 2022 · 5 comments
Closed

Enable Logging while disabling Forwarding & Instrumentation #1614

chriscz opened this issue Nov 10, 2022 · 5 comments
Labels
community To tag external issues and PRs submitted by the community

Comments

@chriscz
Copy link

chriscz commented Nov 10, 2022

Is your feature request related to a problem? Please describe.

No

Feature Description

I want to enable logging and submit logs to NewRelic without using the built-in forwarding so that I can make use of a custom gem's log forwarding facilities SemanticLogger. There is an open issue tracking this problem for which I am working on a PR.

In addition to the above, a public logging API would be great so that instead of

::NewRelic::Agent.agent.log_event_aggregator.record(formatted_message, severity) 

you would do

::NewRelic::Agent.log(:debug, "message_string_or_hash_payload", exception: nil)

Describe Alternatives

  • Integrating the HTTP Logging API
  • Monkey patching New Relic

Additional context

Instrumentation

def format_message_with_tracing(severity, datetime, progname, msg)
formatted_message = yield
return formatted_message if skip_instrumenting?
begin
# It's critical we don't instrument logging from metric recording
# methods within NewRelic::Agent, or we'll stack overflow!!
mark_skip_instrumenting
unless ::NewRelic::Agent.agent.nil?
::NewRelic::Agent.agent.log_event_aggregator.record(formatted_message, severity)
formatted_message = LocalLogDecorator.decorate(formatted_message)
end
formatted_message
ensure
clear_skip_instrumenting
end

Logging Event Code

def record(formatted_message, severity)
return unless enabled?
severity = "UNKNOWN" if severity.nil? || severity.empty?
if NewRelic::Agent.config[METRICS_ENABLED_KEY]
@counter_lock.synchronize do
@seen += 1
@seen_by_severity[severity] += 1
end
end
return if formatted_message.nil? || formatted_message.empty?
return unless NewRelic::Agent.config[:'application_logging.forwarding.enabled']
return if @high_security
txn = NewRelic::Agent::Transaction.tl_current
priority = LogPriority.priority_for(txn)
if txn
return txn.add_log_event(create_event(priority, formatted_message, severity))
else
return @lock.synchronize do
@buffer.append(priority: priority) do
create_event(priority, formatted_message, severity)
end
end
end
rescue
nil
end

Priority

Must Have

Related Issues

@chriscz chriscz added the feature request To tag feature request after Hero Triage for PM to disposition label Nov 10, 2022
@github-actions github-actions bot added the community To tag external issues and PRs submitted by the community label Nov 10, 2022
@angelatan2 angelatan2 removed the feature request To tag feature request after Hero Triage for PM to disposition label Nov 14, 2022
@workato-integration
Copy link

@kaylareopelle kaylareopelle moved this from Triage to Feature Request in Ruby Engineering Board Nov 14, 2022
@kaylareopelle
Copy link
Contributor

Hi @chriscz, thanks for submitting this feature request! We're reviewing it as a team. Right now, consider this issue as gathering interest. Any customers who come across it should comment or use an emoji to show their interest in the feature!

Someone from our team will be in touch if we have questions about what your request.

@kaylareopelle
Copy link
Contributor

Also, thank you for your work to make SemanticLogger compatible with the Ruby agent! I'm glad you were able to find the local decorator in your search.

@fallwith fallwith added the estimate Issue needing estimation label Jun 6, 2023
@kford-newrelic kford-newrelic removed the estimate Issue needing estimation label Aug 10, 2023
@workato-integration
Copy link

This issue won't be actioned.

@tannalynn
Copy link
Contributor

We've decided to close this issue because this isn't a method we want to add to the agent's public API at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community To tag external issues and PRs submitted by the community
Projects
None yet
Development

No branches or pull requests

6 participants