This repository was archived by the owner on Jul 31, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1616#define OPENCENSUS_PLUGINS_GRPC_GRPC_PLUGIN_H_
1717
1818#include " absl/strings/string_view.h"
19+ #include " opencensus/trace/span.h"
20+
21+ namespace grpc {
22+ class ServerContext ;
23+ }
1924
2025namespace opencensus {
2126
@@ -24,6 +29,9 @@ namespace opencensus {
2429// defined below.
2530void RegisterGrpcPlugin ();
2631
32+ // Returns the tracing Span for the current RPC.
33+ opencensus::trace::Span GetSpanFromServerContext (grpc::ServerContext* context);
34+
2735// The tag key for the RPC method and status, set for all values recorded for
2836// the following measures.
2937extern const absl::string_view kMethodTagKey ;
Original file line number Diff line number Diff line change 1313// limitations under the License.
1414
1515#include " opencensus/plugins/grpc/grpc_plugin.h"
16+
17+ #include < grpc++/server_context.h>
18+
1619#include " opencensus/plugins/grpc/internal/channel_filter.h"
1720#include " opencensus/plugins/grpc/internal/client_filter.h"
1821#include " opencensus/plugins/grpc/internal/measures.h"
1922#include " opencensus/plugins/grpc/internal/server_filter.h"
20- #include " src/core/lib/surface/channel_init .h"
23+ #include " opencensus/trace/span .h"
2124
2225namespace opencensus {
2326
@@ -52,6 +55,11 @@ void RegisterGrpcPlugin() {
5255 RpcServerResponseCount ();
5356}
5457
58+ opencensus::trace::Span GetSpanFromServerContext (grpc::ServerContext* context) {
59+ return reinterpret_cast <const CensusContext*>(context->census_context ())
60+ ->Span ();
61+ }
62+
5563// These measure definitions should be kept in sync across opencensus
5664// implementations--see
5765// https://github.com/census-instrumentation/opencensus-java/blob/master/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstants.java.
You can’t perform that action at this time.
0 commit comments