Skip to content
This repository has been archived by the owner. It is now read-only.

Support for the TrackDependency method of Telemetry Client #24

Merged
merged 2 commits into from Feb 23, 2017
Merged

Support for the TrackDependency method of Telemetry Client #24

merged 2 commits into from Feb 23, 2017

Conversation

@artberri
Copy link
Contributor

@artberri artberri commented Feb 22, 2017

This PR adds support for the TrackDependency method of the Client, and includes:

  • Fixed Unit Test due to PhpUnit library update
  • Refactor of Contracts to avoid repeated code.
  • Added trackDependency method to the Telemetry Client.
  • Unit Test added for the trackDependency method.
  • README.md updated with examples of the new method.
composer install
php vendor/bin/phpunit ./ApplicationInsights/Tests 
PHPUnit 4.8.35 by Sebastian Bergmann and contributors.

.........................

Time: 160 ms, Memory: 6.00MB

OK (25 tests, 54 assertions)

Related: #18

Let me know if there is something wrong or if I need to fix something to get this merged.

PD. I have needed to review other language SDKs in order to be able to build this. Is there any proper documentation about every available method and parameters when tracking with AppInsights?

@JakubOleksy
Copy link
Contributor

@JakubOleksy JakubOleksy commented Feb 23, 2017

Looks good to me. i don't have a setup anymore to test this. I assume you confirmed that with these changes all the data still flows to Application Insights?

@artberri
Copy link
Contributor Author

@artberri artberri commented Feb 23, 2017

Yes, we are already using our branch.

Here you have a functional test just in case:

<?php

require __DIR__ . '/vendor/autoload.php';

$telemetryClient = new \ApplicationInsights\Telemetry_Client();
$telemetryClient->getContext()->setInstrumentationKey('XXXXXXX');

$telemetryClient->trackEvent('everythingstillok', ['MyCustomProperty' => 42, 'MyCustomProperty2' => 'test'], ['duration' => 42]);
$telemetryClient->flush();
$telemetryClient->trackEvent('everythingstillok');
$telemetryClient->trackEvent('everythingstillok');
$telemetryClient->trackPageView('everythingstillok', 'http://www.foo.com');
$telemetryClient->trackPageView('everythingstillok', 'http://www.foo.com', 256, ['InlineProperty' => 'test_value'], ['duration' => 42.0]);
$telemetryClient->trackMetric('everythingstillok', 42.0);
$telemetryClient->trackMetric('everythingstillok', 42.0, \ApplicationInsights\Channel\Contracts\Data_Point_Type::Aggregation, 5, 0, 1, 0.2, ['InlineProperty' => 'test_value']);
$telemetryClient->trackMessage('everythingstillok', ['InlineProperty' => 'test_value']);
$telemetryClient->trackRequest('everythingstillok', 'http://foo.bar', time());
$telemetryClient->trackRequest('everythingstillok', 'http://foo.bar', time(), 3754, 200, true, ['InlineProperty' => 'test_value'], ['duration_inner' => 42.0]);
$telemetryClient->trackException(new \Exception('everythingstillok'), ['InlineProperty' => 'test_value'], ['duration_inner' => 42.0]);
$telemetryClient->trackDependency('SQL everythingstillok', \ApplicationInsights\Channel\Contracts\Dependency_Type::SQL, 'SELECT * FROM hola;', time(), 100, true, 200, true);
$telemetryClient->trackDependency('http://everythingstillok.com/a5533355', \ApplicationInsights\Channel\Contracts\Dependency_Type::HTTP, null, time(), 100, false, 400, false);
$telemetryClient->trackDependency('OTHER everythingstillok', \ApplicationInsights\Channel\Contracts\Dependency_Type::OTHER, 'Other text', time(), 100, true);
$telemetryClient->flush();

capt

Once it is merged, could you bump a new version (0.4.0 I guess) so we can reference it in other projects?

I have done this Symfony integration and I need it in order to bump a new version also:
https://github.com/artberri/BerriartAPMBundle

Thank you in advance.

PD. Stil... Is there no doc about the API? :D

@JakubOleksy JakubOleksy merged commit a1fd851 into microsoft:master Feb 23, 2017
@artberri
Copy link
Contributor Author

@artberri artberri commented Feb 24, 2017

@JakubOleksy Could you bumb a new version (push a new tag to the repo)? -> 0.4.0

This is needed to add this library as a dependency to other project using Composer.

@gardnerjr
Copy link
Contributor

@gardnerjr gardnerjr commented Feb 24, 2017

This looks like it is the "old" schema for dependencies? at a quick glance, i see "kind" and all that stuff, instead of user defined "type" and new fields documented here:

https://github.com/Microsoft/ApplicationInsights-dotnet/blob/develop/Schema/PublicSchema/RemoteDependencyData.bond

i don't think there's anything "wrong" with using the old schema, it just isn't as flexible as the new one.

i think the closest thing to docs about the schema are those bond files:
https://github.com/Microsoft/ApplicationInsights-dotnet/tree/develop/Schema/PublicSchema

most of the c# code is generated from those bond files, is there a php way to generate those too?

@JakubOleksy
Copy link
Contributor

@JakubOleksy JakubOleksy commented Feb 25, 2017

Ok, bumped the version. Should be all set? Let me know.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants