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

Add DataDog tracing stub #1653

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Jean85
Copy link
Contributor

@Jean85 Jean85 commented Jul 10, 2024

This PR adds the DataDog ddtracing extensions stubs.

These stubs are copied from their repository: https://github.com/DataDog/dd-trace-php/blob/master/ext/ddtrace.stub.php
Their code is dual-licensed Apache2/BSD3, so it's compatible with this repo: https://github.com/DataDog/dd-trace-php/blob/master/LICENSE

* @var int
* @cvalue DD_TRACE_DBM_PROPAGATION_DISABLED
*/
const DBM_PROPAGATION_DISABLED = UNKNOWN;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please change UNKNOWN to the valid values for all constants?

namespace DDTrace {
/**
* @var int
* @cvalue DD_TRACE_DBM_PROPAGATION_DISABLED
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please clarify what is the puprose of @cvalue tag? Could you please remove these tags? Tests checks PHPDocs for validness based on "canonical" list of PHPDoc tags (https://docs.phpdoc.org/3.0/guide/guides/docblocks.html#more-on-docblocks) and with such tags test will fail. Also after you change the value of constant to a valid scalar, @var tag also can be removed as redundant in other declarations

@@ -0,0 +1,1051 @@
<?php

/** @generate-class-entries */
Copy link
Contributor

Choose a reason for hiding this comment

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

This line probably can be just removed

public string $spanId;

/**
* @var string $traceState
Copy link
Contributor

Choose a reason for hiding this comment

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

This PHPDoc and some other similar below also can be removed as redundant since declaration already defines the name and the type of property

public function getLink(): SpanLink {}

/**
* @return Returns the span id as zero-padded 16 character hexadecimal string.
Copy link
Contributor

Choose a reason for hiding this comment

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

@return tag doesn't declare type here. Please change to @return string Returns the span id .....

*
* @param \DDTrace\Span $span the span associated with this user request.
* @param array $data an array with keys named '_GET', '_POST', '_SERVER', '_FILES', '_COOKIE'
* @param string|resource|null $body the body of the request (a string or a seekable resource)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any advantages of string|resource|null comparing to ?mixed type hint here? Maybe replace it to ?mixed equal to signature?


/**
* Notifies the user request listeners of the imminence of a commit, and allows for the replacement of the response.
* @param \DDTrace\Span $span the span associated with this user request.
Copy link
Contributor

Choose a reason for hiding this comment

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

The same issues as above

* @return string|null The app name, else the fallback name. Return 'null' if the app name isn't set and no
* fallback name is provided.
*/
function ddtrace_config_app_name(?string $fallbackName = null): null|string {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe change return type to ?string instead of union type?

* @param mixed $args,... Arguments of the function
* @return mixed false if void function was properly executed, else the return value of it
*/
function dd_trace_internal_fn(string $functionName, mixed ...$args) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to declare return type mixed in signature as well?

function dd_trace_close_all_spans_and_flush(): void {}

/**
* @alias DDTrace_trace_function
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please change @alias tag to @see. Stub tests check PHPDoc tags based on canonical list of tags https://docs.phpdoc.org/3.0/guide/guides/docblocks.html#more-on-docblocks and these tags don't contain @alias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants