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

Simplify initialization #823

Closed
dyladan opened this issue Feb 28, 2020 · 1 comment · Fixed by #837
Closed

Simplify initialization #823

dyladan opened this issue Feb 28, 2020 · 1 comment · Fixed by #837
Labels
Discussion Issue or PR that needs/is extended discussion. feature-request
Milestone

Comments

@dyladan
Copy link
Member

dyladan commented Feb 28, 2020

Now that we introduced global context and propagation APIs, the user is required to initialize the tracer provider, the context manager, and the propagator before they can begin tracing. We should simplify this process with sane platform-specific defaults in some simple way. Possibly we should export some function from web and node packages like initializeGlobalDefaults or something?

@dyladan dyladan added feature-request Discussion Issue or PR that needs/is extended discussion. labels Feb 28, 2020
@dyladan dyladan added this to the Beta milestone Feb 28, 2020
This was referenced Feb 28, 2020
@dyladan
Copy link
Member Author

dyladan commented Mar 3, 2020

I asked in the spec SIG meeting how much freedom we have to do this, and the answer was that we can do basically whatever we deem appropriate as long as we don't violate spec or API. With that in mind, I think we should export some helper function from node and web packages that allows for global initialization easily.

I have some proposals for the way this may work:

Option 1

import sdk from "@opentelemetry/node";

// configuration object is optional, and all of its properties are optional
// Node tracer provider will be created and registered with api
sdk.configure({
  contextManager: manager, // default for node is async hooks, web is zone
  propagators: [traceContext, b3, correlation], // default is trace context
});

Option 2

import { NodeTracerProvider } from "@opentelemetry/node";

const provider = new NodeTracerProvider(/* options are unchanged */);

// configuration object is optional, and all of its properties are optional
provider.register({
  contextManager: manager, // default for node is async hooks, web is zone
  propagators: [traceContext, b3, correlation], // default is trace context
})

pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this issue Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Issue or PR that needs/is extended discussion. feature-request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant