Skip to content

Add startup logging#935

Merged
SammyK merged 3 commits intomasterfrom
sammyk/build/startup-logging
Jul 6, 2020
Merged

Add startup logging#935
SammyK merged 3 commits intomasterfrom
sammyk/build/startup-logging

Conversation

@SammyK
Copy link
Copy Markdown
Contributor

@SammyK SammyK commented Jun 25, 2020

Description

This PR adds startup logs that contain a JSON-encoded string of configuration and diagnostic information. The JSON can be provided to the support team to help identify configuration issues. The log message is only generated on process startup and can be disabled by setting DD_TRACE_STARTUP_LOGS=0.

Example startup message

[2020-07-01T17:42:50Z] DATADOG TRACER CONFIGURATION - {"agent_error":"Couldn't connect to server","ddtrace.request_init_hook_reachable":false,"date":"2020-07-01T17:42:50Z","os_name":"Linux 49b1cb4bdd12 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64","os_version":"4.19.76-linuxkit","version":"1.0.0-nightly","lang":"php","lang_version":"7.4.5","env":null,"enabled":true,"service":null,"enabled_cli":false,"agent_url":"https://localhost:8126","debug":false,"analytics_enabled":false,"sample_rate":1.000000,"sampling_rules":null,"tags":null,"service_mapping":null,"distributed_tracing_enabled":true,"priority_sampling_enabled":true,"dd_version":null,"architecture":"x86_64","sapi":"cgi-fcgi","ddtrace.request_init_hook":null,"open_basedir_configured":false,"uri_fragment_regex":null,"uri_mapping_incoming":null,"uri_mapping_outgoing":null,"auto_flush_enabled":false,"generate_root_span":true,"http_client_split_by_domain":false,"measure_compile_time":true,"report_hostname_on_root_span":false,"traced_internal_functions":null,"auto_prepend_file_configured":false,"integrations_disabled":null,"enabled_from_env":true,"opcache.file_cache":null}

When debug mode is enabled (DD_TRACE_DEBUG=1), failed diagnostic tests will also generate log messages:

[2020-07-01T17:35:25Z] DATADOG TRACER DIAGNOSTICS - agent_error: Couldn't connect to server
[2020-07-01T17:35:25Z] DATADOG TRACER DIAGNOSTICS - ddtrace.request_init_hook_reachable: false

PHP Info

The JSON string can also be obtained from the PHP info page and the diagnostic information will be displayed in a separate table to help diagnose common issues.

ddtrace PHP info page

From the CLI SAPI, the info can be obtained from php --ri=ddtrace.

ddtrace


Datadog PHP tracer extension
For help, check out the documentation at https://docs.datadoghq.com/tracing/languages/php/
(c) Datadog 2020

Datadog tracing support => enabled
Version => 1.0.0-nightly
DATADOG TRACER CONFIGURATION => {"date":"2020-07-01T17:43:54Z","os_name":"Linux 49b1cb4bdd12 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64","os_version":"4.19.76-linuxkit","version":"1.0.0-nightly","lang":"php","lang_version":"7.4.5","env":null,"enabled":true,"service":null,"enabled_cli":false,"agent_url":"https://localhost:8126","debug":false,"analytics_enabled":false,"sample_rate":1.000000,"sampling_rules":null,"tags":null,"service_mapping":null,"distributed_tracing_enabled":true,"priority_sampling_enabled":true,"dd_version":null,"architecture":"x86_64","sapi":"cli","ddtrace.request_init_hook":null,"open_basedir_configured":false,"uri_fragment_regex":null,"uri_mapping_incoming":null,"uri_mapping_outgoing":null,"auto_flush_enabled":false,"generate_root_span":true,"http_client_split_by_domain":false,"measure_compile_time":true,"report_hostname_on_root_span":false,"traced_internal_functions":null,"auto_prepend_file_configured":false,"integrations_disabled":null,"enabled_from_env":true,"opcache.file_cache":null,"agent_error":"Couldn't connect to server","ddtrace.request_init_hook_reachable":false}

                               Diagnostics
agent_error => Couldn't connect to server
ddtrace.request_init_hook_reachable => false

Directive => Local Value => Master Value
ddtrace.disable => Off => Off
...

The JSON string can also be accessed at runtime from \DDTrace\startup_logs().

echo \DDTrace\startup_logs() . PHP_EOL;

Readiness checklist

  • (only for Members) Changelog has been added to the appropriate release draft. Create one if necessary.
  • Tests added for this feature/bug.

Reviewer checklist

  • Appropriate labels assigned.
  • Milestone is set.
  • Changelog has been added to the appropriate release draft. For community contributors the reviewer is in charge of this task.

@SammyK SammyK added 🏆 enhancement A new feature or improvement c-extension Apply this label to issues and prs related to the C-extension labels Jun 25, 2020
@SammyK SammyK added this to the 0.48.0 milestone Jun 25, 2020
@SammyK SammyK force-pushed the sammyk/build/startup-logging branch 6 times, most recently from ece36d5 to c4908ea Compare July 1, 2020 18:40
@SammyK SammyK marked this pull request as ready for review July 1, 2020 18:42
@SammyK SammyK force-pushed the sammyk/build/startup-logging branch 3 times, most recently from de7925c to 76a165c Compare July 1, 2020 21:45
@SammyK SammyK modified the milestones: 0.48.0, 0.47.0 Jul 2, 2020
@SammyK SammyK force-pushed the sammyk/build/startup-logging branch 2 times, most recently from ffefd60 to 0b687e2 Compare July 2, 2020 21:01
Comment thread src/ext/ddtrace.c Outdated
Comment thread src/ext/php5/startup_logging.c Outdated
@SammyK SammyK force-pushed the sammyk/build/startup-logging branch from e285c91 to 4e8e353 Compare July 6, 2020 21:53
@SammyK SammyK merged commit 4f8d8c1 into master Jul 6, 2020
@SammyK SammyK deleted the sammyk/build/startup-logging branch July 6, 2020 22:45
@morrisonlevi morrisonlevi mentioned this pull request Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c-extension Apply this label to issues and prs related to the C-extension 🏆 enhancement A new feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants