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

Missing continueFromHeaders method #1346

Closed
marandaneto opened this issue Mar 22, 2021 · 8 comments
Closed

Missing continueFromHeaders method #1346

marandaneto opened this issue Mar 22, 2021 · 8 comments
Labels
enhancement New feature or request performance Performance API issues Platform: Java

Comments

@marandaneto
Copy link
Contributor

marandaneto commented Mar 22, 2021

When one wanna continue a trace from a header, right now it requires a bit of boilerplate and also no official docs on how to do it.

The guideline says we should provide a method called continueFromHeaders to make it easier https://develop.sentry.dev/sdk/performance/

eg Python https://github.com/getsentry/sentry-python/blob/2df9e1a230f1294b4fc319cb65838dcd6bb2e75c/sentry_sdk/tracing.py#L272

related to getsentry/sentry-docs#2984

@marandaneto marandaneto added enhancement New feature or request performance Performance API issues labels Mar 22, 2021
@marandaneto
Copy link
Contributor Author

@Tyrrrz this is relevant for you too

@maciejwalkowiak
Copy link
Contributor

Currently we support:

Sentry.startTransaction(TransactionContext.fromSentryTrace("name", "op", new SentryTraceHeader("header")));

continueFromHeaders(Map<String, List<String>> headers) does not bring value for Java as HttpServletRequest does not return headers as a map. Creating a method continueFromHeaders(HttpServletRequest request) would add a dependency on javax.servlet-api to the sentry-core which we also prefer to avoid. IMO having fromSentryTrace is good enough and perhaps adding docs would be sufficient. wdyt @marandaneto ?

@Tyrrrz
Copy link
Contributor

Tyrrrz commented Mar 22, 2021

Same story on .NET:
HTTP frameworks have their own container for headers, so supporting that would require an explicit dependency on the framework.

@marandaneto
Copy link
Contributor Author

marandaneto commented Mar 22, 2021

yeah if integrations have its own wrapper around headers etc, does not make much sense, so we need to tackle this via docs, I know the API pretty well and I could not find out that I had to use the startTransaction along with fromSentryTrace in 2 minutes search, so maybe we could consider even adding a method called continueFromHeaders that takes the header and we do it internally all the boiler plate which would be:

ISpan continueFromHeader(String name, String op, String header) {
  return Sentry.startTransaction(TransactionContext.fromSentryTrace(name, op, new SentryTraceHeader(header)));
}

at least the naming is a bit more suitable to the action, so I'd not even need to read the docs.
wdyt? @bruno-garcia

@Tyrrrz
Copy link
Contributor

Tyrrrz commented Mar 22, 2021

@marandaneto would that be hub.continueFromHeader(...)? maybe a bit ambiguous as to what it's continuing?

@bruno-garcia
Copy link
Member

To be honest I think just documenting: Sentry.startTransaction(TransactionContext.fromSentryTrace("name", "op", new SentryTraceHeader("header"))); is good enough no?

Only could be simplified to: Sentry.startTransaction(TransactionContext.fromSentryTrace("name", "op", "header")); though?

This API is only used when continuing a trace from some other system like a messaging middleware or an HTTP server so it's mostly used by integrations

@marandaneto
Copy link
Contributor Author

IMO the problem is, people are used to using the Static sentry class, that's the entry point API for everything, they don't know about TransactionContext most probably, also SentryTraceHeader so it's a bit buried and requires some investigation to find out (if you don't have docs), most people code using auto-complete and not docs, including me, I'm fine either way, but if I could not figure out by myself within 2 minutes, it's already a red flag, as its been for users already (otherwise this issue didn't exist), we definitely can start with docs and see how it goes, but as the spec says, continueFromHeader is a thin wrapper around fromSentryTrace and startTransaction, so why not?

@adinauer
Copy link
Member

adinauer commented May 3, 2022

We decided to document how to do this here https://docs.sentry.io/platforms/java/guides/spring/performance/instrumentation/custom-instrumentation/#distributed-tracing instead of adding the method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Performance API issues Platform: Java
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants