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

gRPC integration #476

Merged
merged 68 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
1f772fa
Add package boilerplate
c24t Mar 10, 2020
3377e9e
Copy OC examples
c24t Mar 10, 2020
38bb4ef
Move examples, add boilerplate
c24t Mar 10, 2020
7182f3d
Add stub client and server interceptors
c24t Mar 10, 2020
9e4cbca
Add gRPC unary examples
c24t Mar 10, 2020
72a8247
Add stub docs
c24t Mar 11, 2020
d09a0e9
Add unary server interceptor logic
c24t Mar 12, 2020
d11b855
Extend server example
c24t Mar 12, 2020
0c33c80
Add server interceptor tests
c24t Mar 12, 2020
f0b0ba5
TODOs
c24t Mar 12, 2020
483c32f
Missing init
c24t Mar 13, 2020
88e9467
Copy grpc_opentracing
c24t Mar 13, 2020
987d6d4
Cleanup
c24t Mar 13, 2020
3c80b31
Scrub more OpenTracing references, unused code
c24t Mar 24, 2020
19d91ec
Add wait_for_termination
c24t Mar 24, 2020
5a74710
Update interceptors, unary examples
c24t Mar 24, 2020
20c0e9f
Merge branch 'master' into grpc-again
c24t Mar 24, 2020
b597a80
Use get/set_tracer_provider
c24t Mar 24, 2020
f24f826
Add gRPC route guide streaming examples
c24t Mar 24, 2020
6a104cc
Update generated gRPC files
c24t Mar 24, 2020
5846938
Instrument gRPC examples
c24t Mar 24, 2020
82a78de
Handle streaming requests/responses in client
c24t Mar 24, 2020
aa79c70
Handle streaming requests/responses in server
c24t Mar 24, 2020
3845604
Update server tests
c24t Mar 25, 2020
9cf65ab
Set server context explicitly
c24t Mar 25, 2020
835e831
Merge branch 'master' into grpc-again
c24t Mar 25, 2020
55efac2
Remove unused server test classes
c24t Mar 25, 2020
82530ae
Exclude gRPC examples from lint
c24t Mar 25, 2020
8ea858f
Remove OC interceptors
c24t Mar 25, 2020
ac10d52
Update server context managers
c24t Mar 25, 2020
60afdb8
s/OpenTelemetry/OpenTracing/
c24t Mar 25, 2020
fa18357
Move grpc examples, generated code
c24t Mar 25, 2020
bc585d4
Make examples portable
c24t Mar 25, 2020
a3e0c86
Lint, blacken
c24t Mar 25, 2020
401b488
Don't lint generated files
c24t Mar 25, 2020
47e4eed
Remove extra test file
c24t Mar 26, 2020
bb33a9d
Update ext/opentelemetry-ext-grpc/src/opentelemetry/ext/grpc/version.py
c24t Mar 26, 2020
3d49b86
Remove old example dir
c24t Mar 26, 2020
df9f745
Remove copyright year (#523)
mauriciovasquezbernal Mar 25, 2020
656d3a4
Update PyPI classifiers (#525)
mauriciovasquezbernal Mar 25, 2020
8c495e1
Add indicator if SpanContext was propagated from remote parent (#516)
mariojonke Mar 26, 2020
ae08b19
docs: Remove authors from releases (#531)
dgzlopes Mar 26, 2020
8100ab6
Update license boilerplate for #523
c24t Mar 26, 2020
d4b9ca0
Add example app protobuf req, add docs
c24t Mar 26, 2020
e9c0f94
Merge branch 'master' into grpc-again
c24t Mar 26, 2020
b484813
Formatting fix
c24t Mar 26, 2020
f5ae625
Remove grpc example app requirement for now
c24t Mar 27, 2020
2ae99f9
Remove commented code
c24t Mar 30, 2020
720f074
Merge branch 'master' into grpc-again
c24t Mar 30, 2020
9392b67
need a lock when initializing the context
Mar 30, 2020
c10b76f
Merge pull request #4 from codeboten/grpc-again
c24t Mar 30, 2020
a545cdd
Merge branch 'master' into grpc-again
c24t Mar 30, 2020
ac3e617
Don't lint generated files
c24t Mar 30, 2020
88a21ff
Fix now-unused import
c24t Mar 30, 2020
ef080be
Pylint grpcext fixes
c24t Mar 30, 2020
a6eb598
Pylint fixes
c24t Mar 30, 2020
aeb7b5f
Merge branch 'master' into grpc-again
c24t Mar 30, 2020
08e6687
Pylint fixes, ignores
c24t Mar 30, 2020
59858d4
More pylint fixes
c24t Mar 30, 2020
4288861
Merge branch 'master' into grpc-again
c24t Mar 30, 2020
9f5c85a
Misc isort fixes (#535)
c24t Mar 30, 2020
eca618c
Merge branch 'master' into grpc-again
c24t Mar 30, 2020
4e048e0
adding a tox environment for grpc
toumorokoshi Mar 30, 2020
7b950a8
fixing lint
toumorokoshi Mar 30, 2020
06b4c19
Less silly documentation
c24t Mar 30, 2020
8956bfb
Py3.4 threadpools need max_workers
c24t Mar 31, 2020
a8d07cf
Add missing test init
c24t Mar 31, 2020
12db93b
Remove pypy3-test-ext-grpc tox target
c24t Mar 31, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ exclude =
__pycache__
ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger/gen/
ext/opentelemetry-ext-jaeger/build/*
docs/examples/opentelemetry-example-app/src/opentelemetry_example_app/grpc/gen/
4 changes: 2 additions & 2 deletions .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ line_length=79
; docs: https://github.com/timothycrosley/isort#multi-line-output-modes
multi_line_output=3
skip=target
skip_glob=ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger/gen/*,.venv*/*,venv*/*
known_first_party=opentelemetry
skip_glob=**/gen/*,.venv*/*,venv*/*
known_first_party=opentelemetry,opentelemetry_example_app
known_third_party=psutil,pytest
1 change: 1 addition & 0 deletions docs/examples/opentelemetry-example-app/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"opentelemetry-ext-flask",
"flask",
"requests",
"protobuf~=3.11",
],
license="Apache-2.0",
package_dir={"": "src"},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import importlib
import sys

# gRPC-generated modules expect other generated modules to be on the path.
sys.path.extend(importlib.util.find_spec(__name__).submodule_search_locations)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from grpc_tools import protoc


def main():
return protoc.main(
[
"-I.",
"--python_out=.",
"--grpc_python_out=.",
"helloworld.proto",
"route_guide.proto",
]
)


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// https://github.com/grpc/grpc/blob/master/examples/protos/helloworld.proto

syntax = "proto3";

package helloworld;

// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
string name = 1;
}

// The response message containing the greetings
message HelloReply {
string message = 1;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc

import helloworld_pb2 as helloworld__pb2


class GreeterStub(object):
"""The greeting service definition.
"""

def __init__(self, channel):
"""Constructor.

Args:
channel: A grpc.Channel.
"""
self.SayHello = channel.unary_unary(
'/helloworld.Greeter/SayHello',
request_serializer=helloworld__pb2.HelloRequest.SerializeToString,
response_deserializer=helloworld__pb2.HelloReply.FromString,
)


class GreeterServicer(object):
"""The greeting service definition.
"""

def SayHello(self, request, context):
"""Sends a greeting
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_GreeterServicer_to_server(servicer, server):
rpc_method_handlers = {
'SayHello': grpc.unary_unary_rpc_method_handler(
servicer.SayHello,
request_deserializer=helloworld__pb2.HelloRequest.FromString,
response_serializer=helloworld__pb2.HelloReply.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'helloworld.Greeter', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// https://github.com/grpc/grpc/blob/master/examples/protos/route_guide.proto

syntax = "proto3";

package routeguide;

// Interface exported by the server.
service RouteGuide {
// A simple RPC.
//
// Obtains the feature at a given position.
//
// A feature with an empty name is returned if there's no feature at the given
// position.
rpc GetFeature(Point) returns (Feature) {}

// A server-to-client streaming RPC.
//
// Obtains the Features available within the given Rectangle. Results are
// streamed rather than returned at once (e.g. in a response message with a
// repeated field), as the rectangle may cover a large area and contain a
// huge number of features.
rpc ListFeatures(Rectangle) returns (stream Feature) {}

// A client-to-server streaming RPC.
//
// Accepts a stream of Points on a route being traversed, returning a
// RouteSummary when traversal is completed.
rpc RecordRoute(stream Point) returns (RouteSummary) {}

// A Bidirectional streaming RPC.
//
// Accepts a stream of RouteNotes sent while a route is being traversed,
// while receiving other RouteNotes (e.g. from other users).
rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
}

// Points are represented as latitude-longitude pairs in the E7 representation
// (degrees multiplied by 10**7 and rounded to the nearest integer).
// Latitudes should be in the range +/- 90 degrees and longitude should be in
// the range +/- 180 degrees (inclusive).
message Point {
int32 latitude = 1;
int32 longitude = 2;
}

// A latitude-longitude rectangle, represented as two diagonally opposite
// points "lo" and "hi".
message Rectangle {
// One corner of the rectangle.
Point lo = 1;

// The other corner of the rectangle.
Point hi = 2;
}

// A feature names something at a given point.
//
// If a feature could not be named, the name is empty.
message Feature {
// The name of the feature.
string name = 1;

// The point where the feature is detected.
Point location = 2;
}

// A RouteNote is a message sent while at a given point.
message RouteNote {
// The location from which the message is sent.
Point location = 1;

// The message to be sent.
string message = 2;
}

// A RouteSummary is received in response to a RecordRoute rpc.
//
// It contains the number of individual points received, the number of
// detected features, and the total distance covered as the cumulative sum of
// the distance between each point.
message RouteSummary {
// The number of points received.
int32 point_count = 1;

// The number of known features passed while traversing the route.
int32 feature_count = 2;

// The distance covered in metres.
int32 distance = 3;

// The duration of the traversal in seconds.
int32 elapsed_time = 4;
}
Loading