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 cloud trace propagator #819

Merged
merged 16 commits into from
Jun 17, 2020

Conversation

AndrewAXue
Copy link
Contributor

@AndrewAXue AndrewAXue commented Jun 11, 2020

Some old services (e.g. https://github.com/googleapis/cloud-trace-nodejs/blob/master/samples/app.js) still use the http header "X-Cloud-Trace-Context" to pass SpanContext. This propagator allows us both to inject and extract info from this http header so we have backwards compatibility both upstream and downstream.

Addresses issue GoogleCloudPlatform/opentelemetry-operations-python#5

@aabmass
Copy link
Member

aabmass commented Jun 16, 2020

I think this header is still required to get automatic tracing in App Engine, so this is great to have!

What does the user actually have to do to use CloudTraceFormatPropagator? Might be worth updating the docs.

…ter/cloud_trace/cloud_trace_propagator.py

Co-authored-by: Aaron Abbott <[email protected]>
)


def get_dict_value(dict_object: typing.Dict[str, str], key: str) -> str:
Copy link

Choose a reason for hiding this comment

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

Do we have any conventions for typing hints? I see typing hints being using in a few places, but I don't see much consistency.

Copy link
Member

Choose a reason for hiding this comment

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

The tl;dr is that these hints never get evaluated, and don't follow any convention in this repo. They're for the benefit of the person reading the code only and can be safely removed.

Longer answer:

Every public method in opentelemetry-api should have type hints. Tests in that package may have type hints, but the point is to uncover unexpected type changes in the API, not to document the tests.

tox -e mypy runs:

mypy --namespace-packages opentelemetry-api/src/opentelemetry/
mypy --namespace-packages --config-file=mypy-relaxed.ini opentelemetry-api/tests/

We don't run mypy for opentelemetry-sdk, but the public-facing parts of the SDK (including all the exporter classes) should have type hints, and we really should have a tox target that checks this.

We also don't run mypy on ext packages, so the type hints here are just documentation. If we wanted type checking for ext packages similar to the API package we could add a target that ran:

mypy --namespace-packages --config-file=mypy-relaxed.ini ext/opentelemetry-exporter-cloud-trace/tests

...but this fails right now, and we may need to add type stubs for dependencies to get meaningful results from mypy here.

Copy link
Member

Choose a reason for hiding this comment

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

Issue for tox not running mypy on the sdk: #773

Copy link

@kintel kintel left a comment

Choose a reason for hiding this comment

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

Added a few comments, mostly about test coverage.

Copy link
Member

@c24t c24t left a comment

Choose a reason for hiding this comment

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

Logic and tests look great, nice work @AndrewAXue!

)


def get_dict_value(dict_object: typing.Dict[str, str], key: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

The tl;dr is that these hints never get evaluated, and don't follow any convention in this repo. They're for the benefit of the person reading the code only and can be safely removed.

Longer answer:

Every public method in opentelemetry-api should have type hints. Tests in that package may have type hints, but the point is to uncover unexpected type changes in the API, not to document the tests.

tox -e mypy runs:

mypy --namespace-packages opentelemetry-api/src/opentelemetry/
mypy --namespace-packages --config-file=mypy-relaxed.ini opentelemetry-api/tests/

We don't run mypy for opentelemetry-sdk, but the public-facing parts of the SDK (including all the exporter classes) should have type hints, and we really should have a tox target that checks this.

We also don't run mypy on ext packages, so the type hints here are just documentation. If we wanted type checking for ext packages similar to the API package we could add a target that ran:

mypy --namespace-packages --config-file=mypy-relaxed.ini ext/opentelemetry-exporter-cloud-trace/tests

...but this fails right now, and we may need to add type stubs for dependencies to get meaningful results from mypy here.

Copy link

@kintel kintel left a comment

Choose a reason for hiding this comment

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

One remaining bug

Copy link

@kintel kintel left a comment

Choose a reason for hiding this comment

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

Getting close...

Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

Some minor suggestions 👍

@toumorokoshi toumorokoshi merged commit 9d74918 into open-telemetry:master Jun 17, 2020
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.

7 participants