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

chore: clean up span naming #162

Merged
merged 3 commits into from
Jul 31, 2020
Merged

chore: clean up span naming #162

merged 3 commits into from
Jul 31, 2020

Conversation

johnbley
Copy link
Member

  • Clean up span naming to OpenTelemetry specifications (existing names are discouraged as having high cardinality)
  • Centralize logic for what event types to allow, and allow dblclick as well as click
  • (Bad form, but blergh): forgot to unpatch removeEventListener from yesterday's work.

@johnbley johnbley requested a review from a team July 24, 2020 20:01
@codecov
Copy link

codecov bot commented Jul 24, 2020

Codecov Report

Merging #162 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #162   +/-   ##
=======================================
  Coverage   94.10%   94.10%           
=======================================
  Files          74       74           
  Lines        3582     3582           
  Branches      387      387           
=======================================
  Hits         3371     3371           
  Misses        211      211           
Impacted Files Coverage Δ
...try-plugin-user-interaction/src/userInteraction.ts 93.80% <0.00%> (ø)

@kkruk-sumo
Copy link
Contributor

@johnbley Is there a plan to do the same for plugin-document-load and plugin-xml-http-request (in both cases URLs are used as span operation names)?

@johnbley
Copy link
Member Author

@johnbley Is there a plan to do the same for plugin-document-load and plugin-xml-http-request (in both cases URLs are used as span operation names)?

Yes, working my way through a number of smaller issues like this. Doing one area at a time to not overwhelm the maintainers. 😄

@dyladan
Copy link
Member

dyladan commented Jul 29, 2020

@obecny particularly looking for your feedback on this one

/**
* Controls whether or not to create a span, based on the event type.
*/
protected allowEventType(eventType: string): boolean {
Copy link
Member

Choose a reason for hiding this comment

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

this should be private as it is not used by any subclass?

Prefix protected and private methods with _

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to leave a way for users to specialize their own list of "interesting enough" events (possibly even dynamic, unlike with a config item). If that's not cool I can make it private. Either way I'll prefix with _.

Copy link
Member

Choose a reason for hiding this comment

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

By writing an instrumentation module which extends ours? that is an interesting idea.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also: perhaps the lint rules could be expanded to enforce the naming?

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

We can either add such possibility to a plugin config. This can be a 2 callbacks

{
  allowEventType(eventType: string) {
    if (eventType === ....) { // write your own logic
      return true;
    }
  },
  updateSpanName(target: HTMLElement) {
   // write your own logic
   return 'spanName';
  }
}

By default I would support click event only

For event better convenience the plugin could have the 2 public methods with the same name that can be simply override. This way it would allow you to create a plugin without necessity of configuration. Such solution would satisfy anyone then and would allow much more customisation

@johnbley
Copy link
Member Author

johnbley commented Jul 29, 2020

We can either add such possibility to a plugin config. This can be a 2 callbacks

Sorry, not understanding this. You would like _updateInteractionName to be protected as well?

By default I would support click event only

Will do.

@obecny
Copy link
Member

obecny commented Jul 29, 2020

We can either add such possibility to a plugin config. This can be a 2 callbacks

Sorry, not understanding this. You would like _updateInteractionName to be protected as well?

By default I would support click event only

Will do.

I meant when you instantiate plugin

const providerWithZone = new WebTracerProvider({
  plugins: [
    new UserInteractionPlugin({
      allowEventType(eventType: string) {
        if (eventType === ....) { // write your own logic
          return true;
        }
      },
      updateSpanName(target: HTMLElement) {
       // write your own logic
       return 'spanName';
      }
    }),
  ]
});

and 2nd possibility

class MyUserInteractionPlugin extends UserInteractionPlugin {
  allowEventType(eventType: string) {
    if (eventType === ....) { // write your own logic
      return true;
    }
  },
  updateSpanName(target: HTMLElement) {
   // write your own logic
   return 'spanName';
  }
}

@johnbley
Copy link
Member Author

class MyUserInteractionPlugin extends UserInteractionPlugin {

This (strongly typed) is my preference - easier for IDEs, static tools, etc. to analyze/understand the specialization. That's what the current patch uses.

Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

I like the simpler names, and the xpath is still available as an attribute if needed. The use-case for the protected method seems valid to me and anyway there is no way to make a method truly private in JS anyways without jumping through crazy hoops.

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

lgtm

@obecny obecny merged commit f0c0626 into open-telemetry:master Jul 31, 2020
@dyladan dyladan added the enhancement New feature or request label Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants