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 protobuf via gRPC exporting support for Jaeger #1471

Merged
merged 46 commits into from
Jan 4, 2021

Conversation

srikanthccv
Copy link
Member

@srikanthccv srikanthccv commented Dec 13, 2020

Description

This change adds ability to export traces to Jaeger with protobuf via gRPC.

Fixes #1437

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Manual testing with jaeger-all-in-one
  • Added unit tests for protobuf translation

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@srikanthccv srikanthccv requested review from a team, toumorokoshi and aabmass and removed request for a team December 13, 2020 15:47
@@ -26,7 +26,6 @@ envlist =

; opentelemetry-exporter-jaeger
py3{5,6,7,8,9}-test-exporter-jaeger
pypy3-test-exporter-jaeger
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this being removed?

Copy link
Member Author

@srikanthccv srikanthccv Dec 18, 2020

Choose a reason for hiding this comment

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

https://github.com/open-telemetry/opentelemetry-python/blob/master/tox.ini#L31-L37

I think pypy3 doesn't work with exporters which have protobuf via gRPC. It is excluded from otlp and opencensus. It was failing for jaeger as well, that's why I had removed this.

@@ -39,6 +39,8 @@ package_dir=
=src
packages=find_namespace:
install_requires =
grpcio >= 1.0.0, < 2.0.0
Copy link
Member

Choose a reason for hiding this comment

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

since this isn't required for all exporter configurations, should this be an extras_require?

I personally don't care about bloating package dependencies and including unneeded ones, but I've found that to be a prickly subject for others.

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 think this is needed as we have import for from grpc and typehints in certain places.

from grpc import (
    ChannelCredentials,
    insecure_channel,
    secure_channel,
    ssl_channel_credentials,
)

from opentelemetry.exporter.jaeger.gen.agent import Agent as agent
from opentelemetry.exporter.jaeger.gen.jaeger import Collector as jaeger

UDP_PACKET_MAX_LENGTH = 65000
Copy link
Member

Choose a reason for hiding this comment

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

are you suggesting this is an issue? I personally kind of like having this defined. Learned something new about UDP :)

buff = self.buffer.getvalue()
if len(buff) > self.max_packet_size:
logger.warning(
"Data exceeds the max UDP packet size; size %r, max %r",
Copy link
Member

Choose a reason for hiding this comment

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

since this is configurable, this error message won't always be accurate. Would it be better to reference max_packet_size?

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't it already there?

            logger.warning(
                "Data exceeds the max UDP packet size; size %r, max %r",
                len(buff),
                self.max_packet_size,
            )

Are you saying something different?

)
return

with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket:
Copy link
Member

Choose a reason for hiding this comment

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

would you not want to re-use an existing socket here?

Comment on lines 225 to 227
jaeger_spans = protobuf._to_jaeger(spans, self.service_name)
batch = model_pb2.Batch(spans=jaeger_spans)
request = PostSpansRequest(batch=batch)
Copy link
Member

Choose a reason for hiding this comment

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

I think this if is justified, IIUC the point is that values from lines 225-227 aren't used if the second if isn't true. I see @ocelotl's point as well: it seems the above three can be moved to the below if.

We can't get rid of this if (I don't believe we can accept default protobuf values), but we can reduce unneeded work if it's not true.

Copy link
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

Thanks! A few minor points but overall the code looks good.

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.

LGTM 👍

@lzchen lzchen merged commit bd8db6e into open-telemetry:master Jan 4, 2021
@srikanthccv srikanthccv deleted the jaeger-protobuf branch September 24, 2021 08:40
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.

Jaeger exporter must support Protobuf via gRPC
4 participants