Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: Fix opentelemetry interceptors #340

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

Merged
merged 3 commits into from
Oct 28, 2021
Merged

fix: Fix opentelemetry interceptors #340

merged 3 commits into from
Oct 28, 2021

Conversation

bergundy
Copy link
Member

  • 💥 Make makeWorkflowExporter resource param required
  • Fix Workflow span timestamps
  • Disable internal SDK tracing by default
  • Connect child workflow traces to their parent
  • Connect continueAsNew traces
  • Add activity type and workflow type to span names and copy format from Java SDK
  • 💥 Some breaking changes were made to the interceptor interfaces
    • workflowType input attribute is now consistently called workflowType
  • Change trace header name for compatibility with Go and Java tracing implementations
  • Closes [Bug] Opentelemetry bugs/findings #330
  • Closes [Feature Request] Opentracing Support #219
  • Does not expose a way to customize span names at the moment

Tested compatibility with modified Go contextpropation sample.
For Go Jaeger tracer compatibility:

  • npm i @opentelemetry/propagator-jaeger
  • At the top level of your Workflow code and Worker code, add the following lines:
    import { propagation } from '@opentelemetry/api';
    import { JaegerPropagator } from '@opentelemetry/propagator-jaeger';
    api.propagation.setGlobalPropagator(new JaegerPropagator());

Comment on lines 64 to 66
/**
* Activity is executing
*/
Copy link
Member

Choose a reason for hiding this comment

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

Wrong comment

}
return await instrumentFromSpanContext(getTracer(), spanContext, SpanName.WORKFLOW_EXECUTE, () => next(input));
const context = await extractContextFromHeaders(input.headers);
const spanName = `${SpanName.WORKFLOW_EXECUTE}${SPAN_DELIMITER}${workflowInfo().workflowType}`;
Copy link
Member

Choose a reason for hiding this comment

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

All these string makers could just be functions that live next to the constants. Keeps everything together a little better

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 find this ok, it's clear what the outcome is.

const nonOptionalOptions = { workflowType: state.info?.workflowType, taskQueue: state.info?.taskQueue, ...options };
const info = workflowInfo();
const { workflowType, taskQueue, ...rest } = options ?? {};
const nonOptionalOptions = {
Copy link
Member

Choose a reason for hiding this comment

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

That's a funny way of saying "required" 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

:)

@bergundy bergundy force-pushed the otel-fixes branch 3 times, most recently from cc56471 to 7799797 Compare October 28, 2021 13:51
- Make `makeWorkflowExporter` resource param required
- Fix Workflow span timestamps
- Disable internal SDK tracing by default
- Connect child workflow traces to their parent
- Connect continueAsNew traces
- Some breaking changes were made to the interceptor interfaces
- Change trace header name for compatibility with Go and Java tracing implementations
parentSpanId === originalSpan?.spanContext().spanId
);
t.true(firstExecuteSpan !== undefined);
const continueAsNewSpan = spans.find(
Copy link
Member Author

Choose a reason for hiding this comment

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

@Spikhalskiy WDYT about the continue as new behavior?

Choose a reason for hiding this comment

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

ContinueAsNew as a child span of the original run makes sense if this continueAsNew is triggered by the original run.
Just discovered that in JavaSDK continueAsNew creates a workflow with the same exact headers as the original workflow. This means that continueAsNew run will be on the same level in spans structure as the original run. This probably should be fixed in JavaSDK.

@bergundy
Copy link
Member Author

I'm force merging this, looks like GH actions machines are really struggling.
I've seen timeouts in almost every job.

  • Downloading the cassandra docker image
  • Random tests timing out
    Might be time to connect our own builder instances.

@bergundy bergundy merged commit e426688 into main Oct 28, 2021
@bergundy bergundy deleted the otel-fixes branch October 28, 2021 17:06
@schickling
Copy link

@bergundy would be great if you could publish a new version on NPM :)

@bergundy
Copy link
Member Author

bergundy commented Oct 29, 2021 via email

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.

[Bug] Opentelemetry bugs/findings [Feature Request] Opentracing Support
5 participants