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

Cleaning up the examples a little #741

Merged
merged 15 commits into from
Jul 3, 2022
Merged

Conversation

Grunet
Copy link
Contributor

@Grunet Grunet commented Jul 2, 2022

Resolves #426

I still need to smoke test the examples (and probably set up a shortcut to do that more easily in the future, as much as is feasible), but mostly looking for initial feedback on if the new folder structure seems improved to folks.

Otherwise I mostly tried to incorporate the thoughts I gathered from other folks in the issue thread.

@codecov
Copy link

codecov bot commented Jul 2, 2022

Codecov Report

Merging #741 (efedfd7) into main (4c10268) will increase coverage by 0.36%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #741      +/-   ##
============================================
+ Coverage     82.49%   82.86%   +0.36%     
- Complexity     1263     1295      +32     
============================================
  Files           145      150       +5     
  Lines          3125     3192      +67     
============================================
+ Hits           2578     2645      +67     
  Misses          547      547              
Flag Coverage Δ
7.4 82.87% <ø> (+0.37%) ⬆️
8.0 82.92% <ø> (+0.36%) ⬆️
8.1 82.92% <ø> (+0.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/Contrib/Zipkin/SpanConverter.php 96.29% <0.00%> (-0.07%) ⬇️
src/Contrib/Jaeger/SpanConverter.php 95.23% <0.00%> (-0.06%) ⬇️
src/API/Trace/TraceState.php 100.00% <0.00%> (ø)
src/SDK/Common/Exception/StackTraceFormatter.php 0.00% <0.00%> (ø)
...n/Adapter/HttpDiscovery/HttpPlugClientResolver.php 100.00% <0.00%> (ø)
...n/Adapter/HttpDiscovery/MessageFactoryResolver.php 100.00% <0.00%> (ø)
...ommon/Adapter/HttpDiscovery/DependencyResolver.php 100.00% <0.00%> (ø)
...Common/Adapter/HttpDiscovery/PsrClientResolver.php 100.00% <0.00%> (ø)
src/SDK/Common/Http/Psr/Message/MessageFactory.php 100.00% <0.00%> (ø)
src/Context/Context.php 78.57% <0.00%> (+1.90%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c10268...efedfd7. Read the comment docs.

@Grunet Grunet marked this pull request as ready for review July 2, 2022 05:22
@@ -1,7 +1,7 @@
<?php

declare(strict_types=1);
require 'vendor/autoload.php';
require '/../../../../vendor/autoload.php';
Copy link
Member

@tidal tidal Jul 2, 2022

Choose a reason for hiding this comment

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

This doesn't work, since the main libraries autoloader is out of the scope of the docker-compose context, and it wouldn't pull in the depencies of the demo (slim, etc.), so it needs to be require 'vendor/autoload.php';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup good call, switched it back.

I also was curious and tried to get this demo working, but got stuck after updating the tags on the opentelemetry-php-base images ("latest" was pulling in an image from 7 months ago) and exposing the 4317 port on the collector.

Have a hunch something's off with the exporting from PHP but couldn't figure out how to troubleshoot (since this example wants to do all the config via environment variables and the OTEL_LOG_LEVEL one isn't supported yet afaict)

Copy link
Member

@tidal tidal Jul 3, 2022

Choose a reason for hiding this comment

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

Yap, I tried the demo as well a few days ago, and it didn't really work. However I used it about 2 months ago for a Otel workshop at work, and it worked fine.
Maybe @brettmc can have a look at it, once he is back. (Can you Brett?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I sure can take a look at it, right now.

Copy link
Collaborator

@brettmc brettmc Jul 6, 2022

Choose a reason for hiding this comment

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

@Grunet @tidal I found a regression/bug. It's kinda hard to write a test for, since it involves a TracerProvider being destroyed as soon as it is created (I think introduced in the fix for #716 )
In short, this works:

$tracerProvider = (new TracerProviderFactory('example'))->create();
$tracer = $tracerProvider->getTracer('io.opentelemetry.contrib.php');

and this doesn't work:

$tracer = (new TracerProviderFactory('example'))->create()->getTracer('io.opentelemetry.contrib.php');
//or
$tracer = (new TracerProvider([$spanProcessor])->getTracer('foo');

I'll take this up on slack...

@tidal
Copy link
Member

tidal commented Jul 2, 2022

@Grunet Thanks!!!

There is only one small issue, which needs to be fixed, otherwise I'd merge this PR as is, as it already improves the examples by a lot.
For any additional improvements I'd just create another ticket.

@Grunet
Copy link
Contributor Author

Grunet commented Jul 3, 2022

I also added in a make target to just try and run through more of the examples to make sure nothing crashes (I also found a bug along the way using it! Another incorrect path issue). Figured it might be a helpful sanity check in the future w/o a super high maintenance burden (if there's a clever way not to have to list individual example files out too that'd be cool to learn about too)

@Grunet Grunet requested a review from tidal July 3, 2022 05:25
@tidal
Copy link
Member

tidal commented Jul 3, 2022

Figured it might be a helpful sanity check in the future w/o a super high maintenance burden (if there's a clever way not to have to list individual example files out too that'd be cool to learn about too)
Yeah, I have also thought about that, since for beta we should make sure very example really works, otherwise it could be confusing or frustrating for users.

If you would like to work on that, you could add a command to https://github.com/opentelemetry-php/dev-tools.
I'm happy to help you with everything there, if you need help.

For finding the respective file, one could use FilesystemIterator or Symfony's Finder Component.

To run the tests in an isolated process one could use Symfony's Process Component

Let me know, if that's somthing you would be interested in.

Other than that, I'll merge this PR. :)

@tidal tidal merged commit aaa93ee into open-telemetry:main Jul 3, 2022
@Grunet
Copy link
Contributor Author

Grunet commented Jul 6, 2022

If you would like to work on that, you could add a command to https://github.com/opentelemetry-php/dev-tools. I'm happy to help you with everything there, if you need help.

For finding the respective file, one could use FilesystemIterator or Symfony's Finder Component.

To run the tests in an isolated process one could use Symfony's Process Component

Let me know, if that's somthing you would be interested in.

Other than that, I'll merge this PR. :)

Oh yeah interesting I hadn't thought of actually using PHP to manage that! (I was just trying to think a little if there was some clear 1 liner makefile thing, or shell script thing, but gave up pretty quick)

I think it's probably ok for now imo (seems safe/quick to refactor if it gets unwieldy).

I'll go ahead and take a look at what else I can maybe help with amongst the issues

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.

Revamp examples
3 participants