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

feat(http): allow to disable span without parent for outgoing requests #931

Closed
vmarchaud opened this issue Apr 6, 2020 · 14 comments
Closed
Assignees
Labels
Discussion Issue or PR that needs/is extended discussion. feature-request

Comments

@vmarchaud
Copy link
Member

I'm trying to setup tracing across my microservices (~10) and one is sending periodic request to internal GCP stuff.
I know i could ignore them one by one using the ignoreOutgoingUrls option but that would not really be future proof in case new code get added in the underlying library i'm using :/
I can't use something like ignoreOutgoingUrls: /.*/ because that would also disable spans created inside a trace.

My request would be to add an option called disableOutgoingTraces: true that would just avoid creating a new span if none exist in the context. WDYT ?

I'm happy to make the PR ofc

@vmarchaud vmarchaud added feature-request Discussion Issue or PR that needs/is extended discussion. labels Apr 6, 2020
@dyladan
Copy link
Member

dyladan commented Apr 6, 2020

This is a topic the spec has been talking about recently actually. They want to create a context var that disables tracing and I have a nodejs prototype. Works like this:

context.with(disableTracing(context.active()), () => {
	// do something here with tracing disabled
})

does that cover your use case?

@vmarchaud
Copy link
Member Author

context.with(disableTracing(context.active()), () => {
// do something here with tracing disabled
})

Not really because the span are created by the http plugin, not my own code. However in other cases, i agree that this feature would be helpful for end users

@dyladan
Copy link
Member

dyladan commented Apr 6, 2020

Where are you suggesting this option? Are you trying to disable the http plugin entirely? I guess i'm not fully understanding the usecase here.

@vmarchaud
Copy link
Member Author

I'm trying to disable the creation of new span for outgoing request when there are no context/no parent. That would require to add a check here like so:

const currentSpan = plugin.tracer.getCurrentSpan()
if (plugin.options.disableOutgoingTraces && currentSpan === null) {
 return original.apply(this, arguments)
}

@dyladan
Copy link
Member

dyladan commented Apr 6, 2020

Ah I understand. i think disableOutgoingTraces is just a little misleading because it implies all traces are disabled. I think disableOutgoingRootSpans or something similar that makes it clear the only spans being disabled are ones with no parent.

@Flarna
Copy link
Member

Flarna commented Apr 7, 2020

I think it would make sense that each plugin has an requiresParent (or whatever name sounds better).
Each plugin should use a reasonable default value which may differ from plugin to plugin.

@vmarchaud
Copy link
Member Author

Will open PRs for express and http tomorrow then :)

@vmarchaud vmarchaud self-assigned this Apr 7, 2020
@dyladan
Copy link
Member

dyladan commented Apr 7, 2020

Will open PRs for express and http tomorrow then :)

It might make more sense to introduce this as a single PR that adds the option to all plugins with a per-plugin default value. e.g. express would default to not creating root spans, and http would default to creating them.

@Flarna
Copy link
Member

Flarna commented Apr 7, 2020

Just realized that there is just a single http plugin, not one for server and one for client. Therefore I think a single setting is too limiting for the http plugin.

@dyladan
Copy link
Member

dyladan commented Apr 7, 2020

Having a single plugin for client and server is, in my opinion, a mistake anyways. it may be too late to fix though

@Flarna
Copy link
Member

Flarna commented Apr 7, 2020

Other plugins for outgoing requests like MongoDb requires always a parent (see https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-plugin-mongodb/src/mongodb.ts#L110).
I think the default is ok here but an options would be nice.

@vmarchaud
Copy link
Member Author

Just realized that there is just a single http plugin, not one for server and one for client. Therefore I think a single setting is too limiting for the http plugin.

We can totally have one option for both, i will implement that.

vmarchaud added a commit to vmarchaud/opentelemetry-js that referenced this issue Apr 8, 2020
vmarchaud added a commit to vmarchaud/opentelemetry-js that referenced this issue Apr 8, 2020
vmarchaud added a commit to vmarchaud/opentelemetry-js that referenced this issue Apr 9, 2020
vmarchaud added a commit to vmarchaud/opentelemetry-js that referenced this issue Apr 12, 2020
vmarchaud added a commit to vmarchaud/opentelemetry-js that referenced this issue Apr 15, 2020
vmarchaud added a commit to vmarchaud/opentelemetry-js that referenced this issue Apr 18, 2020
vmarchaud added a commit to vmarchaud/opentelemetry-js that referenced this issue Apr 25, 2020
vmarchaud added a commit to vmarchaud/opentelemetry-js that referenced this issue May 2, 2020
vmarchaud added a commit to vmarchaud/opentelemetry-js that referenced this issue May 6, 2020
@pauldraper
Copy link
Contributor

Spec discussion about disabling via context: open-telemetry/opentelemetry-specification#530

@vmarchaud
Copy link
Member Author

#948 has been merged, closing

pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this issue Dec 15, 2023
* feat: adding docker container id detector for supported version(cgroup v1)

* some name changes and license update and refactor

* some name changes and license update and refactor

* removed test path for cgroup

* changed readme to show updated detector name

* fix lint error and package.json as per PR comments

* adding detector to .release-please-manifest.json

* removing trailing spaces in README.md and pinning a peer dependency

* lint error fix

* refactor(@opentelemetry-js-contrib): reverting release-please-manifest and refactor as per comments

Signed-off-by: abhinav mathur <abhinama@cisco.com>

* refactor(opentelemetry-contrib-js): adding eslintrc and ignore files

Signed-off-by: abhinav mathur <abhinama@cisco.com>

* refactor(opentelemetry-js-contrib): pr comments

Signed-off-by: abhinav mathur <abhinama@cisco.com>

* refactor(opentelemetry-js-contrib): adding detector to release config

Signed-off-by: abhinav mathur <abhinama@cisco.com>

* refactor(opentelemetry-js-contrib): pr comments refactor

Signed-off-by: abhinav mathur <abhinama@cisco.com>

* refactor(opentelemetry-js-contrib): pr comments tests refactor

Signed-off-by: abhinav mathur <abhinama@cisco.com>

* refactor(opentelemetry-js-contrib): making test robust and chaging warning to info

Signed-off-by: abhinav mathur <abhinama@cisco.com>

Co-authored-by: Rauno Viskus <Rauno56@users.noreply.github.com>
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
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

No branches or pull requests

4 participants