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 ContextManager interface and AsyncHooks implementation #62

Closed
wants to merge 2 commits into from

Conversation

vmarchaud
Copy link
Member

As defined in #46, i've not use types already available in the core package since the goal is for those package to be standalone.
I didn't really tested the implementation (specially the async hooks one) since the API isn't finished but i will add more test in a separate PR.

I mostly based the API on the Opencensus one, i will explain the choice i made for each function so we have a starting point for the discussion.

@vmarchaud vmarchaud marked this pull request as ready for review June 26, 2019 22:00
@vmarchaud
Copy link
Member Author

@@ -0,0 +1,126 @@
/**
Copy link
Member Author

Choose a reason for hiding this comment

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

This file is pretty much the same as Opencensus: https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/internal/cls-ah.ts, i didn't saw the point of re-implementing differently since this one is already used in production with Census.


/** A key/value object for anything that can be stored in the context */
export interface ContextStore {
[key: string]: unknown;
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 believe the simpler is the API, the better it is. So instead of having a custom class and get/set method i choose to just expose a object there.

* handler).
* @param fn A function to which to bind the trace context.
*/
wrapFunction<T>(fn: Func<T>): Func<T>;
Copy link
Member Author

Choose a reason for hiding this comment

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

Pretty much the most important function to propagate context, i re-used the signature of the Census implementation.

@mayurkale22 mayurkale22 requested review from bg451, rochdev and hekike June 26, 2019 22:09
* There are specific case where the context is not propagated by specific
* code (ex: user space queueing) so expect it to be null sometimes.
*/
getCurrentContext(): ContextStore | null;
Copy link
Member Author

Choose a reason for hiding this comment

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

We should also choose if we return a empty object or null when there are no active context. I would prefer to use null there since users would not trust it's content.

@mayurkale22
Copy link
Member

mayurkale22 commented Jun 26, 2019

Thanks for the PR. I would suggest to split this huge PR in a few smaller PRs.

  1. Initial skeleton (package) for base
  2. Initial skeleton (package) for AsyncHooks (If you want, you can combine 1 and 2)
  3. ContextManager interface
  4. AsyncHooks implementation

thoughts?

@vmarchaud
Copy link
Member Author

Sure no problem @mayurkale22

@vmarchaud vmarchaud closed this Jun 27, 2019
@vmarchaud
Copy link
Member Author

I made two new PR over there #65 and #66, please review on those

dyladan pushed a commit to dyladan/opentelemetry-js that referenced this pull request Sep 9, 2022
dyladan pushed a commit to dyladan/opentelemetry-js that referenced this pull request Sep 9, 2022
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.

3 participants